FAQ Database Discussion Community


Peg.js in AngularJS webapp

angularjs,pegjs
I have an AngularJS web application. I'd like to use peg.js in my application. I've just written a peg.js grammar: CriteriaValue.pegjs and generated the parser with the command line: pegjs CriteriaValue.pegjs, which generated CriteriaValue.js. Could someone explain to me how to use the parser ? var result = parser.parse('my string');...

How do you parse nested comments in pegjs?

javascript,parsing,grammar,peg,pegjs
I was wondering how do you parse comments (say, a la Haskell), in pegjs. The goal: {- This is a comment and should parse. Comments start with {- and end with -}. If you've noticed, I still included {- and -} in the comment. This means that comments should also...

Why is PEGjs / not working correctly?

pegjs
I have a simple parser in PEGjs start = val ln = [\n\r] float = digits:$[-0-9\.]+ { return parseFloat(digits, 10) } str = str:$(!ln !"\"" .)+ val = float / str and I try to match -this But instead of getting "str" it gives error on parsing "float" Line 1,...

PEGJS: Generating an AST for a predicate first syntax

javascript,parsing,grammar,abstract-syntax-tree,pegjs
I'm back to exploring pegjs and clearly have not grasped the core concept yet. I'm trying to parse a "query language" that starts with a predicate and then a list of operands (which could include another predicate). So a simple example would be: OR( "string1" "string2" ) I would like...