# HG changeset patch # User Mike Pavone # Date 1241063953 14400 # Node ID 0c5f24b4f69d81a2b2d761ffc1c6e23cd484d36e # Parent 73e978d590c7b0b778b758d7ae85c6d49bd57f72 Handle blueprints in new parser diff -r 73e978d590c7 -r 0c5f24b4f69d parse.rhope --- a/parse.rhope Wed Apr 29 02:58:03 2009 -0400 +++ b/parse.rhope Wed Apr 29 23:59:13 2009 -0400 @@ -243,19 +243,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] {