Mercurial > repos > rhope
changeset 6:f67d9be38ddf
Merged parser changes and Linux box enhancements
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 13 May 2009 00:43:58 -0400 |
parents | a4d2d633a356 (diff) 94c885692eb5 (current diff) |
children | d61550e2c001 |
files | |
diffstat | 1 files changed, 122 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/parse.rhope Wed Apr 29 03:21:23 2009 -0400 +++ b/parse.rhope Wed May 13 00:43:58 2009 -0400 @@ -47,6 +47,67 @@ out <- [node]Outputs <<[[[node]Outputs >>]Append[output]] } +Blueprint Statement +{ + Expression + Assignments + Blocks +} + +Statement[expression,assignments:out] +{ + out <- [[[Build["Statement"]]Expression <<[expression]]Assignments <<[assignments]]Blocks <<[()] +} + +Add Block@Statement[statement,block:out] +{ + out <- [statement]Blocks <<[ [[statement]Blocks >>]Append[block] ] +} + +Blueprint Worker Expression +{ + Worker + Blueprint + Arguments +} + +Blueprint Global Expression +{ + Store + Variable +} + +Blueprint Pipe Expression +{ + Name +} + +Pipe Expression[name:out] +{ + out <- [Build["Pipe Expression"]]Name <<[name] +} + +Blueprint Block +{ + Tree +} + +Block[:out] +{ + out <- [Build["Block"]]Tree <<[()] +} + +Blueprint Field Expression +{ + Name + Set? +} + +Field Expression[name,set?:out] +{ + out <- [[Build["Field Expression"]]Name <<[name]]Set? <<[set?] +} + Body[node,tokens,current,depth:out,out index, done] { Print[["Body: Depth="]Append[depth]] @@ -243,19 +304,77 @@ out,out index, done <- Before Inputs[[[[[Build["Worker Node"]]Name <<[name]]Inputs <<[()]]Outputs <<[()]]Tree <<[()], tokens, current] } +Skip Nodes[toskip, stop, tokens, current:out] +{ + token <- [tokens]Index[current] + next <- [tokens]Next[current] + { + [token]Type Match[stop] + { + out <- Val[next] + }{ + [token]Type Match[toskip] + { + out <- Skip Nodes[toskip, stop, tokens, next] + }{ + Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]] + } + } + }{ + Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]] + } +} + Blueprint PBlueprint Node { Name Fields } +Fields[node,tokens,current:out,out index,done] +{ + token <- [tokens]Index[current] + next <- [tokens]Next[current] + { + [token]Type Match["Symbol"] + { + out,out index,done <- Fields[[node]Add BField[[token]Text >>], tokens, next] + }{ + [token]Type Match["Block End"] + { + out <- Val[node] + out index <- Val[next] + }{ + [token]Type Match[("Newline","Line Comment","Block Comment")] + { + out,out index,done <- Fields[node, tokens, next] + }{ + Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]] + } + } + } + }{ + [token]Type Match["Block End"] + { + out <- Val[node] + done <- Yes + }{ + Print[To String[Error[["Unexpected end of stream after token of type "]Append[[token]Type >>], [token]Raw Text >>]]] + } + } +} + PBlueprint Node[name, tokens, current:out,out index,done] { - out <- [[Build["PBlueprint Node"]]Name <<[name]]Fields <<[()] - out index <- current - //TODO: Parse rest of blueprint definition + node <- [[Build["PBlueprint Node"]]Name <<[name]]Fields <<[()] + next <- Skip Nodes[("Newline","Block Comment","Comment"), "Block Begin", tokens, current] + out,out index,done <- Fields[node, tokens, next] } +Add BField@PBlueprint Node[node,field:out] +{ + out <- [node]Fields <<[[[node]Fields >>]Append[field]] +} Top Level[tokens, current, nodes:out] {