# HG changeset patch # User Michael Pavone # Date 1388366212 28800 # Node ID decdf28a8517794f59e33bc3647d7c5b21843f38 # Parent 8c16ef123aeebf17bf6245a935ec52d4aa329cf4 Implemented arrays in grammar diff -r 8c16ef123aee -r decdf28a8517 modules/parser.tp --- 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"