jison
jison copied to clipboard
Implementing own parser.yy.parseError function throws error
When using the generated javascript parser file, and implementing my own parseError function like:
parser.yy.parseError = function(error, hash) {...};
gives the following error every time I parse something:
TypeError: Cannot read property '0' of undefined
You can find a working example here: http://jsfiddle.net/fLknW/
It seems to me that the algorithm should stop after it calls parseError(errStr, {...})
since action
will always be undefined. The error is not thrown when not overriding the default implementation of parseError since by default it does throw new Error(str);
which stops the algorithm
:+1:
No one ever got around to this one then?
Anything new on this?
Since jison doesn't have yyerror support anyway I just ended up catching the error somewhere in my wrapper code and working with the error object from there.
:-/
Have you tried to define a parseError
function in the parser scope? This works for me.
yy = { };
yy.parseError = function(msg, hash) {
doSomething();
}
parser.yy = yy;