grammar test
number <- [0-9]? "foo" %action
grammar test
number <- [0-9]+ %action
grammar test
number <- [0-9]?
grammar test
number <- [0-9]? %action
$ canopy grammar.peg
Line 2: expected [\s], "#", [a-zA-Z_], "(", "&", "!", '"', "'", "`", "[", ".", "<", "/"
number <- [0-9]? %action
^
SyntaxError: Line 2: expected [\s], "#", [a-zA-Z_], "(", "&", "!", '"', "'", "`", "[", ".", "<", "/"
number <- [0-9]? %action
^
at Parser.parse (/usr/lib/node_modules/canopy/lib/canopy.js:2788:11)
at Object.parse (/usr/lib/node_modules/canopy/lib/canopy.js:2794:19)
at Canopy.Compiler.parseTree (/usr/lib/node_modules/canopy/lib/canopy.js:4527:20)
at Canopy.Compiler.toSource (/usr/lib/node_modules/canopy/lib/canopy.js:4539:10)
at Object.compile (/usr/lib/node_modules/canopy/lib/canopy.js:19:21)
at Object.<anonymous> (/usr/lib/node_modules/canopy/bin/canopy:25:24)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
These work:
But this fails with a grammar parsing error