access to AST of pegjs

157 views
Skip to first unread message

ek.s...@gmail.com

unread,
Feb 6, 2013, 12:46:45 AM2/6/13
to pe...@googlegroups.com
Hi,
I wanted to specify a grammar, call pegjs.buildParser and then access the AST corresponding to the grammer to, say create programs following the grammar.

Do you think pegjs allows me to do that?

thanks
nishant

David Majda

unread,
Mar 12, 2013, 3:35:00 PM3/12/13
to eks...@gmail.com, pegjs
Hi,

2013/2/6 <ek.s...@gmail.com>:
> Hi,
> I wanted to specify a grammar, call pegjs.buildParser and then access the AST corresponding to the grammer to, say create programs following the grammar.
>
> Do you think pegjs allows me to do that?

PEG.js exports its grammar parser in the "parser" property. Just do:

var ast = PEG.parser.parse(input);

and you'll have the AST in hand.

--
David Majda
Entropy fighter
http://majda.cz/
Reply all
Reply to author
Forward
0 new messages