comparison parse.rhope @ 4:0c5f24b4f69d

Handle blueprints in new parser
author Mike Pavone <pavone@retrodev.com>
date Wed, 29 Apr 2009 23:59:13 -0400
parents 73e978d590c7
children a4d2d633a356
comparison
equal deleted inserted replaced
2:73e978d590c7 4:0c5f24b4f69d
241 { 241 {
242 Print[["Worker: "]Append[To String[name]]] 242 Print[["Worker: "]Append[To String[name]]]
243 out,out index, done <- Before Inputs[[[[[Build["Worker Node"]]Name <<[name]]Inputs <<[()]]Outputs <<[()]]Tree <<[()], tokens, current] 243 out,out index, done <- Before Inputs[[[[[Build["Worker Node"]]Name <<[name]]Inputs <<[()]]Outputs <<[()]]Tree <<[()], tokens, current]
244 } 244 }
245 245
246 Skip Nodes[toskip, stop, tokens, current:out]
247 {
248 token <- [tokens]Index[current]
249 next <- [tokens]Next[current]
250 {
251 [token]Type Match[stop]
252 {
253 out <- Val[next]
254 }{
255 [token]Type Match[toskip]
256 {
257 out <- Skip Nodes[toskip, stop, tokens, next]
258 }{
259 Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]]
260 }
261 }
262 }{
263 Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]]
264 }
265 }
266
246 Blueprint PBlueprint Node 267 Blueprint PBlueprint Node
247 { 268 {
248 Name 269 Name
249 Fields 270 Fields
250 } 271 }
251 272
273 Fields[node,tokens,current:out,out index,done]
274 {
275 token <- [tokens]Index[current]
276 next <- [tokens]Next[current]
277 {
278 [token]Type Match["Symbol"]
279 {
280 out,out index,done <- Fields[[node]Add BField[[token]Text >>], tokens, next]
281 }{
282 [token]Type Match["Block End"]
283 {
284 out <- Val[node]
285 out index <- Val[next]
286 }{
287 [token]Type Match[("Newline","Line Comment","Block Comment")]
288 {
289 out,out index,done <- Fields[node, tokens, next]
290 }{
291 Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]]
292 }
293 }
294 }
295 }{
296 [token]Type Match["Block End"]
297 {
298 out <- Val[node]
299 done <- Yes
300 }{
301 Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]]
302 }
303 }
304 }
305
252 PBlueprint Node[name, tokens, current:out,out index,done] 306 PBlueprint Node[name, tokens, current:out,out index,done]
253 { 307 {
254 out <- [[Build["PBlueprint Node"]]Name <<[name]]Fields <<[()] 308 node <- [[Build["PBlueprint Node"]]Name <<[name]]Fields <<[()]
255 out index <- current 309 next <- Skip Nodes[("Newline","Block Comment","Comment"), "Block Begin", tokens, current]
256 //TODO: Parse rest of blueprint definition 310 out,out index,done <- Fields[node, tokens, next]
257 } 311 }
258 312
313 Add BField@PBlueprint Node[node,field:out]
314 {
315 out <- [node]Fields <<[[[node]Fields >>]Append[field]]
316 }
259 317
260 Top Level[tokens, current, nodes:out] 318 Top Level[tokens, current, nodes:out]
261 { 319 {
262 token <- [tokens]Index[current] 320 token <- [tokens]Index[current]
263 Print[[token]Type >>] 321 Print[[token]Type >>]