changeset 228:decdf28a8517

Implemented arrays in grammar
author Michael Pavone <pavone@retrodev.com>
date Sun, 29 Dec 2013 17:16:52 -0800
parents 8c16ef123aee
children 7435367a932a
files modules/parser.tp
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/parser.tp	Sun Dec 29 17:09:21 2013 -0800
+++ b/modules/parser.tp	Sun Dec 29 17:16:52 2013 -0800
@@ -821,6 +821,23 @@
 		}
 	}
 
+	arraylit <- match: "#[" . ws . Els . "]" where: {
+		Els <- zeroPlus: lexpr
+	} yield: {
+		//Handle limitation of zeroPlus macro
+		if: (Els length) = 0 {
+			Els <- []
+		}
+		#{
+			litval <- Els
+			string <- {
+				"#[\n\t". ((litval map: :el {
+					string: el
+				}) join: "\n\t") . "\n]"
+			}
+		}
+	}
+
 	primlitsym <- match: hws . Lit where: {
 		Lit <- matchOne: [
 			hexlit
@@ -829,6 +846,7 @@
 			symexpr
 			object
 			listlit
+			arraylit
 		]
 	} yield: {
 		Lit
@@ -883,7 +901,7 @@
 		testmatchintlit: "0x20" :s {hexlit: s}
 		testmatchintlit: "0x42u64" :s {hexlit: s}
 		testmatchintlit: "0b10101" :s {binary: s}
-		code <- "#{ foo <- 123 > 0x42 && 42 < 104\n bar <- 0xABC + 0b1010101\n baz <- 0b1010 * 5\n qux <- fo: 38 shizzle: bam\n quine <- 123 | [4 5 6 fiddle sticks]\n}"
+		code <- "#{ foo <- 123 > 0x42 && 42 < 104\n bar <- 0xABC + 0b1010101\n baz <- 0b1010 * 5\n qux <- fo: 38 shizzle: bam\n quine <- 123 | [4 5 6 fiddle sticks]\nquizzle <- #[receiver meth: arg]}"
 		codem <- expr: code
 		if: (codem matched?) {
 			print: code . "\nmatched with yield:\n" . (codem yield) . "\n"