comparison parser.vistxt @ 0:76568becd6d6

Rhope Alpha 2a source import
author Mike Pavone <pavone@retrodev.com>
date Tue, 28 Apr 2009 23:06:07 +0000
parents
children b3f71490858c
comparison
equal deleted inserted replaced
-1:000000000000 0:76568becd6d6
1 Import extendlib.vistxt
2
3
4
5 Company Parser
6 |:
7 Arg Begin
8 Arg End
9 Line Comment
10 Comment Begin
11 Comment End
12 Assign
13 Block Begin
14 Block End
15 Blueprint Type Delim
16 Empty Block
17 Binary Operator
18 String Begin
19 String End
20 String Escape
21 List Begin
22 List End
23 List Delim
24 In Out Delim
25 Do Worker
26 Index Begin
27 Index End
28 Previous
29 Block Val
30 Set Field
31 Get Field
32 Import
33 Blueprint
34 Global Separator
35 Uses
36 Hex Escape
37 Escape Map
38 :|
39
40 New@Parser(0,1)
41 |:
42 out(0) <- [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Build["Parser"]
43 ]Arg Begin << ["["]
44 ]Arg End <<["]"]
45 ]Line Comment <<["//"]
46 ]Comment Begin <<["/*"]
47 ]Comment End <<["*/"]
48 ]Assign <<["<-"]
49 ]Block Begin <<["{"]
50 ]Block End <<["}"]
51 ]Blueprint Type Delim <<[":"]
52 ]Empty Block <<[";"]
53 ]Binary Operator <<["`"]
54 ]String Begin <<["\""]
55 ]String End <<["\""]
56 ]String Escape <<["\\"]
57 ]List Begin <<["("]
58 ]List End <<[")"]
59 ]List Delim <<[","]
60 ]In Out Delim <<[":"]
61 ]Do Worker <<["$"]
62 ]Index Begin <<["("]
63 ]Index End <<[")"]
64 ]Previous <<["@"]
65 ]Set Field <<["<<"]
66 ]Get Field <<[">>"]
67 ]Import <<["Import"]
68 ]Blueprint <<["Blueprint"]
69 ]Global Separator <<["::"]
70 ]Hex Escape <<["x"]
71 ]Uses <<["uses"]
72 ]Escape Map <<[[[[New@Dictionary[]]Set["n","\n"]]Set["r","\r"]]Set["t","\t"]]
73 :|
74
75 Company Output Reference
76 |:
77 Index
78 Output Number
79 :|
80
81 New@Output Reference(2,1)
82 |:
83 out(0) <- [[Build["Output Reference"]]Index <<[index(0)]]Output Number <<[num(1)]
84 :|
85
86 Add Pipe Reference(3,1)
87 |:
88 reflist <- [refs(0)]Index[name(1)] |::|
89 |:
90 reflist <- New@List[]
91 :|
92 out(0) <- [refs(0)]Set[name(1), [reflist]Append[reference(2)]]
93 :|
94
95 Assignment Save Reference(5,1)
96 |:
97 [[parse worker(3)]Outputs >>]Find[assignment(1)]
98 |:
99 out(0) <- refs(0)
100 :||:
101 out(0) <- Add Pipe Reference[refs(0), assignment(1), New@Output Reference[index(4), output num(2)]]
102 :|
103 :|
104
105 Company Parse Program
106 |:
107 Workers
108 Imports
109 Blueprints
110 Errors
111 :|
112
113 New@Parse Program(0,1)
114 |:
115 out(0) <- [[[Build["Parse Program"]
116 ]Workers <<[New@Dictionary[]]
117 ]Imports <<[New@Dictionary[]]
118 ]Blueprints <<[New@Dictionary[]]
119 :|
120
121 Company Blueprint Definition
122 |:
123 Name
124 Fields
125 :|
126
127 New@Blueprint Definition(2,1)
128 |:
129 out(0) <- [[Build["Blueprint Definition"]]Name << [name(0)]]Fields <<[fields(1)]
130 :|
131
132 Company Parse Worker
133 |:
134 Name
135 Inputs
136 Outputs
137 Line Number
138 Trees
139 Uses Stores
140 :|
141
142 New@Parse Worker(4,1)
143 |:
144 out(0) <- [[[[[[Build["Parse Worker"]]Name <<[name(0)]]Inputs <<[inputs(1)]]Outputs <<[outputs(2)]]Line Number <<[line(3)]]Trees <<[New@List[]]]Uses Stores <<[New@List[]]
145 :|
146
147 Company Worker Node
148 |:
149 Name
150 Params
151 Assignments
152 Blocks
153 Index
154 :|
155
156 New@Worker Node(2,1)
157 |:
158 out(0) <- [[[[Build["Worker Node"]]Name <<[name(0)]]Params <<[params(1)]]Assignments <<[New@List[]]]Blocks <<[New@List[]]
159 :|
160
161 Add List Helper(6,3)
162 |:
163 ,nextworker,nextrefs <- [[list(0)]Index[key(3)]]Add to Worker[worker(1), program(2), parse worker(4), refs(5)]
164 |: nextlist <- [list(0)]Set[key(3), ~] :|
165 [list(0)]Next[key(3)]
166 |:
167 list(0),worker(1),refs(2) <- Add List Helper[nextlist, nextworker, program(2), ~, parse worker(4), nextrefs]
168 :||:
169 list(0) <- Val[nextlist]
170 worker(1) <- Val[nextworker]
171 refs(2) <- Val[nextrefs]
172 :|
173 :|
174
175 Add List to Worker(5,3)
176 |:
177 [list(0)]First
178 |:
179 list(0),worker(1),refs(2) <- Add List Helper[list(0), worker(1), program(2), ~, parse worker(3), refs(4)]
180 :||:
181 list(0) <- list(0)
182 worker(1) <- worker(1)
183 refs(2) <- refs(4)
184 :|
185 :|
186
187 _Add Blocks to Worker(6,3)
188 |:
189 block, next worker, nextrefs <- Add List to Worker[[blocks(0)]Index[key(4)], worker(1), program(2), parse worker(3), refs(5)]
190 next blocks <- [blocks(0)]Set[key(4), block]
191 [blocks(0)]Next[key(4)]
192 |:
193 blocks(0),worker(1),refs(2) <- _Add Blocks to Worker[next blocks, next worker, program(2), parseworker(3), ~, nextrefs]
194 :||:
195 blocks(0) <- Val[next blocks]
196 worker(1) <- Val[next worker]
197 refs(2) <- Val[nextrefs]
198 :|
199 :|
200
201 Add Blocks to Worker(5,3)
202 |:
203 [blocks(0)]First
204 |:
205 blocks(0), worker(1), refs(2) <- _Add Blocks to Worker[blocks(0), worker(1), program(2), parse worker(3), ~, refs(4)]
206 :||:
207 blocks(0) <- blocks(0)
208 worker(1) <- worker(1)
209 refs(2) <- refs(4)
210 :|
211 :|
212
213 Add to Worker@Worker Node(5,3)
214 |:
215 [program(2)]Find Worker[[node(0)]Name >>]
216 |:
217 after worker <- [worker(1)]Add Worker Call[~] |::|
218 |:
219 assignment refs <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker(3)]]Set Input[4, ~], refs(4), [node(0)]Assignments >>]
220 [node(0)]Index <<[~]
221 |:
222 params list, params worker, params refs <- Add List to Worker[[~]Params >>, after worker, program(2), parse worker(3), assignment refs]
223 block list, worker(1), refs(2) <- Add Blocks to Worker[[~]Blocks >>, params worker, program(2), parse worker(3), params refs]
224 node(0) <- [[~]Params <<[params list]]Blocks <<[block list]
225 :|
226 :|
227 :||:
228 Print[["Error: Could not find a worker named "]Append[[node(0)]Name >>]]
229 :|
230 :|
231
232 Add Multi Wire(5,1)
233 |:
234 out(0) <- [worker(0)]Add Wire[[ref(1)]Index >>, [ref(1)]Output Number >>, end index(3), input num(4)]
235 :|
236
237 Add Param Wire(7,1)
238 |:
239 param worker, start index, output num <- [param(1)]Add Wires[worker(0), blocks(4), parse worker(5), assignments(6)] |::|
240 |:
241 out(0) <- [param worker]Add Wire[start index, output num, end index(3), input num(2)]
242 :||::||:
243 out(0) <- Fold[[["Add Multi Wire"]Set Input[3, end index(3)]]Set Input[4, input num(2)], param worker, ~]
244 :|
245 :|
246
247 _Add Block Wire(6,1)
248 |:
249 out(0) <- [node(1)]Add Wires[worker(0), blocks(3), parse worker(4), assignments(5)]
250 :|
251
252 Add Block Wire(7,1)
253 |:
254 blocks <- [existing blocks(4)]Append[New@Output Reference[parent index(3), output num(2)]]
255 out(0) <- Fold[[[["_Add Block Wire"]Set Input[3, blocks]]Set Input[4, parse worker(5)]]Set Input[5, assignments(6)], worker(0), block nodes(1)]
256 //out(0) <- [param(1)]Add Wires[worker(0), blocks]
257 :|
258
259 Assignments Add Wires(5,1)
260 |:
261 [[parse worker(3)]Outputs >>]Find[assignment(1)]
262 |:
263 ,output index <- [worker(0)]Add Output[assignment(1), ~]
264 |:
265 worker(0) <- [~]Add Wire[start index(4), output num(2), output index, 0]
266 :|
267 :||:
268 //Ugly hack alert!
269 If[[asignment(1)]Contains["::"]]
270 |:
271 parts <- [assignment(1)]Split["::"]
272 ,global index <- [worker(0)]Add Global Set[[parts]Index[0], [parts]Index[1]]
273 |:
274 worker(0) <- [~]Add Wire[start index(4), output num(2), global index, 0]
275 :|
276 :||:
277 worker(0) <- worker(0)
278 :|
279 :|
280 :|
281
282 Has Block@Worker Node(1,2)
283 |:
284 out(0) <- Yes
285 :|
286
287 _Has Block Params(2,1)
288 |:
289 param <- [param list(0)]Index[key(1)]
290 out(0) <- [param]Has Block |::|
291 |:
292 [param list(0)]Next[key(1)]
293 |:
294 out(0) <- _Has Block Params[param list(0), ~]
295 :||:
296 out(0) <- No
297 :|
298 :|
299
300 :|
301
302 Has Block Params(1,1)
303 |:
304 [param list(0)]First
305 |:
306 out(0) <- _Has Block Params[param list(0), ~]
307 :||:
308 out(0) <- No
309 :|
310 :|
311
312 Add Wires@Worker Node(5,4)
313 |:
314 worker(0),index(1),num(2) <- Add Wires Worker or Field[node(0), worker(1), blocks(2), parse worker(3), assignments(4)]
315 :|
316
317 Add Wires Worker or Field(5,4)
318 |:
319 Fold[[["Assignments Add Wires"]Set Input[3, parse worker(3)]]Set Input[4, [node(0)]Index >>], worker(1), [node(0)]Assignments >>]
320 |: Fold[[[[["Add Block Wire"]Set Input[3, [node(0)]Index >>]]Set Input[4, blocks(2)]]Set Input[5, parse worker(3)]]Set Input[6, assignments(4)], ~, [node(0)]Blocks >>]
321 |: params worker <- Fold[[[[["Add Param Wire"]Set Input[3, [node(0)]Index >>]]Set Input[4, blocks(2)]]Set Input[5, parse worker(3)]]Set Input[6, assignments(4)], ~, [node(0)]Params >>] :|:|
322 If[Has Block Params[[node(0)]Params >>]]
323 |:
324 worker(0) <- Val[params worker]
325 :||:
326 [blocks(2)]Peek
327 |:
328 worker(0) <- [params worker]Add Wire[[~]Index >>, [~]Output Number >>, [node(0)]Index >>, [0]-[1]]
329 :||:
330 worker(0) <- Val[params worker]
331 :|
332 :|
333 index(1) <- [node(0)]Index >>
334 num(2) <- 0
335 :|
336
337 Company Field Node
338 |:
339 Name
340 Params
341 Assignments
342 Blocks
343 Index
344 Set?
345 :|
346
347 Has Block@Field Node(1,2)
348 |:
349 has block(0) <- Yes
350 :|
351
352 New@Field Node(3,1)
353 |:
354 out(0) <- [[[[[Build["Field Node"]]Name <<[name(0)]]Assignments <<[New@List[]]]Blocks <<[New@List[]]]Set? <<[set(2)]]Params <<[params(1)]
355 :|
356
357 Add to Worker@Field Node(5,3)
358 |:
359 If[[node(0)]Set? >>]
360 |:
361 after worker,index <- [worker(1)]Add Object Set[[node(0)]Name >>]
362 :||:
363 after worker,index <- [worker(1)]Add Object Get[[node(0)]Name >>]
364 :|
365 index
366 |:
367 assignment refs <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker(3)]]Set Input[4, ~], refs(4), [node(0)]Assignments >>]
368 [node(0)]Index <<[~]
369 |:
370 params list, params worker, params refs <- Add List to Worker[[~]Params >>, after worker, program(2), parse worker(3), assignment refs]
371 block list, worker(1), refs(2) <- Add Blocks to Worker[[~]Blocks >>, params worker, program(2), parse worker(3), params refs]
372 node(0) <- [[~]Params <<[params list]]Blocks <<[block list]
373 :|
374 :|
375 :|
376
377 Add Wires@Field Node(5,4)
378 |:
379 worker(0),index(1),num(2) <- Add Wires Worker or Field[node(0), worker(1), blocks(2), parse worker(3), assignments(4)]
380 :|
381
382 Company Named Pipe Node
383 |:
384 Name
385 Assignments
386 Blocks
387 Index
388 :|
389
390 Has Block@Named Pipe Node(1,2)
391 |:
392 If[[[node(0)]Index >>] < [0]]
393 |:
394 //~ should really be a parser parameter
395 If[[[node(0)]Name >>] = ["~"]]
396 |:
397 has block(0) <- Yes
398 :||:
399 no block(1) <- No
400 :|
401 :||:
402 has block(0) <- Yes
403 :|
404 :|
405
406 New@Named Pipe Node(1,1)
407 |:
408 out(0) <- [[[Build["Named Pipe Node"]]Name <<[name(0)]]Assignments <<[New@List[]]]Blocks <<[New@List[]]
409 :|
410
411 Add to Worker@Named Pipe Node(5,3)
412 |:
413 [[parse worker(3)]Inputs >>]Find[[node(0)]Name >>]
414 |:
415 after add <- [worker(1)]Add Input[[node(0)]Name >>, ~] |::|
416 |:
417 assign refs <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker(3)]]Set Input[4, ~], refs(4), [node(0)]Assignments >>]
418 index node <- [node(0)]Index <<[~]
419 :|
420 :||:
421 after add <- worker(1)
422 index node <- [node(0)]Index <<[[0]-[1]]
423 //TODO: Handle assignments from a named pipe that isn't an input
424 assign refs <- refs(4)
425 :|
426 block list, worker(1), refs(2) <- Add Blocks to Worker[[node(0)]Blocks >>, after add, program(2), parse worker(3), assign refs]
427 node(0) <- [index node]Blocks <<[block list]
428 :|
429
430 Add Wires@Named Pipe Node(5,4)
431 |:
432 reflist(3) <- [assignments(4)]Index[[node(0)]Name >>]
433 |:
434 //TODO: Fix support for a named pipe with a block
435 worker(0) <- worker (1)
436 :||:
437 If[[[node(0)]Name >>] = ["~"]]
438 |:
439 wires worker <- worker(1)
440 [blocks(2)]Peek
441 |:
442 my index <- [~]Index >>
443 num(2) <- [~]Output Number >>
444 :||:
445 //TODO: Propagate an error rather than printing it out
446 Print["Error, block reference symbol (~) located outside of a block"]
447 :|
448 :||:
449 If[[[node(0)]Index >>] < [0]]
450 |:
451 Print[[[["Error, reference to named pipe "]Append[[node(0)]Name >>]]Append[" that was never assigned to in worker "]]Append[[parse worker(3)]Name >>]]
452 :||:
453 my index <- [node(0)]Index >>
454 num(2) <- 0
455 assignments worker <- Fold[[["Assignments Add Wires"]Set Input[3, parse worker(3)]]Set Input[4, [node(0)]Index >>], worker(1), [node(0)]Assignments >>]
456 [blocks(2)]Peek
457 |:
458 wires worker <- [assignments worker]Add Wire[[~]Index >>, [~]Output Number >>, [node(0)]Index >>, [0]-[1]]
459 :||:
460 wires worker <- Val[assignments worker]
461 :|
462 :|
463 :|
464 :|
465 index(1) <- my index
466
467 worker(0) <- Fold[[[[["Add Block Wire"]Set Input[3, my index]]Set Input[4, blocks(2)]]Set Input[5, parse worker(3)]]Set Input[6, assignments(4)], wires worker, [node(0)]Blocks >>]
468 :|
469
470 Company Global Node
471 |:
472 Store
473 Name
474 Assignments
475 Blocks
476 Index
477 :|
478
479 New@Global Node(2,1)
480 |:
481 out(0) <- [[[[Build["Global Node"]]Store <<[store(0)]]Name <<[name(1)]]Assignments <<[New@List[]]]Blocks <<[New@List[]]
482 :|
483
484 Add to Worker@Global Node(5,3)
485 |:
486 out worker(1) <- [worker(1)]Add Global Get[[node(0)]Store >>, [node(0)]Name >>] |::|
487 |:
488 refs(2) <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker(3)]]Set Input[4, ~], refs(4), [node(0)]Assignments >>]
489 out node(0) <- [node(0)]Index <<[~]
490 :|
491 refs(2) <- refs(4)
492 :|
493
494 Add Wires@Global Node(5,4)
495 |:
496 worker(0),index(1),num(2) <- Add Wires Literal or Global[node(0), worker(1), blocks(2), parse worker(3), assignments(4)]
497 :|
498
499 Has Block@Global Node(1,2)
500 |:
501 out(0) <- Yes
502 :|
503
504 Company Literal Node
505 |:
506 Value
507 Assignments
508 Blocks
509 Index
510 :|
511
512 Has Block@Literal Node(1,2)
513 |:
514 out(0) <- Yes
515 :|
516
517 New@Literal Node(1,1)
518 |:
519 out(0) <- [[[Build["Literal Node"]]Value <<[value(0)]]Assignments <<[New@List[]]]Blocks <<[New@List[]]
520 :|
521
522 Add to Worker@Literal Node(5,3)
523 |:
524 out worker(1) <- [worker(1)]Add Constant[[node(0)]Value >>] |::|
525 |:
526 refs(2) <- Fold[[["Assignment Save Reference"]Set Input[3, parse worker(3)]]Set Input[4, ~], refs(4), [node(0)]Assignments >>]
527 out node(0) <- [node(0)]Index <<[~]
528 :|
529 :|
530
531 Add Wires@Literal Node(5,4)
532 |:
533 worker(0),index(1),num(2) <- Add Wires Literal or Global[node(0), worker(1), blocks(2), parse worker(3), assignments(4)]
534 :|
535
536 Add Wires Literal or Global(5,4)
537 |:
538 assignments worker <- Fold[[["Assignments Add Wires"]Set Input[3, parse worker(3)]]Set Input[4, [node(0)]Index >>], worker(1), [node(0)]Assignments >>]
539 [blocks(2)]Peek
540 |:
541 worker(0) <- [assignments worker]Add Wire[[~]Index >>, [~]Output Number>>, [node(0)]Index >>, [0]-[1]]
542 :||:
543 worker(0) <- Val[assignments worker]
544 :|
545 index(1) <- [node(0)]Index >>
546 num(2) <- 0
547 :|
548
549 Company Block Node
550 |:
551 Number
552 :|
553
554 Company Parse Error
555 |:
556 Type
557 Text
558 Line Number
559 :|
560
561 New@Parse Error(3,1)
562 |:
563 out(0) <- [[[Build["Parse Error"]]Type <<[type(0)]]Text <<[text(1)]]Line Number <<[number(2)]
564 :|
565
566 Filter Empty(1,1)
567 |:
568 If[[[string(0)]Length] > [0]]
569 |:
570 out(0) <- Yes
571 :||:
572 out(0) <- No
573 :|
574 :|
575
576 Company Blueprint Field
577 |:
578 Name
579 Type
580 :|
581
582 New@Blueprint Field(2,1)
583 |:
584 out(0) <- [[Build["Blueprint Field"]]Name <<[name(0)]]Type <<[type(1)]
585 :|
586
587 Process Blueprint Field(3,1)
588 |:
589 parts <- [field(1)]Split[delim(2)]
590 If[[[parts]Length] > [1]]
591 |:
592 out(0) <- [list(0)]Append[New@Blueprint Field[[parts]Index[1], [parts]Index[0]]]
593 :||:
594 out(0) <- [list(0)]Append[New@Blueprint Field[[parts]Index[0], "Any Type"]]
595 :|
596 :|
597
598 Block Comment(4,1)
599 |:
600 If[[block count(3)] > [0]]
601 |:
602 after, before <- [string(0)]Get DString[[[New@List[]]Append[begin comment(1)]]Append[end comment(2)]] |::| |::|
603 |:
604 If[[~] = [begin comment(1)]]
605 |:
606 out(0) <- Block Comment[after, begin comment(1), end comment(2), [block count(3)]+[1]]
607 :||:
608 out(0) <- Block Comment[after, begin comment(1), end comment(2), [block count(3)]-[1]]
609 :|
610 :||:
611 //No match
612 out(0) <- ""
613 :|
614 :||:
615 out(0) <- string(0)
616 :|
617 :|
618
619 Line Comment(1,1)
620 |:
621 [string(0)]Get DString["\n"]
622 |:
623 out(0) <- ["\n"]Append[~]
624 :| |::| |::| |:
625 out(0) <- ""
626 :|
627 :|
628
629 _Get Comment DString(6,4)
630 |:
631 after,before,delim,nomatch(3) <- [string(0)]Get DString[delims(1)]
632 |:
633 If[[delim] = [line comment(2)]]
634 |:
635 after comment <- Line Comment[after]
636 :||:
637 If[[delim] = [begin comment(3)]]
638 |:
639 after comment <- Block Comment[after, begin comment(3), end comment(4), 1]
640 :||:
641 rest(0) <- Val[after]
642 before(1) <- [prev before(5)]Append[before]
643 delim(2) <- Val[delim]
644 :|
645 :|
646 :| |::| |::| |:
647 before(1) <- [prev before(5)]Append[before]
648 :|
649
650 after comment
651 |:
652 rest(0),more before,delim(2),nomatch(3) <- _Get Comment DString[~, delims(1), line comment(2), begin comment(3), end comment(4), prev before(5)]
653 before(1) <- [before]Append[more before]
654 :|
655
656 :|
657
658 Get Comment DString(3,4)
659 |:
660 line comment <- [params(2)]Line Comment >>
661 begin comment <- [params(2)]Comment Begin >>
662 end comment <- [params(2)]Comment End >>
663 all delims <- [[[delims(1)]As List]Append[begin comment]]Append[line comment]
664 rest(0), before(1), delim(2), not found(3) <- _Get Comment DString[string(0), delims(1), line comment, begin comment, end comment, ""]
665 :|
666
667 Comment Left Trim(3,1)
668 |:
669 line comment <- [params(2)]Line Comment >>
670
671 end comment <- [params(2)]Comment End >>
672 trimmed <- Left Trim[string(0), trim chars(1)]
673 If[[trimmed]Starts With[line comment]]
674 |:
675 ,after delim <- [trimmed]Slice[[line comment]Length]
676 out(0) <- Comment Left Trim[Line Comment[after delim], trim chars(1), params(2)]
677 :||:
678 begin comment <- [params(2)]Comment Begin >>
679 If[[trimmed]Starts With[begin comment]]
680 |:
681 ,after delim <- [trimmed]Slice[[line comment]Length]
682 out(0) <- Comment Left Trim[Block Comment[after delim, begin comment, end comment, 1], trim chars(1), params(2)]
683 :||:
684 out(0) <- Val[trimmed]
685 :|
686 :|
687 :|
688
689 Blueprint(4,1)
690 |:
691 ,whitespace name <- [string(0)]Get Comment DString[[params(1)]Block Begin >>, params(1)]
692 |:
693 ,no blueprint <- [whitespace name]Slice[ [[params(1)]Blueprint >>]Length ]
694 name <- Trim[no blueprint, "\r\n\t "]
695 name lines <- 0//[Count Substring[left, "\n"]] + [Count Substring[right, "\n"]]
696 ,body <- [~]Get Comment DString[ [params(1)]Block End >>, params(1)]
697 |:
698 body lines <- [body]Split["\n"]
699 more lines <- [[[body lines]Length] - [1]] + [name lines]
700 fields <- Fold[["Process Blueprint Field"]Set Input[2, [params(1)]Blueprint Type Delim >>], New@List[], Filter[Map[body lines, ["Trim"]Set Input[1,"\n\r\t "]], "Filter Empty"]]
701 new tree <- [tree(2)]Blueprints << [ [[tree(2)]Blueprints >>]Set[name, New@Blueprint Definition[name, fields]] ]
702 out(0) <- Null[~, params(1), new tree, [lines(3)] + [more lines]]
703 :| |::| |:
704 out(0) <- [tree(2)]Errors <<[ [[tree(2)]Errors >>]Append[New@Parse Error["Error",[["Blueprint is missing an block close symbol \""]Append[[params(1)]Block End >>]]Append["\""], lines(3)]] ]
705 :|
706
707 :| |::| |:
708 out(0) <- [tree(2)]Errors <<[ [[tree(2)]Errors >>]Append[New@Parse Error["Error",[["Blueprint is missing an block open symbol \""]Append[[params(1)]Block Begin >>]]Append["\""], lines(3)]] ]
709 :|
710 :|
711
712 Parse Import(4,1)
713 |:
714 [line]Slice[ [[params(1)]Import >>]Length ] |::|
715 |:
716 filename <- Trim[~, " \n\r\t"]
717 :|
718 new tree <- [tree(2)]Imports <<[ [[tree(2)]Imports >>]Set[filename, Yes] ]
719 ,line <- [string(0)]Get Comment DString["\n", params(1)]
720 |:
721 out(0) <- Null[~, params(1), new tree, [lines(3)] + [1]]
722 :| |::| |:
723 out(0) <- Val[new tree]
724 :|
725 :|
726
727 Get Expression Blocks(3,2)
728 |:
729 check block <- Comment Left Trim[string(0), "\n\r\t ", params(1)]
730 If[[check block]Starts With[[params(1)]Block Begin >>]]
731 |:
732 ,begin block <- [check block]Slice[[[params(1)]Block Begin >>]Length]
733 trees, after block <- Worker Body[begin block, params(1), New@List[]]
734 blocks(0), after(1) <- Get Expression Blocks[after block, params(1), [blocks(2)]Append[trees]]
735 :||:
736 If[[check block]Starts With[[params(1)]Empty Block >>]]
737 |:
738 blocks(0) <- blocks(2)
739 ,after(1) <- [check block]Slice[[[params(1)]Empty Block >>]Length]
740 :||:
741 blocks(0) <- blocks(2)
742 after(1) <- Val[check block]
743 :|
744 :|
745 :|
746
747 Parse Escape(2,2)
748 |:
749 code,rest <- [string(0)]Slice[1]
750 If[[code] = [[params(1)]Hex Escape >>]]
751 |:
752 hex,after(1) <- [rest]Slice[2]
753 char(0) <- [""]Put Byte[From Hex@Whole Number[hex]]
754 :||:
755 after(1) <- Val[rest]
756 char(0) <- [[params(1)]Escape Map >>]Index[code] |::|
757 |:
758 char(0) <- Val[code]
759 :|
760 :|
761 :|
762
763 Parse String(3,2)
764 |:
765 delims <- [[New@List[]]Append[[params(1)]String End >>]]Append[[params(1)]String Escape >>]
766 after, before, delim <- [string(0)]Get Comment DString[delims, params(1)]
767 |:
768 If[[delim] = [[params(1)]String End >>]]
769 |:
770 value(0) <- [current(2)]Append[before]
771 after(1) <- Val[after]
772 :||:
773 char,after escape <- Parse Escape[after, params(1)]
774 value(0),after(1) <- Parse String[after escape, params(1), [[current(2)]Append[before]]Append[char]]
775 :|
776 :|
777 :|
778
779 Parse List(3,2)
780 |:
781 trimmed <- Comment Left Trim[string(0), "\r\n\t ", params(1)]
782 If[[trimmed]Starts With[[params(1)]List End >>]]
783 |:
784 value(0) <- list(2)
785 ,after(1) <- [trimmed]Slice[[[params(1)]List End >>]Length]
786 :||:
787 If[[trimmed]Starts With[[params(1)]List Delim >>]]
788 |:
789 ,el string <- [trimmed]Slice[[[params(1)]List Delim >>]Length]
790 :||:
791 el string <- Val[trimmed]
792 :|
793 element,after el <- Named Pipe or Literal[el string, params(1)]
794 value(0),after(1) <- Parse List[after el, params(1), [list(2)]Append[[element]Get Value]]
795 :|
796 :|
797
798 Get Value@Literal Node(1,1)
799 |:
800 out(0) <- [node(0)]Value >>
801 :|
802
803 Get Value@Named Pipe Node(1,1)
804 |:
805 out(0) <- node(0)
806 :|
807
808 Parse Number(2,2)
809 |:
810 delims <- [[[[{" ","\t","\n","\r"}]Append[[params(1)]List Delim >>]]Append[[params(1)]Block Begin >>]]Append[[params(1)]Arg End >>]]Append[[params(1)]List End >>]
811 after delim,valstring <- [string(0)]Get Comment DString[delims, params(1)] |::| |::|
812 |:
813 after(1) <- [~]Append[after delim]
814 :||:
815 after(1) <- ""
816 :|
817 first two,rest <- [valstring]Slice[2]
818 If[[first two] = ["0x"]]
819 |:
820 value(0) <- From Hex@Whole Number[rest]
821 :||:
822 If[[valstring]Contains["."]]
823 |:
824 value(0) <- <String@Real Number[valstring]
825 :||:
826 value(0) <- <String@Whole Number[valstring]
827 :|
828 :|
829 :|
830
831 Named Pipe or Literal(2,2)
832 |:
833 name <- Comment Left Trim[string(0), "\n\r\t ", params(1)]
834 If[[name]Starts With[[params(1)]String Begin >>]]
835 |:
836 ,string begin <- [name]Slice[[[params(1)]String Begin >>]Length]
837 value,after(1) <- Parse String[string begin, params(1), ""]
838 :||:
839 If[[name]Starts With[[params(1)]List Begin >>]]
840 |:
841 ,list start <- [name]Slice[[[params(1)]List Begin >>]Length]
842 value,after(1) <- Parse List[list start, params(1), New@List[]]
843 :||:
844 If[[[name]Slice[1]]In["-0123456789"]]
845 |:
846 value,after(1) <- Parse Number[name, params(1)]
847 :||:
848 delims <- [[[[[[{"\n"}]Append[[params(1)]Block Begin >>]]Append[[params(1)]Block End >>]]Append[[params(1)]Empty Block >>]]Append[[params(1)]Arg End >>]]Append[[params(1)]List Delim >>]]Append[[params(1)]List End >>]
849 ,before,delim <- [name]Get Comment DString[delims, params(1)]
850 |:
851 after(1) <- [delim]Append[~]
852 :| |::| |::| |:
853 after(1) <- ""
854 :|
855 If[[before] = ["Yes"]]
856 |:
857 yesno <- Yes
858 :||:
859 If[[before] = ["No"]]
860 |:
861 yesno <- No
862 :||:
863 If[[before] = [""]]
864 |:
865 Print[[["Found "]Append[delim]]Append[" where a named pipe or literal was expected"]]
866 :||:
867 If[[before]Contains[[params(1)]Global Separator >>]]
868 |:
869 parts <- [before]Split[[params(1)]Global Separator >>]
870 out(0) <- New@Global Node[Right Trim[[parts]Index[0],"\r\n\t "], Trim[[parts]Index[1], "\r\n\t "]]
871 :||:
872 out(0) <- New@Named Pipe Node[Right Trim[before,"\r\n\t "]]
873 :|
874 :|
875 :|
876 :|
877 out(0) <- New@Literal Node[yesno]
878 :|
879 :|
880 :|
881 out(0) <- New@Literal Node[value]
882 :|
883
884 Parse Arguments(3,2)
885 |:
886 args <- Comment Left Trim[string(0), "\r\n\t ", params(1)]
887 If[[args]Starts With[[params(1)]List Delim >>]]
888 |:
889 [args]Slice[[[params(1)]List Delim >>]Length] |::|
890 |:
891 final args <- Comment Left Trim[~, "\r\n\t ", params(1)]
892 :|
893 :||:
894 If[[args]Starts With[[params(1)]Arg End >>]]
895 |:
896 args(0) <- arglist(2)
897 ,after(1) <- [args]Slice[[[params(1)]Arg End >>]Length]
898 :||:
899 final args <- Val[args]
900 :|
901 :|
902 arg, after arg <- Parse Expression[final args, params(1)]
903 args(0), after(1) <- Parse Arguments[after arg, params(1), [arglist(2)]Append[arg]]
904 :|
905
906 Worker or Field(3,1)
907 |:
908 get field <- [params(2)]Get Field >>
909 If[[name(0)]Ends With[get field]]
910 |:
911 field <- Right Trim[[name(0)]Slice[[[name(0)]Length] - [[get field]Length]], "\n\r\t "]
912 out(0) <- New@Field Node[field, args(1), No]
913 :||:
914 set field <- [params(2)]Set Field >>
915 If[[name(0)]Ends With[set field]]
916 |:
917 field <- Right Trim[[name(0)]Slice[[[name(0)]Length] - [[set field]Length]], "\n\r\t "]
918 out(0) <- New@Field Node[field, args(1), Yes]
919 :||:
920 out(0) <- New@Worker Node[name(0), args(1)]
921 :|
922 :|
923 :|
924
925 Prefix(4,2)
926 |:
927 //Parse argument list
928 more args,after(1) <- Parse Arguments[string(0), params(1), existing args(3)]
929 expression(0) <- Worker or Field[name(2), more args, params(1)]
930 :|
931
932 Postfix or Infix(2,2)
933 |:
934 args, after args <- Parse Arguments[string(0), params(1), New@List[]]
935 delims <- [[[[[{"\n"}]Append[[params(1)]Arg Begin >>]]Append[[params(1)]Empty Block >>]]Append[[params(1)]Block Begin >>]]Append[[params(1)]Arg End >>]]Append[[params(1)]List Delim >>]
936 after,before,delim <- [after args]Get Comment DString[delims, params(1)]
937 |:
938 If[[delim] = [[params(1)]Arg Begin >>]]
939 |:
940 expression(0), after(1) <- Prefix[after, params(1), Trim[before,"\r\n\t "], args]
941 :||:
942 If[[delim] = [[params(1)]Empty Block >>]]
943 |:
944 after expression(1) <- Val[after]
945 :||:
946 ,after expression(1) <- [after args]Slice[[before]Length]
947 :|
948 expression(0) <- Worker or Field[Trim[before,"\r\n\t "], args, params(1)]
949 :|
950 :|
951 :|
952
953 Parse Expression(2,2)
954 |:
955 delims <- [[[[[[[{"\n"}]Append[[params(1)]Arg Begin >>]]Append[[params(1)]Arg End >>]]Append[[params(1)]Assign >>]]Append["\n"]]Append[[params(1)]Empty Block >>]]Append[[params(1)]Block End >>]]Append[[params(1)]String Begin >>]
956 after, before, delim <- [trimmed(0)]Get Comment DString[delims, params(1)]
957 |:
958 //If we find an arg begin token, we have a worker expression
959 If[[delim] = [[params(1)]Arg Begin >>]]
960 |:
961 maybe name <- Right Trim[before, "\r\t "]
962 //Prefix expressions will have the worker name before the first arg begin token
963 If[[maybe name] = [""]]
964 |:
965 expression, after expression <- Postfix or Infix[after, params(1)]
966 :||:
967 If[[maybe name]Contains[[params(1)]List Delim >>]]
968 |:
969 after expression <- [after literal]Append[[delim]Append[after]]
970 expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params(1)]
971 :||:
972 expression, after expression <- Prefix[after, params(1), maybe name, New@List[]]
973 :|
974 :|
975 :||:
976 If[[delim] = [[params(1)]Assign >>]]
977 |:
978 //Expressions starting with an assignment can be prefix, postfix or infix
979 //or they can be a simple literal or named pipe
980 assignments <- Map[[before]Split[[params(1)]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]]
981 ,after blocks(1) <- Parse Expression[Comment Left Trim[after, " \n\r\t", params(1)], params(1)]
982 |:
983 final expression(0) <- [~]Assignments <<[assignments]
984 :|
985 :||:
986 //If[[delim] = [[params(1)]String Begin >>]]
987 //|:
988 // If[[Trim[before, "\r\n\t "]] = [""]]
989 // |:
990 // expression, after expression <- Named Pipe or Literal[[delim]Append[after], params(1)]
991 // :||:
992 // after expression <- [after literal]Append[[delim]Append[after]]
993 // expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params(1)]
994 // :|
995 //:||:
996 // after expression <- [after literal]Append[[delim]Append[after]]
997 // expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params(1)]
998 //:|
999 expression, after expression <- Named Pipe or Literal[trimmed(0), params(1)]
1000 :|
1001 :|
1002 //Any expression can be followed by one or more blocks mapping the inputs of other expressions
1003 //to the outputs of the current one
1004 blocks,after blocks(1) <- Get Expression Blocks[after expression, params(1), New@List[]]
1005 final expression(0) <- [expression]Blocks <<[blocks]
1006 :|
1007 :|
1008
1009 Worker Body(3,2)
1010 |:
1011 trimmed <- Comment Left Trim[string(0), "\n\r\t ", params(1)]
1012 If[[trimmed]Starts With[[params(1)]Block End >>]]
1013 |:
1014 //We're done with this block, return
1015 ,after end(1) <- [trimmed]Slice[[[params(1)]Block End >>]Length]
1016 trees(0) <- trees(2)
1017 :||:
1018 expression, after expression <- Parse Expression[trimmed, params(1)]
1019 trees(0),after end(1) <- Worker Body[after expression, params(1), [trees(2)]Append[expression]]
1020 :|
1021 :|
1022
1023 Process Modifiers(3,1)
1024 |:
1025 //Eventually this will need to be more sophisticated to handle more modifiers
1026 trimmed <- Comment Left Trim[modifiers(2), "\n\r\t ", params(1)]
1027 If[[trimmed]Starts With[[params(1)]Uses >>]]
1028 |:
1029 ,after uses <- [trimmed]Slice[[[params(1)]Uses >>]Length]
1030 ,stores string <- [after uses]Get Comment DString["\n", params(1)]
1031 out(0) <- [worker(0)]Uses Stores <<[Map[[stores string]Split[[params(1)]List Delim >>], ["Trim"]Set Input[1, "\r\n\t "]]]
1032 :||:
1033 out(0) <- worker(0)
1034 :|
1035 :|
1036
1037 Worker Name(4,1)
1038 |:
1039 ,whitespace name <- [string(0)]Get Comment DString[[params(1)]Arg Begin >>, params(1)]
1040 |:
1041 worker name <- Trim[whitespace name, "\n\r\t "]
1042 in out <- [params(1)]In Out Delim >>
1043 arg end <- [params(1)]Arg End >>
1044 delims <- [[New@List[]]Append[in out]]Append[arg end]
1045 after <- [~]Get Comment DString[delims, params(1)] |::|
1046 |:
1047 arglist <- Trim[~,"\r\n\t "]
1048 :||:
1049 //check if there is an in/out separator
1050 //if it isn't present, everything in the arglist is an input
1051 If[[~] = [in out]]
1052 |:
1053 after arglist <- [after]Get Comment DString[arg end, params(1)] |::|
1054 |:
1055 output string <- Trim[~,"\n\r\t "]
1056 :|
1057 :||:
1058 after arglist <- Val[after]
1059 output string <- ""
1060 :|
1061 inputs <- Map[[arglist]Split[[params(1)]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]]
1062 outputs <- Map[[output string]Split[[params(1)]List Delim >>], ["Trim"]Set Input[1,"\n\r\t "]]
1063
1064 New@Parse Worker[worker name, inputs, outputs, 0]
1065 |:
1066 body text, modifiers <- [after arglist]Get Comment DString[[params(1)]Block Begin >>, params(1)]
1067 modified <- Process Modifiers[~, params(1), modifiers]
1068 expression trees, after body <- Worker Body[body text, params(1), New@List[]]
1069 worker <- [modified]Trees <<[expression trees]
1070 new worker dict <- [[tree(2)]Workers >>]Set[worker name, worker]
1071 out(0) <- Null[after body, params(1), [tree(2)]Workers <<[new worker dict], 0]
1072 :|
1073 :|
1074 :||::||::||:
1075 out(0) <- tree(2)
1076 :|
1077 :|
1078
1079 Null(4,1)
1080 |:
1081 trimmed <- Comment Left Trim[string(0), " \n\r\t", params(1)]
1082 current line <- 0//[lines(3)] + [Count Substring[whitespace, "\n"]]
1083 If[[trimmed]Starts With[ [params(1)]Blueprint >> ]]
1084 |:
1085 out(0) <- Blueprint[trimmed, params(1), tree(2), current line]
1086 :||:
1087 If[[trimmed]Starts With[ [params(1)]Import >> ]]
1088 |:
1089 out(0) <- Parse Import[trimmed, params(1), tree(2), current line]
1090 :||:
1091 out(0) <- Worker Name[trimmed, params(1), tree(2), current line]
1092 :|
1093 :|
1094 :|
1095
1096 Add Workers(3,1)
1097 |:
1098 prog,worker <- [program(2)]New Worker[name(1)]
1099 [worker]Set IO Counts[ [[[worker(0)]Index[name(1)]]Inputs >>]Length, [[[worker(0)]Index[name(1)]]Outputs >>]Length]
1100 [workers(0)]Next[name(1)]
1101 |:
1102 out(0) <- Add Workers[workers(0), ~, prog]
1103 :||:
1104 out(0) <- Val[prog]
1105 :|
1106 :|
1107
1108 Add Wires Helper(5,1)
1109 |:
1110 worker(0) <- [node(1)]Add Wires[worker(0), New@List[], parse worker(3), assignments(4)]
1111 :|
1112
1113 Add Contents(3,2)
1114 |:
1115 worker <- [[program(2)]Find Worker[name(1)]]Uses[[parse worker(0)]Uses Stores >>]
1116 trees, contents worker, refs <- Add List to Worker[[parse worker(0)]Trees >>, worker, program(2), parse worker(0), New@Dictionary[]]
1117 Fold[[["Add Wires Helper"]Set Input[3, parse worker(0)]]Set Input[4, refs], contents worker, trees]
1118 out(0) <- [parse worker(0)]Trees <<[trees]
1119 key(1) <- name(1)
1120 :|
1121
1122 Add Blueprint Field(3,1)
1123 |:
1124 out(0) <- [blueprint(0)]Add Field[[field(1)]Name >>, [field(1)]Type >>]
1125 :|
1126
1127 Add Blueprint(2,1)
1128 |:
1129 out(0) <- [prog(0)]New Blueprint[[def(1)]Name >>] |::|
1130 |:
1131 Fold["Add Blueprint Field", ~, [def(1)]Fields >>]
1132 :|
1133 :|
1134
1135 _Tree to Program(2,1)
1136 |:
1137 after blueprint <- Fold["Add Blueprint", program(1), [parse tree(0)]Blueprints >>]
1138 [[parse tree(0)]Workers >>]First
1139 |:
1140 prog <- Add Workers[[parse tree(0)]Workers >>, ~, after blueprint]
1141 :|
1142 Key Value Map[[parse tree(0)]Workers >>, ["Add Contents"]Set Input[2, prog]]
1143 out(0) <- prog
1144 :|
1145
1146 Tree to Program(1,1)
1147 |:
1148 out(0) <- _Tree to Program[parse tree(0), [New@Program[]]Add Builtins]
1149 :|
1150
1151 Needs Imports(3,1)
1152 |:
1153 If[not imported?(1)]
1154 |:
1155 out(0) <- [needs import(0)]Append[name(2)]
1156 :||:
1157 out(0) <- needs import(0)
1158 :|
1159 :|
1160
1161 Do Import(4,1)
1162 |:
1163 file <- <String@File[file name(1)]
1164 ,text <- [file]Get FString[[file]Length]
1165 after import <- Null[text, params(3), tree(0), 0]
1166 out(0) <- [after import]Imports <<[ [[after import]Imports >>]Set[file name(1), No] ]
1167 :|
1168
1169 Process Imports(2,1)
1170 |:
1171 needs import <- Fold["Needs Imports", New@List[], [parse tree(0)]Imports >>]
1172 If[[[needs import]Length] > [0]]
1173 |:
1174 import tree <- Fold[["Do Import"]Set Input[3, params(1)], parse tree(0), needs import]
1175 out(0) <- Process Imports[import tree, params(1)]
1176 :||:
1177 out(0) <- parse tree(0)
1178 :|
1179 :|
1180
1181 _Init Used Store(2,1)
1182 |:
1183 [dict(0)]Index[store name(1)]
1184 |:
1185 out(0) <- dict(0)
1186 :||:
1187 Init Store[store name(1)]
1188 out(0) <- [dict(0)]Set[store name(1), Yes]
1189 :|
1190 :|
1191
1192 _Init Used Stores(2,1)
1193 |:
1194 out(0) <- Fold["_Init Used Store", dict(0), [worker(1)]Uses Stores >>]
1195 :|
1196
1197 Init Used Stores(1,1)
1198 |:
1199 out(0) <- Fold["_Init Used Stores", existing stores(1), [parse tree(0)]Workers >>]
1200 :|
1201
1202 Until End(1,1)
1203 |:
1204 line <- Get Input[]
1205 If[[line] = ["End"]]
1206 |:
1207 out(0) <- [text(0)]Append["\n"]
1208 :||:
1209 out(0) <- Until End[[[text(0)]Append["\n"]]Append[line]]
1210 :|
1211 :|
1212
1213 _REPL(3,0)
1214 |:
1215 line <- Get Input[]
1216 If[[line] = ["Begin"]]
1217 |:
1218 text <- Until End[""]
1219 Null[text, params(0), New@Parse Program[], 0]
1220 |:
1221 define tree <- Process Imports[~, params(0)]
1222 Init Used Stores[define tree, stores(2)]
1223 |: _REPL[params(0), _Tree to Program[define tree, prog(1)], ~] :|
1224 :|
1225 :||:
1226 If[[line]Starts With[[params(0)]Import >>]]
1227 |:
1228 Parse Import[[line]Append["\n"], params(0), New@Parse Program[], 0]
1229 |:
1230 import tree <- Process Imports[~, params(0)]
1231 Init Used Stores[import tree, stores(2)]
1232 |: _REPL[params(0), _Tree to Program[import tree, prog(1)], ~] :|
1233 :|
1234 :||:
1235 trees <- Worker Body[[line]Append["}"], params(0), New@List[]]
1236 tree <- [New@Worker Node["Val", [New@List[]]Append[[trees]Index[0]]]]Assignments <<[{"__out"}]
1237 this stores <- [[tree]Gather Stores[params(0), New@Dictionary[]]]Keys
1238 next stores <- Fold["_Init Used Store", stores(2), this stores]
1239 |:
1240 pworker <- [[New@Parse Worker["__Eval", New@List[], {"__out"}, 0]]Trees <<[[New@List[]]Append[tree]]]Uses Stores <<[this stores]
1241 :|
1242 [[prog(1)]Find Worker["__Eval"]]Clear
1243 |: Add Contents[pworker, "__Eval", prog(1)]
1244 |: Pretty Print[[[[prog(1)]Find Worker["__Eval"]]Do[New@List[]]]Index[0], ""]
1245 |: _REPL[params(0), prog(1), next stores] :| :| :|
1246 :|
1247 :|
1248 :|
1249
1250 REPL(1,0)
1251 |:
1252 Print["Rhope Alpha 2\nCopyright 2008 by Michael Pavone\nEntering interactive mode\n"]
1253 prog <- Tree to Program[Null["Val[in:out]\n{\n out <- in\n}\n__Eval[:__out]\n{\n}\n", params(0), New@Parse Program[], 0]]
1254 _REPL[params(0), prog, New@Dictionary[]]
1255 :|
1256
1257 Add If Store(3,1)
1258 |:
1259 If[[name(1)]Contains[[params(2)]Global Separator >>]]
1260 |:
1261 parts <- [name(1)]Split[[params(2)]Global Separator >>]
1262 out(0) <- [stores(0)]Set[[parts]Index[0], Yes]
1263 :||:
1264 out(0) <- stores(0)
1265 :|
1266 :|
1267
1268 Param Gather Stores(3,1)
1269 |:
1270 out(0) <- [node(1)]Gather Stores[params(2), stores(0)]
1271 :|
1272
1273 Gather Stores@Named Pipe Node(3,1)
1274 |:
1275 out(0) <- Fold[["Add If Store"]Set Input[2, params(1)], stores(2), [node(0)]Assignments >>]
1276 :|
1277
1278 Gather Stores@Global Node(3,1)
1279 |:
1280 out(0) <- [stores(2)]Set[[node(0)]Store >>, Yes]
1281 :|
1282
1283 Gather Stores@Worker Node(3,1)
1284 |:
1285 //TODO: Handle blocks
1286 store list <- Fold[["Param Gather Stores"]Set Input[2, params(1)], stores(2), [node(0)]Params >>]
1287 out(0) <- Fold[["Add If Store"]Set Input[2, params(1)], store list, [node(0)]Assignments >>]
1288 :|
1289
1290 Gather Stores@Field Node(3,1)
1291 |:
1292 //TODO: Handle blocks
1293 store list <- Fold[["Param Gather Stores"]Set Input[2, params(1)], stores(2), [node(0)]Params >>]
1294 out(0) <- Fold[["Add If Store"]Set Input[2, params(1)], store list, [node(0)]Assignments >>]
1295 :|
1296
1297 Gather Stores@Literal Node(3,1)
1298 |:
1299 out(0) <- Fold[["Add If Store"]Set Input[2, params(1)], stores(2), [node(0)]Assignments >>]
1300 :|
1301
1302
1303 Main(1,0)
1304 |:
1305
1306 [args(0)]Index[1]
1307 |:
1308 file <- <String@File[~]
1309 ,text <- [file]Get FString[[file]Length]
1310 params <- New@Parser[]
1311 Null[text, params, New@Parse Program[], 0]
1312 |:
1313 tree <- Process Imports[~, params]
1314 Init Used Stores[tree, New@Dictionary[]]
1315 |: [Tree to Program[tree]]Run[[args(0)]Tail[1]] :|
1316 :|
1317 :||:
1318 REPL[New@Parser[]]
1319 :|
1320 :|