block by GerHobbelt e18f2ef8ee575d4ff49d

JISON sample wrapper showcasing custom error handlers (stripped JavaScript, ... where more must be done)

This code is a stripped version of actual production code which employs this JISON clone:

(https://github.com/GerHobbelt/jison)

hence make sure to diff that one against vanilla to see differences/features.


code shows .yy.parseError, lexer.post_lex, parser.post_parser, how to get the token identifier strings from the JISON-generated parser class, etc.

Note that the event reg/unreg/trigger functions are quick replacements for this gist only, use your own event system here. The key is that this works, even when you fire events from user action code inside the lexer or parser itself, hence more powerful than simply hooking .yy.parseError only!

parser-wrapper.js