From af9e8a1e92e2f036b4115211908b4d1b6ad1c323 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Wed, 21 Oct 2015 10:50:05 +0200 Subject: [PATCH] fix #1023: getExpectedTokens() returns out of context tokens on consecutive runs --- runtime/JavaScript/src/antlr4/error/ErrorStrategy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/JavaScript/src/antlr4/error/ErrorStrategy.js b/runtime/JavaScript/src/antlr4/error/ErrorStrategy.js index f1e852616..f2993e713 100644 --- a/runtime/JavaScript/src/antlr4/error/ErrorStrategy.js +++ b/runtime/JavaScript/src/antlr4/error/ErrorStrategy.js @@ -269,7 +269,8 @@ DefaultErrorStrategy.prototype.sync = function(recognizer) { case ATNState.PLUS_LOOP_BACK: case ATNState.STAR_LOOP_BACK: this.reportUnwantedToken(recognizer); - var expecting = recognizer.getExpectedTokens(); + var expecting = new IntervalSet(); + expecting.addSet(recognizer.getExpectedTokens()); var whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer)); this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule); break;