zaach/jison — pull request #97 by robertleeplummerjr (2012-04-22 21:37:34+00:00)
Title: Making parser and lexer extendable and nestable

So I've been talking about this for some time, I need the ability to nest parser, ie one active parser, create a new one, parse, close that parser, and continue with the parent parser without destroying it. This gives you the ability to clone the parser object with a Factory method (default will be parserFactory(parserExtensions, lexerExtensions);)

What the and lexer extensions do:
They tie into the base parser/lexer, so say you wanted to parse html, you can easily do it like this within the YACC grammer:

{CODE()}
html : { parser.html($1); }
{CODE}

And you'd be able to create your new parser object like this:

{CODE()}
var myParser = parserFactory({
html: function(val) {return '' + val + ''; }
});
{CODE}

To note, the jQuery.extend method must be available, if it isn't the code gracefully degrades.