# HG changeset patch # User Mike Pavone # Date 1289446189 18000 # Node ID 386f4a874821e97b1986e4ca77cdc7df4134b686 # Parent e1911b2fd5ccb006e44b1f3c7adfa62683ee0e37 More work on new parser diff -r e1911b2fd5cc -r 386f4a874821 lex.rhope --- a/lex.rhope Wed Nov 10 22:29:33 2010 -0500 +++ b/lex.rhope Wed Nov 10 22:29:49 2010 -0500 @@ -103,7 +103,7 @@ Numeric Literal[literal, text, simple tokens, token list:out] { first,rest <- [text]Slice[1] - If[[first] In ["01234567890.x"]] + If[[first] In ["01234567890.xui"]] { out <- Numeric Literal[[literal]Append[first], rest, simple tokens, token list] }{ @@ -203,13 +203,14 @@ Lex[text:out] { - simple tokens <- [[[[[[[[[[Dictionary[] + simple tokens <- [[[[[[[[[[[Dictionary[] ]Set["{", "Block Begin"] ]Set["}", "Block End"] ]Set["(", "List Begin"] ]Set[")", "List End"] ]Set["[", "Args Begin"] ]Set["]", "Args End"] + ]Set[".", "Call Separator"] ]Set[",", "List Separator"] ]Set[":", "Name Separator"] ]Set["@", "Method Separator"] diff -r e1911b2fd5cc -r 386f4a874821 parse.rhope --- a/parse.rhope Wed Nov 10 22:29:33 2010 -0500 +++ b/parse.rhope Wed Nov 10 22:29:49 2010 -0500 @@ -124,6 +124,16 @@ out <- ["Pipe Value\n\tName:\t"]Append[[pipe]Name >>] } +Blueprint Literal +{ + Value +} + +Literal[val:out] +{ + out <- [Build[Literal()]]Value <<[val] +} + Blueprint Block { Tree @@ -151,6 +161,52 @@ out <- [[[Build[Field Call()]]Name <<[name]]Set? <<[set?]]Arguments <<[()] } +After Literal[tokens,current,literal:out,out index] +{ + next index <- [tokens]Next[current] + { + after <- [tokens]Index[~] + [after]Type Match["Call Separator"] + { + out,out index <- To Call[tokens,next index,[()]Append[literal]] + }{ + [after]Type Match[("Newline","Block End","List End")] + { + out <- literal + out index <- current + } + } + }{ + out <- literal + out index <- current + } +} + +Parse Hex[text:out,error] +{ + +} + +Parse Number[text:out,error] +{ + [text]Starts With["0x"] + { + [text]Slice[2] {} + { out,error <- Parse Hex[~] } + }{ + [text]Contains["."] + { + + }{ + val,sign,size <-[text]Partition[("u","i")] {} {} {} + { + //TODO: Produce "bigint" instead of Int32 + out <- Int32[text] + } + } + } +} + Expression[tokens,current:out,out index,none] { token <- [tokens]Index[current] @@ -163,7 +219,17 @@ { }{ - + [after]Type Match["Call Separator"] + { + + }{ + [after]Type Match["Newline"] + { + + }{ + + } + } } } }{ @@ -182,18 +248,24 @@ { }{ - [token]Type Match[("String Literal","Numeric Literal")] + [token]Type Match["String Literal"] { - + lit <- [token]Text >> }{ - [token]Type Match["Newline"] + [token]Type Match["Numeric Literal"] { - ,none <- [tokens]Next[current] - { out, out index <- Expression[tokens, ~] } + lit <- Parse Number[[token]Text >>] }{ - none, unexpected token <- [token]Type Match["Block End"] + [token]Type Match["Newline"] + { + ,none <- [tokens]Next[current] + { out, out index <- Expression[tokens, ~] } + }{ + none, unexpected token <- [token]Type Match["Block End"] + } } } + out,out index <- After Literal[tokens,current,Literal[lit]] } } } @@ -208,7 +280,7 @@ { //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] + //call = [Args Begin arg list Args End]Symbol[Args Begin arg list Args End] | (value | Arg Placeholder) Call Separator Symbol //arg list = value | Arg Placeholder [List Separator arg list] //block = Block Begin [expressions] Block End //blocks = block [blocks]