comparison modules/ast.tp @ 252:004946743678

Added code for building a method symbol table
author Michael Pavone <pavone@retrodev.com>
date Sat, 10 May 2014 19:11:01 -0700
parents b76f683d076e
children be224817a14b
comparison
equal deleted inserted replaced
251:2557ce4e671f 252:004946743678
34 (left stringIndent: indent) . " " . op . (right stringIndent: indent) 34 (left stringIndent: indent) . " " . op . (right stringIndent: indent)
35 } 35 }
36 string <- { 36 string <- {
37 stringIndent: "" 37 stringIndent: ""
38 } 38 }
39 fold:with <- :acc :fun {
40 acc <- fun: acc self
41 acc <- _left fold: acc with: fun
42 _right fold: acc with: fun
43 }
39 } 44 }
40 } 45 }
41 46
42 stringLit <- :_val { 47 stringLit <- :_val {
43 #{ 48 #{
46 stringIndent <- :indent { 51 stringIndent <- :indent {
47 "\"" . val . "\"" 52 "\"" . val . "\""
48 } 53 }
49 string <- { 54 string <- {
50 stringIndent: "" 55 stringIndent: ""
56 }
57 fold:with <- :acc :fun {
58 fun: acc self
51 } 59 }
52 } 60 }
53 } 61 }
54 62
55 intLit:withBits:andBase:signed? <- :_val :_bits :_base :_signed? { 63 intLit:withBits:andBase:signed? <- :_val :_bits :_base :_signed? {
87 } 95 }
88 } 96 }
89 string <- { 97 string <- {
90 stringIndent: "" 98 stringIndent: ""
91 } 99 }
100 fold:with <- :acc :fun {
101 fun: acc self
102 }
92 } 103 }
93 } 104 }
94 105
95 symbol <- :_name { 106 symbol <- :_name {
96 #{ 107 #{
100 name 111 name
101 } 112 }
102 string <- { 113 string <- {
103 stringIndent: "" 114 stringIndent: ""
104 } 115 }
116 fold:with <- :acc :fun {
117 fun: acc self
118 }
105 } 119 }
106 } 120 }
107 121
108 funcall:withArgs:hasReceiver? <- :_tocall :_args :_receiver? { 122 funcall:withArgs:hasReceiver? <- :_tocall :_args :_receiver? {
109 #{ 123 #{
124 nodeType <- { _call }
110 tocall <- _tocall 125 tocall <- _tocall
111 args <- _args 126 args <- _args
112 hasReceiver? <- _receiver? 127 hasReceiver? <- _receiver?
113 stringIndent <- :indent { 128 stringIndent <- :indent {
114 argparts <- [] 129 argparts <- []
137 str 152 str
138 } 153 }
139 string <- { 154 string <- {
140 stringIndent: "" 155 stringIndent: ""
141 } 156 }
157 fold:with <- :acc :fun {
158 acc <- fun: acc self
159 _args fold: acc with: :acc el {
160 fun: acc el
161 }
162 }
142 } 163 }
143 } 164 }
144 165
145 object <- :_messages { 166 object <- :_messages {
146 #{ 167 #{
153 }) . "\n" . indent . "}" 174 }) . "\n" . indent . "}"
154 } 175 }
155 string <- { 176 string <- {
156 stringIndent: "" 177 stringIndent: ""
157 } 178 }
179 fold:with <- :acc :fun {
180 acc <- fun: acc self
181 messages fold: acc with: :acc el {
182 fun: acc el
183 }
184 }
158 } 185 }
159 } 186 }
160 187
161 seqLit:array? <- :_els :_array? { 188 seqLit:array? <- :_els :_array? {
162 #{ 189 #{
170 }) . "\n" . indent . "]" 197 }) . "\n" . indent . "]"
171 } 198 }
172 string <- { 199 string <- {
173 stringIndent: "" 200 stringIndent: ""
174 } 201 }
202 fold:with <- :acc :fun {
203 acc <- fun: acc self
204 els fold: acc with: :acc el {
205 fun: acc el
206 }
207 }
175 } 208 }
176 } 209 }
177 210
178 assign:to <- :_expr :_sym { 211 assign:to <- :_expr :_sym {
179 #{ 212 #{
183 stringIndent <- :indent { 216 stringIndent <- :indent {
184 (to stringIndent: indent) . " <- " . (assign stringIndent: indent) 217 (to stringIndent: indent) . " <- " . (assign stringIndent: indent)
185 } 218 }
186 string <- { 219 string <- {
187 stringIndent: "" 220 stringIndent: ""
221 }
222 fold:with <- :acc :fun {
223 acc <- fun: acc self
224 acc <- fun: acc _sym
225 fun: acc _expr
188 } 226 }
189 } 227 }
190 } 228 }
191 229
192 lambda:withArgs <- :_exprs :_args { 230 lambda:withArgs <- :_exprs :_args {
205 }) . "\n" . indent . "}" 243 }) . "\n" . indent . "}"
206 } 244 }
207 string <- { 245 string <- {
208 stringIndent: "" 246 stringIndent: ""
209 } 247 }
248 fold:with <- :acc :fun {
249 acc <- fun: acc self
250 expressions fold: acc with: :acc el {
251 fun: acc el
252 }
253 }
210 } 254 }
211 } 255 }
212 } 256 }
213 } 257 }