Closed mpalmerlee closed 3 months ago
By adding a parseError property to the parser.yy object we avoid the error this.parseError is not a function and we can re-throw the underlying error with a more useful error message.
parseError
this.parseError is not a function
This works because the parser.yy object gets copied to the sharedState object here: https://github.com/zaach/jison/blob/master/lib/jison.js#L1393
parser.yy
sharedState
Then because sharedState.parseError is defined it is used rather than undefined here: https://github.com/zaach/jison/blob/master/lib/jison.js#L1409
sharedState.parseError
Fixes #92
thanks for making this contribution @mpalmerlee. i'll make time to take a look at this soon.
By adding a
parseError
property to the parser.yy object we avoid the errorthis.parseError is not a function
and we can re-throw the underlying error with a more useful error message.This works because the
parser.yy
object gets copied to thesharedState
object here: https://github.com/zaach/jison/blob/master/lib/jison.js#L1393Then because
sharedState.parseError
is defined it is used rather than undefined here: https://github.com/zaach/jison/blob/master/lib/jison.js#L1409Fixes #92