Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing own parser.yy.parseError function throws error #218

Open
mebibou opened this issue Jun 4, 2014 · 6 comments
Open

Implementing own parser.yy.parseError function throws error #218

mebibou opened this issue Jun 4, 2014 · 6 comments

Comments

@mebibou
Copy link

mebibou commented Jun 4, 2014

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

@XavierBoubert
Copy link

👍

@rubenvereecken
Copy link

No one ever got around to this one then?

@mathiasrw
Copy link

Anything new on this?

@rubenvereecken
Copy link

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.

@mathiasrw
Copy link

:-/

@yosbelms
Copy link

yosbelms commented Feb 8, 2016

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants