From 41eb4d422a28fd1e5f2bb609afe28ba57494c523 Mon Sep 17 00:00:00 2001 From: Johan Ahlen Date: Mon, 19 Jun 2017 23:54:46 +0200 Subject: [PATCH 1/2] Fix issue where the location of the past lexer input is reported on error and not the failing input --- lib/jison.js | 2 +- ports/comments.js | 2 +- ports/csharp/Jison/Jison/Test/formula.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jison.js b/lib/jison.js index d078056ee..efd0a7f5d 100755 --- a/lib/jison.js +++ b/lib/jison.js @@ -1493,7 +1493,7 @@ _handle_error: text: lexer.match, token: this.terminals_[symbol] || symbol, line: lexer.yylineno, - loc: yyloc, + loc: lexer.yylloc, expected: expected, recoverable: (error_rule_depth !== false) }); diff --git a/ports/comments.js b/ports/comments.js index 0633a2f21..e641a0656 100644 --- a/ports/comments.js +++ b/ports/comments.js @@ -142,7 +142,7 @@ parse: function parse(input) { } else { errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); } - this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: this.lexer.yylloc, expected: expected}); } } if (action[0] instanceof Array && action.length > 1) { diff --git a/ports/csharp/Jison/Jison/Test/formula.js b/ports/csharp/Jison/Jison/Test/formula.js index e040e4acd..b7bfcd03e 100644 --- a/ports/csharp/Jison/Jison/Test/formula.js +++ b/ports/csharp/Jison/Jison/Test/formula.js @@ -696,7 +696,7 @@ _handle_error: text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, - loc: yyloc, + loc: this.lexer.yylloc, expected: expected, recoverable: (error_rule_depth !== false) }); From ad8e41475ef67c6bb8b227f17da368d348536e6d Mon Sep 17 00:00:00 2001 From: Johan Ahlen Date: Wed, 13 Mar 2019 19:34:20 +0100 Subject: [PATCH 2/2] Add ruleId as unique identifier for syntax errors --- .gitignore | 3 ++- lib/jison.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3f1af7895..39d9341e1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ node_modules # Editor backup files *.bak *~ -web/content/assets/js/jison.js \ No newline at end of file +web/content/assets/js/jison.js +.idea diff --git a/lib/jison.js b/lib/jison.js index efd0a7f5d..d08ddb0a6 100755 --- a/lib/jison.js +++ b/lib/jison.js @@ -1494,6 +1494,7 @@ _handle_error: token: this.terminals_[symbol] || symbol, line: lexer.yylineno, loc: lexer.yylloc, + ruleId: stack.slice(stack.length - 2, stack.length).join('_'), expected: expected, recoverable: (error_rule_depth !== false) });