changeset 134:386f4a874821

More work on new parser
author Mike Pavone <pavone@retrodev.com>
date Wed, 10 Nov 2010 22:29:49 -0500
parents e1911b2fd5cc
children 18a4403fe576
files lex.rhope parse.rhope
diffstat 2 files changed, 83 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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"]
--- 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]