Mercurial > repos > rhope
diff parse.rhope @ 132:1f238280047f
Some work on expression parsing in new parser
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 05 Nov 2010 01:23:25 -0400 |
parents | 0a4682be2db2 |
children | 386f4a874821 |
line wrap: on
line diff
--- a/parse.rhope Fri Nov 05 02:43:34 2010 +0000 +++ b/parse.rhope Fri Nov 05 01:23:25 2010 -0400 @@ -86,37 +86,42 @@ ]Append[ ["\n\tBlocks:\t"]Append[ [[String[[statement]Blocks >>]]Split["\n"]]Join["\n\t"] ] ] } -Blueprint Worker Expression +Blueprint Worker Call { Worker Blueprint Arguments } -String@Worker Expression[exp:out] +Worker Call[worker,blueprint:out] { - out <- ["Worker Expression\n\tWorker:\t"]Append[[exp]Worker >>] + out <- [[[Build[Worker Call()]]Worker <<[worker]]Blueprint <<[blueprint]]Arguments <<[()] } -Blueprint Global Expression +String@Worker Call[exp:out] +{ + out <- ["Worker Call\n\tWorker:\t"]Append[[exp]Worker >>] +} + +Blueprint Global Reference { Store Variable } -Blueprint Pipe Expression +Blueprint Pipe Value { Name } -Pipe Expression[name:out] +Pipe Value[name:out] { - out <- [Build[Pipe Expression()]]Name <<[name] + out <- [Build[Pipe Value()]]Name <<[name] } -String@Pipe Expression[pipe:out] +String@Pipe Value[pipe:out] { - out <- ["Pipe Expression\n\tName:\t"]Append[[pipe]Name >>] + out <- ["Pipe Value\n\tName:\t"]Append[[pipe]Name >>] } Blueprint Block @@ -134,22 +139,81 @@ out <- Fold[_String Seq[?], "Block", [block]Tree >>] } -Blueprint Field Expression +Blueprint Field Call { Name Set? + Arguments +} + +Field Call[name,set?:out] +{ + out <- [[[Build[Field Call()]]Name <<[name]]Set? <<[set?]]Arguments <<[()] } -Field Expression[name,set?:out] +Expression[tokens,current:out,out index,none] { - out <- [[Build[Field Expression()]]Name <<[name]]Set? <<[set?] + token <- [tokens]Index[current] + [token]Type Match["Symbol"] + { + ,end stream <- [tokens]Next[current] + { + after <- [tokens]Index[~] + [after]Type Match["Args Begin"] + { + + }{ + + } + } + }{ + [token]Type Match[("Field Get","Field Set")] + { + [token]Type Match["Field Set"] + { set? <- Yes } + { set? <- No } + Field Call[[token]Text >>, set?] + }{ + [token]Type Match["Args Begin"] + { + + }{ + [token]Type Match["List Begin"] + { + + }{ + [token]Type Match[("String Literal","Numeric Literal")] + { + + }{ + [token]Type Match["Newline"] + { + ,none <- [tokens]Next[current] + { out, out index <- Expression[tokens, ~] } + }{ + none, unexpected token <- [token]Type Match["Block End"] + } + } + } + } + } + } } + Body[node,tokens,current,depth:out,out index, done] { Print[["Body: Depth="]Append[String[depth]]] If[[depth] > [0]] { + //symbol list = Symbol [List Separator symbol list] + //value = String Literal | Number Literal | List Literal | Symbol | Block Reference | expression + //call = [Args Begin arg list Args End]Symbol[Args Begin arg list Args End] + //arg list = value | Arg Placeholder [List Separator arg list] + //block = Block Begin [expressions] Block End + //blocks = block [blocks] + //expressions = expression [expressions] + //expression = [symbol list Assignment] call | value blocks | Newline token <- [tokens]Index[current] [token]Type Match["Block Begin"] { @@ -455,7 +519,7 @@ } }{ - [token]Type Match[("Newline","Block Comment","Line Comment")] + [token]Type Match["Newline"] { next nodes <- Val[nodes] next index <- Val[current] @@ -471,12 +535,23 @@ } } +NotComment[token:out] +{ + [token]Type Match[("Block Comment","Line Comment")] + { + out <- No + }{ + out <- Yes + } +} + Parse[tokens:out] { [tokens]First { - out <- Top Level[tokens, ~, ()] + out <- Top Level[Filter[tokens, NotComment[?]], ~, ()] }{ out <- () } } +