GerHobbelt / jison

bison / YACC / LEX in JavaScript (LALR(1), SLR(1), etc. lexer/parser generator)
https://gerhobbelt.github.io/jison/
MIT License
118 stars 20 forks source link

make esprima errors more intelligible (caused by faults in user action code test-parse-passes during grammar compile) #60

Open GerHobbelt opened 4 years ago

GerHobbelt commented 4 years ago

Here's one with bleeding edge jison-gho: not useful as it is. Try to catch these buggers and make them behave like the extended yyerror reports:

(Also note the bloody stacktrace is only about a part in esprima itself, which is extremely useless for error diagnosis of the action code which is parsed through there. 😭 )


$ make issue-360
node ../dist/cli-cjs.js -o ./output/issue-360/ --main --export-ast+ ./issue-360.json
JISON output for module [issue_360] has been written to file: output\issue-360\issue-360.js
macros keylen: 5
macros keylen B: 8
indented action: {
  entry: '/* skip whitespace */',
  action: 'function',
  actionHasLF: false
}

W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima.js:1995
                throw this.unexpectedTokenError(token, message);
                ^
Error: Line 13: Unexpected token }
    at ErrorHandler.constructError (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima.js:5012:22)
    at ErrorHandler.createError (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima.js:5028:27)
    at JSXParser.Parser.unexpectedTokenError (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima.j
s:1985:39)
    at JSXParser.Parser.throwUnexpectedToken (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima.j
s:1995:21)
    at JSXParser.Parser.parseVariableIdentifier (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprim
a.js:3594:27)
    at JSXParser.Parser.parseFunctionDeclaration (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\espri
ma.js:4316:24)
    at JSXParser.Parser.parseStatementListItem (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima
.js:3379:39)
    at JSXParser.Parser.parseFunctionSourceElements (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\es
prima.js:4195:29)
    at JSXParser.Parser.parseFunctionDeclaration (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\espri
ma.js:4347:26)
    at JSXParser.Parser.parseStatementListItem (W:\Projects\sites\library.visyond.gov\80\lib\tooling\jison\node_modules\recast\node_modules\esprima\dist\esprima
.js:3379:39) {
  index: 165,
  lineNumber: 13,
  description: 'Unexpected token }'
}