Mercurial > repos > rhope
annotate parser_old_c.rhope @ 138:1411de6050e1
First stab at transaction data structures, needs work
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 16 Nov 2010 21:53:18 -0500 |
parents | fc3815b7462f |
children | a68e6828d896 |
rev | line source |
---|---|
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 Import nworker_c.rhope |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 //Rather than rewrite the code that uses this |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 //let's implement Get DString using Partition |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 Get DString[str,delims:after,before,delim,not found] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 before,delim,after,not found <- [str]Partition[delims] {} {} {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 before <- str |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 Blueprint Parser |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 Arg Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 Arg End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 Line Comment |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 Comment Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 Comment End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 Assign |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 Block Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 Block End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 Blueprint Type Delim |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 Empty Block |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 Binary Operator |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 String Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 String End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 String Escape |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 List Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 List End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 List Delim |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 In Out Delim |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 Index Begin |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 Index End |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 Previous |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 Block Val |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 Set Field |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 Get Field |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 Import |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 Blueprint |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 Global Separator |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 Uses |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 Hex Escape |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 Escape Map |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 Foreign |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 Parser[:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 { |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
115
diff
changeset
|
51 out <- [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Build[Parser()] |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 ]Arg Begin << ["["] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 ]Arg End <<["]"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 ]Line Comment <<["//"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 ]Comment Begin <<["/*"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 ]Comment End <<["*/"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 ]Assign <<["<-"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 ]Block Begin <<["{"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 ]Block End <<["}"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 ]Blueprint Type Delim <<[":"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 ]Empty Block <<[";"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 ]Binary Operator <<["`"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 ]String Begin <<["\""] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 ]String End <<["\""] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 ]String Escape <<["\\"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 ]List Begin <<["("] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 ]List End <<[")"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 ]List Delim <<[","] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 ]In Out Delim <<[":"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 ]Index Begin <<["("] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 ]Index End <<[")"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 ]Previous <<["@"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 ]Set Field <<["<<"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 ]Get Field <<[">>"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 ]Import <<["Import"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 ]Blueprint <<["Blueprint"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 ]Global Separator <<["::"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 ]Hex Escape <<["x"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 ]Uses <<["uses"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 ]Escape Map <<[[[[Dictionary[]]Set["n","\n"]]Set["r","\r"]]Set["t","\t"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 ]Foreign <<["Foreign"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 Blueprint Output Reference |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 Output Number |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 Output Reference[index,num:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 out <- [[Build[Output Reference()]]Index <<[index]]Output Number <<[num] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 Add Pipe Reference[refs,name,reference:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 reflist <- [refs]Index[name] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 reflist <- () |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 out <- [refs]Set[name, [reflist]Append[reference]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 Assignment Save Reference[refs,assignment,output num,parse worker,index:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 [[parse worker]Outputs >>]Find[=[assignment,?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 out <- refs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 out <- Add Pipe Reference[refs, assignment, Output Reference[index, output num]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 Blueprint Foreign Lib |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 Language |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 New Foreign Lib[language, library:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 out <- [[Build[Foreign Lib()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 ]Language <<[language] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 ]Name <<[library] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 Blueprint Parse Program |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 Workers |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 Imports |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 Blueprints |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 Errors |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 Parse Program[:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 out <- [[[[Build[Parse Program()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 ]Workers <<[Dictionary[]] |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
115
diff
changeset
|
139 ]Imports <<[Dictionary[]] |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 ]Blueprints <<[Dictionary[]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 ]Errors <<[()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 Blueprint Blueprint Definition |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 Fields |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 New Blueprint Definition[name,fields:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 out <- [[Build[Blueprint Definition()]]Name << [name]]Fields <<[fields] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 Blueprint Parse Worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 Inputs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 Outputs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 Line Number |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 Trees |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 Uses Stores |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 Input Types |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 Output Types |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 Parse Worker[name,inputs,outputs,intypes,outtypes,line:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 out <- [[[[[[[[Build[Parse Worker()]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[()]]Uses Stores <<[()]]Input Types <<[intypes]]Output Types <<[outtypes] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 Blueprint Worker Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 Params |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 Assignments |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 Blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 Worker Node[name,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 out <- [[[[Build[Worker Node()]]Name <<[name]]Params <<[params]]Assignments <<[()]]Blocks <<[()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 Add List Helper[inlist,worker,program,key,parse worker,refs:out list,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 ,nextworker,nextrefs <- [[inlist]Index[key]]Add to Worker[worker, program, parse worker, refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 { nextlist <- [inlist]Set[key, ~] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 [inlist]Next[key] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 out list,out worker,out refs <- Add List Helper[nextlist, nextworker, program, ~, parse worker, nextrefs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 out list <- Val[nextlist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 out worker <- Val[nextworker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 out refs <- Val[nextrefs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 Add List to Worker[list,worker,program,parse worker,refs:out list,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 [list]First |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 out list,out worker,out refs <- Add List Helper[list, worker, program, ~, parse worker, refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 out list <- list |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 out worker <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 out refs <- refs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 _Add Blocks to Worker[blocks,worker,program,parse worker,key,refs:out blocks,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 block, next worker, nextrefs <- Add List to Worker[[blocks]Index[key], worker, program, parse worker, refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 next blocks <- [blocks]Set[key, block] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 [blocks]Next[key] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 out blocks,out worker,out refs <- _Add Blocks to Worker[next blocks, next worker, program, parse worker, ~, nextrefs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 out blocks <- Val[next blocks] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 out worker <- Val[next worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 out refs <- Val[nextrefs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 Add Blocks to Worker[blocks,worker,program,parse worker,refs:out blocks,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 [blocks]First |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 out blocks, out worker, out refs <- _Add Blocks to Worker[blocks, worker, program, parse worker, ~, refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 out blocks <- blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 out worker <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 out refs <- refs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 Add to Worker@Worker Node[node,worker,program,parse worker,refs:out node,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 [program]Find Worker[[node]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 after worker <- [worker]Add Worker Call[~] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 //Print[[[[node]Name >>]Append[" has index "]]Append[~]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 assignment refs <- Fold[Assignment Save Reference[?, ?, ?, parse worker, ~], refs, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 [node]Index <<[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 params list, params worker, params refs <- Add List to Worker[[~]Params >>, after worker, program, parse worker, assignment refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 block list, out worker, out refs <- Add Blocks to Worker[[~]Blocks >>, params worker, program, parse worker, params refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 out node <- [[~]Params <<[params list]]Blocks <<[block list] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 Print[["Error: Could not find a worker named "]Append[[node]Name >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 Check Question Mark[params, index:has mark,no mark] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 param,no mark <-[params]Index[index] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 If[[Blueprint Of[param]]=[Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 has mark <-If[[[param]Name >>] = ["?"]] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 has mark,no mark <- Check Question Mark[params, [index]+[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 has mark,no mark <- Check Question Mark[params, [index]+[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 Collect Literal Inputs[literal, params, index, complex inputs:literal out,complex out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 param <- [params]Index[index] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 If[[Blueprint Of[param]]=[Literal Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 next literal <- [literal]Set Input[index, [param]Value >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 next complex <- Val[complex inputs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 ,doset <- If[[Blueprint Of[param]]=[Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 ,doset <- If[[[param]Name >>] = ["?"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 //Question mark indicates unpopulated input |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 next complex <- Val[complex inputs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 next literal <- Val[literal] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 Val[doset] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 next complex <- [complex inputs]Set[index, param] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 next literal <- Val[literal] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 literal out, complex out <- Collect Literal Inputs[next literal, params, [index]+[1], next complex] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 literal out <- literal |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 complex out <- complex inputs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 Do Set Input[literal,param,index:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 out <- Worker Node["Set Input", [[[()]Append[literal]]Append[Literal Node[index]]]Append[param]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 Check Worker Literals@Worker Node[node,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 new params <- Map[[node]Params >>, Check Worker Literals[?, program]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 Check Question Mark[new params, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 base literal, complex inputs <- Collect Literal Inputs[Worker Literal[[node]Name >>], new params, 0, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 new node <- Fold[Do Set Input[?], Literal Node[base literal], complex inputs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 new node <- [node]Params <<[new params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 out <- [new node]Blocks <<[ Map[[node]Blocks >>, Map[?, Check Worker Literals[?, program]]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 Add Multi Wire[worker,ref,junk,end index,input num:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
326 out <- [worker]Add Wire[[ref]Index >>, [ref]Output Number >>, end index, input num] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
327 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 Add Param Wire[worker,param,input num,end index,blocks,parse worker,assignments:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 param worker, start index, output num <- [param]Add Wires[worker, blocks, parse worker, assignments] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 out <- [param worker]Add Wire[start index, output num, end index, input num] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 }{}{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 out <- Fold[Add Multi Wire[?, ?, ?, end index, input num], param worker, ~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 _Add Block Wire[worker,node,junk,blocks,parse worker,assignments:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 out <- [node]Add Wires[worker, blocks, parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 Add Block Wire[worker,block nodes,output num,parent index,existing blocks,parse worker,assignments:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 blocks <- [existing blocks]Append[Output Reference[parent index, output num]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 out <- Fold[_Add Block Wire[?, ?, ?, blocks, parse worker, assignments], worker, block nodes] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 Assignments Add Wires[worker,assignment,output num,parse worker,start index:out worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 [[parse worker]Outputs >>]Find[=[assignment,?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 ,output index <- [worker]Add Typed Output[assignment, ~, [[parse worker]Output Types >>]Index[~]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 out worker <- [~]Add Wire[start index, output num, output index, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 //Ugly hack alert! |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 If[[assignment]Contains["::"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 parts <- [assignment]Split["::"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 ,global index <- [worker]Add Global Set[[parts]Index[0], [parts]Index[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 out worker <- [~]Add Wire[start index, output num, global index, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
367 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 out worker <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
371 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
372 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 Has Block@Worker Node[junk:out,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 out <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
377 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 _Has Block Params[param list,key:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
380 param <- [param list]Index[key] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 out <- [param]Has Block {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
382 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
383 [param list]Next[key] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 out <- _Has Block Params[param list, ~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 out <- No |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 Has Block Params[param list:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 [param list]First |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
397 out <- _Has Block Params[param list, ~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 out <- No |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
400 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
401 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
402 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 Add Wires@Worker Node[node,worker,blocks,parse worker,assignments:outworker,index,num,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 outworker,index,num <- Add Wires Worker or Field[node, worker, blocks, parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
406 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
408 Add Wires Worker or Field[node,worker,blocks,parse worker,assignments:outworker,index,num,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
410 Fold[Assignments Add Wires[?, ?, ?, parse worker, [node]Index >>], worker, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
411 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 Fold[Add Block Wire[?, ?, ?, [node]Index >>, blocks, parse worker, assignments], ~, [node]Blocks >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 params worker <- Fold[Add Param Wire[?, ?, ?, [node]Index >>, blocks, parse worker, assignments], ~, [node]Params >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 index <- [node]Index >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
417 num <- 0 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
419 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 If[Has Block Params[[node]Params >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
422 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 outworker <- Val[params worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
425 [blocks]Peek |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
426 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 outworker <- [params worker]Add Wire[[~]Index >>, [~]Output Number >>, [node]Index >>, [0]-[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
428 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
429 outworker <- Val[params worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
431 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 Blueprint Field Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 Params |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 Assignments |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 Blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 Set? |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
442 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
443 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
444 Has Block@Field Node[junk:has block,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
445 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
446 has block <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
447 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
448 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
449 Field Node[name,params,set:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
450 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
451 out <- [[[[[Build[Field Node()]]Name <<[name]]Assignments <<[()]]Blocks <<[()]]Set? <<[set]]Params <<[params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
452 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
453 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
454 Add to Worker@Field Node[node,worker,program,parse worker,refs:out node,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 If[[node]Set? >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 after worker,index <- [worker]Add Object Set[[node]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 after worker,index <- [worker]Add Object Get[[node]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 Val[index] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 assignment refs <- Fold[Assignment Save Reference[?, ?, ?, parse worker, ~], refs, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 [node]Index <<[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
467 params list, params worker, params refs <- Add List to Worker[[~]Params >>, after worker, program, parse worker, assignment refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 block list, out worker, out refs <- Add Blocks to Worker[[~]Blocks >>, params worker, program, parse worker, params refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
469 out node <- [[~]Params <<[params list]]Blocks <<[block list] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
470 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 Add Wires@Field Node[node,worker,blocks,parse worker,assignments:outworker,index,num] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
476 outworker,index,num <- Add Wires Worker or Field[node, worker, blocks, parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 Check Worker Literals@Field Node[node,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 new params <- Map[[node]Params >>, Check Worker Literals[?, program]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 out <- [[node]Blocks <<[ Map[[node]Blocks >>, Map[?, Check Worker Literals[?, program]]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 ]Params <<[new params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
484 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
486 Blueprint Named Pipe Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
488 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
489 Assignments |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
490 Blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
491 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
492 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
493 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
494 Has Block@Named Pipe Node[node:has block,no block] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 If[[[node]Index >>] < [0]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 //~ should really be a parser parameter |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 If[[[node]Name >>] = ["~"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
501 has block <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
503 no block <- No |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
504 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
506 has block <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
507 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
509 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 Named Pipe Node[name:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
511 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
512 out <- [[[Build[Named Pipe Node()]]Name <<[name]]Assignments <<[()]]Blocks <<[()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
513 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
514 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
515 Add to Worker@Named Pipe Node[node,worker,program,parse worker,refs:out node,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
516 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
517 [[parse worker]Inputs >>]Find[=[[node]Name >>, ?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
518 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
519 after add <- [worker]Add Typed Input[[node]Name >>, ~, [[parse worker]Input Types>>]Index[~]] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
520 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 assign refs <- Fold[Assignment Save Reference[?, ?, ?, parse worker, ~], refs, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 index node <- [node]Index <<[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
523 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
524 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
525 after add <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
526 index node <- [node]Index <<[[0]-[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
527 //TODO: Handle assignments from a named pipe that isn't an input |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 assign refs <- refs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
530 block list, out worker, out refs <- Add Blocks to Worker[[node]Blocks >>, after add, program, parse worker, assign refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
531 out node <- [index node]Blocks <<[block list] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
532 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
533 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
534 Add Wires@Named Pipe Node[node,worker,blocks,parse worker,assignments:outworker,index,num,reflist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
535 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
536 reflist <- [assignments]Index[[node]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
537 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
538 //TODO: Fix support for a named pipe with a block |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
539 outworker <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
540 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
541 If[[[node]Name >>] = ["~"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
542 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
543 wires worker <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
544 [blocks]Peek |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
545 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
546 my index <- [~]Index >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
547 num <- [~]Output Number >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
548 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
549 //TODO: Propagate an error rather than printing it out |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
550 Print["Error, block reference symbol located outside of a block"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
551 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
552 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
553 If[[[node]Index >>] < [0]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
554 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
555 Print[[[["Error, reference to named pipe "]Append[[node]Name >>]]Append[" that was never assigned to in worker "]]Append[[parse worker]Name >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
556 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
557 my index <- [node]Index >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
558 num <- 0 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
559 assignments worker <- Fold[Assignments Add Wires[?, ?, ?, parse worker, [node]Index >>], worker, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
560 [blocks]Peek |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
561 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
562 wires worker <- [assignments worker]Add Wire[[~]Index >>, [~]Output Number >>, [node]Index >>, [0]-[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
563 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
564 wires worker <- Val[assignments worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
565 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
566 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
567 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
568 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
569 index <- Val[my index] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
570 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
571 outworker <- Fold[Add Block Wire[?, ?, ?, my index, blocks, parse worker, assignments], wires worker, [node]Blocks >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
572 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
573 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
574 Check Worker Literals@Named Pipe Node[node,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
575 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
576 out <- [node]Blocks <<[ Map[[node]Blocks >>, Map[?, Check Worker Literals[?, program]]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
577 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
578 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
579 Blueprint Global Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
580 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
581 Store |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
582 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
583 Assignments |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
584 Blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
585 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
586 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
587 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
588 Global Node[store,name:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
589 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
590 out <- [[[[Build[Global Node()]]Store <<[store]]Name <<[name]]Assignments <<[()]]Blocks <<[()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
591 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
592 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
593 Add to Worker@Global Node[node,worker,unused,parse worker,refs:out node,out worker,outrefs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
594 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
595 out worker <- [worker]Add Global Get[[node]Store >>, [node]Name >>] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
596 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
597 outrefs <- Fold[Assignment Save Reference[?, ?, ?, parse worker, ~], refs, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 out node <- [node]Index <<[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
599 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
600 outrefs <- refs |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
601 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
602 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
603 Add Wires@Global Node[node,worker,blocks,parse worker,assignments:outworker,index,num,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
605 outworker,index,num <- Add Wires Literal or Global[node, worker, blocks, parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
606 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
607 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
608 Has Block@Global Node[junk:out,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
609 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
610 out <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
611 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
612 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
613 Check Worker Literals@Global Node[node,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
614 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
615 out <- [node]Blocks <<[ Map[[node]Blocks >>, Map[?, Check Worker Literals[?, program]]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
616 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
617 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
618 Blueprint Literal Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
619 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
620 Value |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
621 Assignments |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
622 Blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
623 Index |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
624 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
625 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
626 Has Block@Literal Node[junk:out,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
627 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
628 out <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
629 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
630 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
631 Literal Node[value:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
632 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
633 out <- [[[Build[Literal Node()]]Value <<[value]]Assignments <<[()]]Blocks <<[()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
634 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
635 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
636 Add to Worker@Literal Node[node,worker,unused,parse worker,refs:out node,out worker,out refs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
637 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
638 out worker <- [worker]Add Constant[[node]Value >>] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
639 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
640 out refs <- Fold[Assignment Save Reference[?, ?, ?, parse worker, ~], refs, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
641 out node <- [node]Index <<[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
642 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
643 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
644 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
645 Add Wires@Literal Node[node,worker,blocks,parse worker,assignments:outworker,index,num,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
646 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
647 outworker,index,num <- Add Wires Literal or Global[node, worker, blocks, parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
648 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
649 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
650 Check Worker Literals@Literal Node[node,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
651 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
652 out <- [node]Blocks <<[ Map[[node]Blocks >>, Map[?, Check Worker Literals[?, program]]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
653 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
654 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
655 Add Wires Literal or Global[node,worker,blocks,parse worker,junk:outworker,index,num,unused] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
656 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
657 assignments worker <- Fold[Assignments Add Wires[?, ?, ?, parse worker, [node]Index >>], worker, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
658 [blocks]Peek |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
659 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
660 outworker <- [assignments worker]Add Wire[[~]Index >>, [~]Output Number>>, [node]Index >>, [0]-[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
661 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
662 outworker <- Val[assignments worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
663 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
664 index <- [node]Index >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
665 num <- 0 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
666 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
667 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
668 Blueprint Block Node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
669 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
670 Number |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
671 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
672 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
673 Blueprint Parse Error |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
674 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
675 Type |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
676 Text |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
677 Line Number |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
678 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
679 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
680 Parse Error[type,text,number:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
681 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
682 out <- [[[Build[Parse Error()]]Type <<[type]]Text <<[text]]Line Number <<[number] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
683 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
684 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
685 Not Empty[string:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
686 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
687 If[[[string]Length] > [0]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
688 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
689 out <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
690 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
691 out <- No |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
692 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
693 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
694 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
695 Blueprint Blueprint Field |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
696 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
697 Name |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
698 Type |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
699 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
700 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
701 New Blueprint Field[name,type:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
702 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
703 out <- [[Build[Blueprint Field()]]Name <<[name]]Type <<[type] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
704 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
705 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
706 Process Blueprint Field[list,field,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
707 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
708 ,name <- [field]Get DString[[params]List Begin >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
709 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
710 type info <- Parse List[~,params,()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
711 type <- [type info]Index[0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
712 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
713 If[[Blueprint Of[~]] = [Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
714 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
715 before variant <- Type Instance[[type]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
716 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 before variant <- [type]Params <<[ Map[[type]Params >>, Remove Named Pipe Node[?]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
718 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
719 variant <- [type info]Index[1] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
720 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
721 ,warn <- If[[Blueprint Of[~]] = [Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
722 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
723 fieldtype,warn <- [before variant]Set Variant[[variant]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
724 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
725 Val[warn] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
726 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
727 Print[[[["Warning: Invalid variant for type "]Append[[before variant]Name >>]]Append[" on field "]]Append[name]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
728 fieldtype <- Val[before variant] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
729 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
730 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
731 fieldtype <- Val[before variant] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
733 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
734 fieldtype <- Type Instance["Any Type"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
735 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
736 out <- [list]Append[New Blueprint Field[name, fieldtype]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
737 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
738 out <- [list]Append[New Blueprint Field[name, Type Instance["Any Type"]]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
740 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
741 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
742 Block Comment[string,begin comment,end comment,block count:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
743 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
744 If[[block count] > [0]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
745 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
746 after, before <- [string]Get DString[[[()]Append[begin comment]]Append[end comment]] {} {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
747 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
748 If[[~] = [begin comment]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
749 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
750 out <- Block Comment[after, begin comment, end comment, [block count]+[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
751 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
752 out <- Block Comment[after, begin comment, end comment, [block count]-[1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
753 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
754 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
755 //No match |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
756 out <- "" |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
757 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
758 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
759 out <- string |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
760 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
761 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
762 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
763 Line Comment[string:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
764 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
765 [string]Get DString["\n"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
766 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
767 out <- ["\n"]Append[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
768 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
769 out <- "" |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
770 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
771 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
772 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
773 _Get Comment DString[string,delims,line comment,begin comment,end comment,prev before:rest,before,delim,nomatch] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
774 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
775 after,befored,used delim,nomatch <- [string]Get DString[delims] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
776 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
777 If[[used delim] = [line comment]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
778 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
779 after comment <- Line Comment[after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
781 If[[used delim] = [begin comment]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
782 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
783 after comment <- Block Comment[after, begin comment, end comment, 1] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
784 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
785 rest <- Val[after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
786 before <- [prev before]Append[befored] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
787 delim <- Val[used delim] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
789 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
790 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
791 before <- [prev before]Append[befored] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
792 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
793 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
794 after comment |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
795 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
796 rest,more before,delim,nomatch <- _Get Comment DString[~, delims, line comment, begin comment, end comment, prev before] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
797 before <- [before]Append[more before] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
798 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
799 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
800 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
801 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
802 As List[val:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
803 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
804 [(List(),List Leaf())]Find[=[Blueprint Of[val], ?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
805 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
806 out <- val |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
807 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
808 out <- [()]Append[val] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
809 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
810 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
811 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
812 Get Comment DString[string,delims,params:rest,before,delim,not found] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
813 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
814 line comment <- [params]Line Comment >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
815 begin comment <- [params]Comment Begin >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
816 end comment <- [params]Comment End >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
817 all delims <- [[[delims]As List]Append[begin comment]]Append[line comment] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
818 rest, before, delim, not found <- _Get Comment DString[string, delims, line comment, begin comment, end comment, ""] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
819 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
820 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
821 Comment Left Trim[string,trim chars,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
822 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
823 line comment <- [params]Line Comment >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
824 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
825 end comment <- [params]Comment End >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
826 trimmed <- Left Trim[string, trim chars] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
827 If[[trimmed]Starts With[line comment]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
828 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
829 ,after delim <- [trimmed]Slice[[line comment]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
830 out <- Comment Left Trim[Line Comment[after delim], trim chars, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
831 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
832 begin comment <- [params]Comment Begin >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
833 If[[trimmed]Starts With[begin comment]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
834 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
835 ,after delim <- [trimmed]Slice[[line comment]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
836 out <- Comment Left Trim[Block Comment[after delim, begin comment, end comment, 1], trim chars, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
837 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
838 out <- Val[trimmed] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
839 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
840 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
841 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
842 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
843 PBlueprint[string,params,tree,lines:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
844 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
845 ,whitespace name <- [string]Get Comment DString[[params]Block Begin >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
846 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
847 ,no blueprint <- [whitespace name]Slice[ [[params]Blueprint >>]Length ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
848 name <- Trim[no blueprint, "\r\n\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
849 name lines <- 0 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
850 ,body <- [~]Get Comment DString[ [params]Block End >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
851 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
852 body lines <- [body]Split["\n"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
853 more lines <- [[[body lines]Length] - [1]] + [name lines] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
854 fields <- Fold[Process Blueprint Field[?, ?, params], (), Filter[Map[body lines, Trim[?,"\n\r\t "]], Not Empty[?]]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
855 new tree <- [tree]Blueprints << [ [[tree]Blueprints >>]Set[name, New Blueprint Definition[name, fields]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
856 out <- Null[~, params, new tree, [lines] + [more lines]] |
101
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
857 } {} {} { |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
858 out <- [tree]Errors <<[ [[tree]Errors >>]Append[Parse Error["Error",[["Blueprint is missing an block close symbol \""]Append[[params]Block End >>]]Append["\""], lines]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
859 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
860 |
101
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
861 } {} {} { |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
862 out <- [tree]Errors <<[ [[tree]Errors >>]Append[Parse Error["Error",[["Blueprint is missing an block open symbol \""]Append[[params]Block Begin >>]]Append["\""], lines]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
863 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
864 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
865 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
866 Parse Import[string,params,tree,lines:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
867 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
868 [line]Slice[ [[params]Import >>]Length ] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
869 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
870 filename <- Trim[~, " \n\r\t"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
871 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
872 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
873 new tree <- [tree]Imports <<[[[tree]Imports >>]Set[filename, Yes]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
874 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
875 ,line <- [string]Get Comment DString["\n", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
876 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
877 out <- Null[~, params, new tree, [lines] + [1]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
878 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
879 out <- Val[new tree] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
880 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
881 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
882 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
883 Get Expression Blocks[string,params,blocks:outblocks,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
884 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
885 check block <- Comment Left Trim[string, "\n\r\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
886 If[[check block]Starts With[[params]Block Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
887 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
888 ,begin block <- [check block]Slice[[[params]Block Begin >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
889 trees, after block <- Worker Body[begin block, params, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
890 outblocks, after <- Get Expression Blocks[after block, params, [blocks]Append[trees]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
891 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
892 If[[check block]Starts With[[params]Empty Block >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
893 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
894 outblocks <- blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
895 ,after <- [check block]Slice[[[params]Empty Block >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
896 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
897 outblocks <- blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
898 after <- Val[check block] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
899 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
900 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
901 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
902 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
903 Parse Escape[string,params:char,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
904 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
905 code,rest <- [string]Slice[1] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
906 If[[code] = [[params]Hex Escape >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
907 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
908 hex,after <- [rest]Slice[2] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
909 char <- String[[Array[]]Append[Trunc UInt8[Abs UInt[Hex Int32[hex]]]]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
910 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
911 after <- Val[rest] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
912 char <- [[params]Escape Map >>]Index[code] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
913 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
914 char <- Val[code] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
915 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
916 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
917 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
918 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
919 Parse String[string,params,current:value,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
920 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
921 delims <- [[()]Append[[params]String End >>]]Append[[params]String Escape >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
922 afters, before, delim <- [string]Get Comment DString[delims, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
923 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
924 If[[delim] = [[params]String End >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
925 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
926 value <- [current]Append[before] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
927 after <- Val[afters] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
928 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
929 char,after escape <- Parse Escape[afters, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
930 value,after <- Parse String[after escape, params, [[current]Append[before]]Append[char]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
931 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
932 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
933 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
934 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
935 Parse List[string,params,list:value,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
936 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
937 trimmed <- Comment Left Trim[string, "\r\n\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
938 If[[trimmed]Starts With[[params]List End >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
939 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
940 value <- list |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
941 ,after <- [trimmed]Slice[[[params]List End >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
942 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
943 If[[trimmed]Starts With[[params]List Delim >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
944 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
945 ,el string <- [trimmed]Slice[[[params]List Delim >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
946 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
947 el string <- Val[trimmed] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
948 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
949 element,after el <- Named Pipe or Literal[el string, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
950 value,after <- Parse List[after el, params, [list]Append[[element]Get Value]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
951 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
952 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
953 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
954 Get Value@Literal Node[node:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
955 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
956 out <- [node]Value >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
957 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
958 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
959 Get Value@Named Pipe Node[node:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
960 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
961 out <- node |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
962 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
963 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
964 Machine Integer[val, size, signed?:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
965 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
966 conv <- [[[[[[[[() |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
967 ]Append[UInt8[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
968 ]Append[Int8[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
969 ]Append[UInt16[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
970 ]Append[Int16[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
971 ]Append[UInt32[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
972 ]Append[Int32[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
973 ]Append[UInt64[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
974 ]Append[Int64[?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
975 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
976 base idx <- [[(8,16,32,64)]Find[=[size,?]]]*[2] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
977 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
978 If[signed?] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
979 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
980 idx <- [base idx]+[1] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
981 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
982 idx <- Val[base idx] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
983 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
984 out <- [[conv]Index[idx]]Call[val] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
985 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
986 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
987 Parse Number[string,params:value,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
988 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
989 delims <- [[[[(" ","\t","\n","\r")]Append[[params]List Delim >>]]Append[[params]Block Begin >>]]Append[[params]Arg End >>]]Append[[params]List End >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
990 after delim,valstring <- [string]Get Comment DString[delims, params] {} {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
991 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
992 after <- [~]Append[after delim] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
993 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
994 after <- "" |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
995 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
996 first two,rest <- [valstring]Slice[2] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
997 If[[first two] = ["0x"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
998 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
999 value <- Hex Int32[rest] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1000 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1001 If[[valstring]Contains["."]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1002 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1003 value <- Real64[valstring] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1004 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1005 size, val, type <- [valstring]Get DString[("i","u")] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1006 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1007 value <- Machine Integer[val, Int32[size], [type]=["i"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1008 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1009 value <- Int32[valstring] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1010 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1011 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1012 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1013 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1014 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1015 Parse Params@Type Instance[literal,params,string:out,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1016 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1017 plist,after <- Parse List[string,params,()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1018 out <- [literal]Params <<[plist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1019 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1020 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1021 Named Pipe or Literal[string,params:out,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1022 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1023 name <- Comment Left Trim[string, "\n\r\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1024 If[[name]Starts With[[params]String Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1025 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1026 ,string begin <- [name]Slice[[[params]String Begin >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1027 value,after <- Parse String[string begin, params, ""] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1028 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1029 If[[name]Starts With[[params]List Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1030 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1031 ,list start <- [name]Slice[[[params]List Begin >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1032 value,after <- Parse List[list start, params, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1033 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1034 If[[[name]Slice[1]]In["-0123456789"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1035 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1036 value,after <- Parse Number[name, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1037 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1038 delims <- [[[[[[[("\n")]Append[[params]Block Begin >>]]Append[[params]Block End >>]]Append[[params]Empty Block >>]]Append[[params]Arg End >>]]Append[[params]List Delim >>]]Append[[params]List End >>]]Append[[params]List Begin >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1039 afterdelim,raw before,delim,nodelim <- [name]Get Comment DString[delims, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1040 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1041 before <- Trim[raw before, "\r\n\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1042 If[[delim] = [[params]List Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1043 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1044 value,after <- [Type Instance[before]]Parse Params[params,afterdelim] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1045 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1046 Val[afterdelim] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1047 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1048 after <- [delim]Append[~] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1049 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1050 Val[nodelim] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1051 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1052 after <- "" |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1053 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1054 If[[before] = ["Yes"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1055 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1056 yesno <- Yes |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1057 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1058 If[[before] = ["No"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1059 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1060 yesno <- No |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1061 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1062 If[[before] = [""]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1063 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1064 Print[[["Found "]Append[delim]]Append[" where a named pipe or literal was expected"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1065 { Print[["Near: "]Append[ [afterdelim]Slice[80]]] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1066 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1067 If[[before]Contains[[params]Global Separator >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1068 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1069 parts <- [before]Split[[params]Global Separator >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1070 out <- Global Node[Right Trim[[parts]Index[0],"\r\n\t "], Trim[[parts]Index[1], "\r\n\t "]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1071 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1072 out <- Named Pipe Node[Right Trim[before,"\r\n\t "]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1073 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1074 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1075 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1076 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1077 out <- Literal Node[yesno] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1078 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1079 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1080 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1081 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1082 out <- Literal Node[value] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1083 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1084 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1085 Parse Arguments[string,params,arglist:args,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1086 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1087 targs <- Comment Left Trim[string, "\r\n\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1088 If[[targs]Starts With[[params]List Delim >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1089 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1090 [targs]Slice[[[params]List Delim >>]Length] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1091 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1092 final args <- Comment Left Trim[~, "\r\n\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1093 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1094 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1095 If[[targs]Starts With[[params]Arg End >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1096 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1097 args <- arglist |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1098 ,after <- [targs]Slice[[[params]Arg End >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1099 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1100 final args <- Val[targs] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1101 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1102 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1103 arg, after arg <- Parse Expression[final args, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1104 args, after <- Parse Arguments[after arg, params, [arglist]Append[arg]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1105 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1106 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1107 Worker or Field[name,args,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1108 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1109 get field <- [params]Get Field >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1110 If[[name]Ends With[get field]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1111 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1112 field <- Right Trim[[name]Slice[[[name]Length] - [[get field]Length]], "\n\r\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1113 out <- Field Node[field, args, No] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1114 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1115 set field <- [params]Set Field >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1116 If[[name]Ends With[set field]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1117 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1118 field <- Right Trim[[name]Slice[[[name]Length] - [[set field]Length]], "\n\r\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1119 out <- Field Node[field, args, Yes] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1120 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1121 out <- Worker Node[name, args] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1122 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1123 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1124 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1125 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1126 Prefix[string,params,name,existing args:expression,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1127 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1128 //Parse argument list |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1129 more args,after <- Parse Arguments[string, params, existing args] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1130 expression <- Worker or Field[name, more args, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1131 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1132 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1133 Postfix or Infix[string,params:expression,after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1134 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1135 args, after args <- Parse Arguments[string, params, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1136 delims <- [[[[[("\n")]Append[[params]Arg Begin >>]]Append[[params]Empty Block >>]]Append[[params]Block Begin >>]]Append[[params]Arg End >>]]Append[[params]List Delim >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1137 aftere,before,delim <- [after args]Get Comment DString[delims, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1138 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1139 If[[delim] = [[params]Arg Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1140 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1141 expression, after <- Prefix[aftere, params, Trim[before,"\r\n\t "], args] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1142 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1143 If[[delim] = [[params]Empty Block >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1144 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1145 after <- Val[aftere] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1146 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1147 ,after <- [after args]Slice[[before]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1148 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1149 expression <- Worker or Field[Trim[before,"\r\n\t "], args, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1150 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1151 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1152 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1153 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1154 Parse Expression[trimmed,params:final expression,after blocks] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1155 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1156 delims <- [[[[[[[("\n")]Append[[params]Arg Begin >>]]Append[[params]Arg End >>]]Append[[params]Assign >>]]Append["\n"]]Append[[params]Empty Block >>]]Append[[params]Block End >>]]Append[[params]String Begin >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1157 after, before, delim <- [trimmed]Get Comment DString[delims, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1158 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1159 //If we find an arg begin token, we have a worker expression |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1160 If[[delim] = [[params]Arg Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1161 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1162 maybe name <- Right Trim[before, "\r\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1163 //Prefix expressions will have the worker name before the first arg begin token |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1164 If[[maybe name] = [""]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1165 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1166 expression, after expression <- Postfix or Infix[after, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1167 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1168 If[[maybe name]Contains[[params]List Delim >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1169 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1170 after expression <- [after literal]Append[[delim]Append[after]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1171 expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1172 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1173 expression, after expression <- Prefix[after, params, maybe name, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1174 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1175 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1176 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1177 If[[delim] = [[params]Assign >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1178 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1179 //Expressions starting with an assignment can be prefix, postfix or infix |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1180 //or they can be a simple literal or named pipe |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1181 assignments <- Map[[before]Split[[params]List Delim >>], Trim[?,"\n\r\t "]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1182 ,after blocks <- Parse Expression[Comment Left Trim[after, " \n\r\t", params], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1183 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1184 final expression <- [~]Assignments <<[assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1185 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1186 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1187 //If[[delim] = [[params]String Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1188 //{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1189 // If[[Trim[before, "\r\n\t "]] = [""]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1190 // { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1191 // expression, after expression <- Named Pipe or Literal[[delim]Append[after], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1192 // }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1193 // after expression <- [after literal]Append[[delim]Append[after]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1194 // expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1195 // } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1196 //}{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1197 // after expression <- [after literal]Append[[delim]Append[after]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1198 // expression, after literal <- Named Pipe or Literal[Right Trim[before, "\r\n\t "], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1199 //} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1200 expression, after expression <- Named Pipe or Literal[trimmed, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1201 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1202 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1203 //Any expression can be followed by one or more blocks mapping the inputs of other expressions |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1204 //to the outputs of the current one |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1205 blocks,after blocks <- Get Expression Blocks[after expression, params, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1206 final expression <- [expression]Blocks <<[blocks] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1207 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1208 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1209 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1210 Worker Body[string,params,trees:outtrees,after end] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1211 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1212 trimmed <- Comment Left Trim[string, "\n\r\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1213 If[[trimmed]Starts With[[params]Block End >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1214 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1215 //We're done with this block, return |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1216 ,after end <- [trimmed]Slice[[[params]Block End >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1217 outtrees <- trees |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1218 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1219 expression, after expression <- Parse Expression[trimmed, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1220 outtrees,after end <- Worker Body[after expression, params, [trees]Append[expression]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1221 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1222 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1223 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1224 Process Modifiers[worker,params,modifiers:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1225 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1226 //Eventually this will need to be more sophisticated to handle more modifiers |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1227 trimmed <- Comment Left Trim[modifiers, "\n\r\t ", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1228 If[[trimmed]Starts With[[params]Uses >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1229 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1230 ,after uses <- [trimmed]Slice[[[params]Uses >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1231 ,stores string <- [after uses]Get Comment DString["\n", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1232 out <- [worker]Uses Stores <<[Map[[stores string]Split[[params]List Delim >>], Trim[?, "\r\n\t "]]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1233 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1234 out <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1235 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1236 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1237 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1238 Remove Named Pipe Node[element:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1239 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1240 If[[Blueprint Of[element]] = [Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1241 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1242 out <- [element]Name >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1243 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1244 If[[Blueprint Of[element]] = [Type Instance()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1245 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1246 out <- [element]Params <<[ Map[[element]Params >>, Remove Named Pipe Node[?]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1247 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1248 out <- element |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1249 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1250 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1251 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1252 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1253 Parse Param List[text,paramlist,typelist,params:out params,out types] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1254 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1255 delims <- [[()]Append[[params]List Begin >>]]Append[[params]List Delim >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1256 after,param name <-[text]Get DString[delims] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1257 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1258 tname <- Trim[~, "\r\n\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1259 If[[tname] = [""]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1260 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1261 nextlist <- Val[paramlist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1262 next types <- Val[typelist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1263 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1264 nextlist <- [paramlist]Append[tname] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1265 next types <- [typelist]Append[paramtype] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1266 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1267 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1268 If[[~] = [[params]List Begin >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1269 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1270 type info,after type <- Parse List[after,params,()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1271 type <- [type info]Index[0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1272 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1273 If[[Blueprint Of[~]] = [Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1274 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1275 before variant <- Type Instance[[type]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1276 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1277 before variant <- <- [type]Params <<[ Map[[type]Params >>, Remove Named Pipe Node[?]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1278 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1279 variant <- [type info]Index[1] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1280 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1281 ,warn <- If[[Blueprint Of[~]] = [Named Pipe Node()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1282 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1283 before mutable,warn <- [before variant]Set Variant[[variant]Name >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1284 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1285 Val[warn] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1286 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1287 Print[[[["Warning: Invalid variant for type "]Append[[before variant]Name >>]]Append[" on input "]]Append[param name]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1288 before mutable <- Val[before variant] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1289 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1290 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1291 before mutable <- Val[before variant] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1292 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1293 [type info]Index[2] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1294 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1295 paramtype <- [before mutable]Mutable? <<[ [[~]Name >>] = ["Mutable"] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1296 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1297 paramtype <- Val[before mutable] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1298 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1299 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1300 paramtype <- Type Instance["Any Type"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1301 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1302 [after type]Get DString[","] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1303 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1304 out params,out types <- Parse Param List[~,nextlist,next types,params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1305 } {} {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1306 out params <- Val[nextlist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1307 out types <- Val[next types] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1308 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1309 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1310 paramtype <- Type Instance["Any Type"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1311 out params,out types <- Parse Param List[after,nextlist,next types,params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1312 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1313 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1314 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1315 paramtype <- Type Instance["Any Type"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1316 out params <- Val[nextlist] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1317 out types <- Val[next types] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1318 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1319 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1320 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1321 Worker Declaration[string,params:worker,rest,no match] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1322 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1323 ,whitespace name <- [string]Get Comment DString[[params]Arg Begin >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1324 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1325 worker name <- Trim[whitespace name, "\n\r\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1326 in out <- [params]In Out Delim >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1327 arg end <- [params]Arg End >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1328 delims <- [[()]Append[in out]]Append[arg end] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1329 after <- [~]Get Comment DString[delims, params] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1330 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1331 arglist <- Trim[~,"\r\n\t "] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1332 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1333 //check if there is an in/out separator |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1334 //if it isn't present, everything in the arglist is an input |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1335 If[[~] = [in out]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1336 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1337 rest <- [after]Get Comment DString[arg end, params] {} |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1338 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1339 outputs,output types <- Parse Param List[~, (), (), params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1340 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1341 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1342 rest <- Val[after] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1343 outputs <- () |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1344 output types <- () |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1345 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1346 inputs,input types <- Parse Param List[arglist, (), (), params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1347 worker <- Parse Worker[worker name, inputs, outputs, input types, output types, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1348 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1349 }{}{}{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1350 no match <- string |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1351 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1352 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1353 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1354 Worker Name[string,params,tree,lines:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1355 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1356 ,after arglist <- Worker Declaration[string, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1357 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1358 worker name <- [~]Name >> |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1359 body text, modifiers <- [after arglist]Get Comment DString[[params]Block Begin >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1360 modified <- Process Modifiers[~, params, modifiers] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1361 expression trees, after body <- Worker Body[body text, params, ()] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1362 worker <- [modified]Trees <<[expression trees] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1363 new worker dict <- [[tree]Workers >>]Set[worker name, worker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1364 out <- Null[after body, params, [tree]Workers <<[new worker dict], 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1365 } {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1366 out <- tree |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1367 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1368 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1369 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1370 Parse Foreign Worker[tree, string, lib, params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1371 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1372 ,rest <- Worker Declaration[string, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1373 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1374 foreign <- [~]Trees << [lib] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1375 next <- [tree]Workers << [[[tree]Workers >>]Set[[foreign]Name >>, foreign]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1376 out <- Parse Foreign Worker[next, rest, lib, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1377 } {} { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1378 out <- tree |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1379 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1380 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1381 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1382 Parse Foreign[string,params,tree,lines:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1383 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1384 ,after foreign <- [string]Slice[[[params]Foreign >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1385 [after foreign]Get Comment DString[[params]Blueprint Type Delim >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1386 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1387 [~]Get Comment DString[[params]Block Begin >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1388 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1389 rest, body <- [~]Get Comment DString[[params]Block End >>, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1390 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1391 { lib <- Trim[~, "\r\n\t "] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1392 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1393 { language <- Trim[~, "\r\n\t "] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1394 Parse Foreign Worker[tree, body, New Foreign Lib[language, lib], params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1395 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1396 out <- Null[rest, params, ~, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1397 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1398 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1399 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1400 Null[string,params,tree,lines:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1401 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1402 trimmed <- Comment Left Trim[string, " \n\r\t", params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1403 current line <- 0 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1404 If[[trimmed]Starts With[ [params]Blueprint >> ]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1405 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1406 out <- PBlueprint[trimmed, params, tree, current line] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1407 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1408 If[[trimmed]Starts With[ [params]Import >> ]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1409 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1410 out <- Parse Import[trimmed, params, tree, current line] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1411 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1412 If[[trimmed]Starts With[ [params]Foreign >> ]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1413 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1414 out <- Parse Foreign[trimmed, params, tree, current line] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1415 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1416 If[trimmed] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1417 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1418 out <- Worker Name[trimmed, params, tree, current line] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1419 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1420 out <- tree |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1421 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1422 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1423 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1424 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1425 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1426 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1427 Check Worker Literals@Parse Worker[worker,program:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1428 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1429 [(List(),List Leaf())]Find[=[Blueprint Of[[worker]Trees >>], ?]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1430 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1431 out <- [worker]Trees <<[ Map[[worker]Trees >>, Check Worker Literals[?, program]] ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1432 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1433 out <- worker |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1434 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1435 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1436 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1437 Register Workers Compile[prog, worker, name:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1438 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1439 //Print[["Registering "]Append[name]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1440 If[[ Blueprint Of[[worker]Trees >>] ] = [Foreign Lib()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1441 { convention <- Val[[[worker]Trees >>]Language >>] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1442 { convention <- "rhope" } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1443 out <- [prog]Register Worker[name, convention, [[worker]Inputs >>]Length, [[worker]Outputs >>]Length] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1444 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1445 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1446 Add Workers Compile[prog, worker, name:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1447 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1448 Print[["Transforming "]Append[name]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1449 If[[Blueprint Of[[worker]Trees >>]] = [Foreign Lib()]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1450 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1451 //TODO: Handle foreign func |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1452 final nworker <- [[[[[NWorker[[[worker]Trees >>]Language >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1453 ]Inputs <<[ [worker]Inputs >> ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1454 ]Input Types <<[ [worker]Input Types >> ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1455 ]Outputs <<[ [worker]Outputs >> ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1456 ]Output Types <<[ [worker]Output Types >> ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1457 ]Library <<[ [[worker]Trees >>]Name >> ] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1458 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1459 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1460 trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [[NWorker["rhope"]]Uses[[worker]Uses Stores >>]]Outputs <<[ [worker]Outputs >> ], prog, worker, Dictionary[]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1461 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1462 final nworker <- Fold[Add Wires Helper[?, ?, ?, worker, refs], nworker, trees] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1463 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1464 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1465 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1466 out <- [prog]Bind Worker[name, final nworker] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1467 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1468 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1469 Add Wires Helper[worker,node,unused,parse worker,assignments:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1470 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1471 out <- [node]Add Wires[worker, (), parse worker, assignments] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1472 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1473 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1474 Add Blueprint Field[blueprint,field,unused:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1475 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1476 out <- [blueprint]Add Field[[field]Name >>, [field]Type >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1477 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1478 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1479 Add Blueprint Compile[prog,def:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1480 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1481 out <- [prog]Bind Blueprint[[def]Name >>, Fold[Add Blueprint Field[?], NBlueprint[], [def]Fields >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1482 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1483 |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
115
diff
changeset
|
1484 Tree to Program Native[parse tree,number types:out] |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1485 { |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
115
diff
changeset
|
1486 registered <- Fold[Register Workers Compile[?], [Fold[Add Blueprint Compile[?], [NProgram[]]Numtypes <<[number types], [parse tree]Blueprints >>]]Register Builtins, [parse tree]Workers >>] |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1487 out <- Fold[Add Workers Compile[?], registered, [parse tree]Workers >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1488 { Print["Transformed AST to dataflow graph "] } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1489 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1490 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1491 Needs Imports[needs import,not imported?,name:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1492 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1493 If[not imported?] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1494 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1495 out <- [needs import]Append[name] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1496 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1497 out <- needs import |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1498 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1499 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1500 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1501 Do Import[tree,file name,unused,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1502 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1503 Print[["Parsing: "]Append[file name]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1504 file <- [File[file name]]Open["r"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1505 text <- String[[file]Read[[file]Length]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1506 after import <- Null[text, params, tree, 0] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1507 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1508 out <- [after import]Imports <<[[[after import]Imports >>]Set[file name, No]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1509 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1510 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1511 Process Imports[parse tree,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1512 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1513 needs import <- Fold[Needs Imports[?], (), [parse tree]Imports >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1514 If[[[needs import]Length] > [0]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1515 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1516 import tree <- Fold[Do Import[?, ?, ?, params], parse tree, needs import] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1517 out <- Process Imports[import tree, params] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1518 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1519 out <- parse tree |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1520 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1521 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1522 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1523 Until End[text:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1524 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1525 line <- Get Input[] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1526 If[[line] = ["End"]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1527 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1528 out <- [text]Append["\n"] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1529 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1530 out <- Until End[[[text]Append["\n"]]Append[line]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1531 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1532 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1533 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1534 Add If Store[stores,name,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1535 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1536 If[[name]Contains[[params]Global Separator >>]] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1537 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1538 parts <- [name]Split[[params]Global Separator >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1539 out <- [stores]Set[[parts]Index[0], Yes] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1540 }{ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1541 out <- stores |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1542 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1543 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1544 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1545 Param Gather Stores[stores,node,params:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1546 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1547 out <- [node]Gather Stores[params, stores] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1548 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1549 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1550 Gather Stores@Named Pipe Node[node,params,stores:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1551 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1552 out <- Fold[Add If Store[?, ?, params], stores, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1553 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1554 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1555 Gather Stores@Global Node[node,params,stores:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1556 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1557 out <- [stores]Set[[node]Store >>, Yes] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1558 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1559 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1560 Gather Stores@Worker Node[node,params,stores:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1561 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1562 //TODO: Handle blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1563 store list <- Fold[Param Gather Stores[?, ?, params], stores, [node]Params >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1564 out <- Fold[Add If Store[?, ?, params], store list, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1565 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1566 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1567 Gather Stores@Field Node[node,params,stores:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1568 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1569 //TODO: Handle blocks |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1570 store list <- Fold[Param Gather Stores[?, ?, params], stores, [node]Params >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1571 out <- Fold[Add If Store[?, ?, params], store list, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1572 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1573 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1574 Gather Stores@Literal Node[node,params,stores:out] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1575 { |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1576 out <- Fold[Add If Store[?, ?, params], stores, [node]Assignments >>] |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1577 } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1578 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1579 |