diff --git a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs index 62a3c074e..b9cec7769 100644 --- a/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs +++ b/runtime/CSharp/runtime/CSharp/Antlr4.Runtime/BufferedTokenStream.cs @@ -371,6 +371,7 @@ namespace Antlr4.Runtime this._tokenSource = tokenSource; tokens.Clear(); p = -1; + this.fetchedEOF = false; } public virtual IList GetTokens() diff --git a/runtime/JavaScript/src/antlr4/BufferedTokenStream.js b/runtime/JavaScript/src/antlr4/BufferedTokenStream.js index a29c2f1a5..72fd5b147 100644 --- a/runtime/JavaScript/src/antlr4/BufferedTokenStream.js +++ b/runtime/JavaScript/src/antlr4/BufferedTokenStream.js @@ -234,6 +234,7 @@ BufferedTokenStream.prototype.setTokenSource = function(tokenSource) { this.tokenSource = tokenSource; this.tokens = []; this.index = -1; + this.fetchedEOF = false; }; @@ -280,8 +281,7 @@ BufferedTokenStream.prototype.getHiddenTokensToRight = function(tokenIndex, if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; } - var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, - Lexer.DEFAULT_TOKEN_CHANNEL); + var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL); var from_ = tokenIndex + 1; // if none onchannel to right, nextOnChannel=-1 so set to = last token var to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel; @@ -300,8 +300,7 @@ BufferedTokenStream.prototype.getHiddenTokensToLeft = function(tokenIndex, if (tokenIndex < 0 || tokenIndex >= this.tokens.length) { throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1; } - var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, - Lexer.DEFAULT_TOKEN_CHANNEL); + var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL); if (prevOnChannel === tokenIndex - 1) { return null; } diff --git a/runtime/Python2/src/antlr4/BufferedTokenStream.py b/runtime/Python2/src/antlr4/BufferedTokenStream.py index 570900750..7fec66b44 100644 --- a/runtime/Python2/src/antlr4/BufferedTokenStream.py +++ b/runtime/Python2/src/antlr4/BufferedTokenStream.py @@ -192,7 +192,7 @@ class BufferedTokenStream(TokenStream): self.tokenSource = tokenSource self.tokens = [] self.index = -1 - + self.fetchedEOF = False # Given a starting index, return the index of the next token on channel. diff --git a/runtime/Python3/src/antlr4/BufferedTokenStream.py b/runtime/Python3/src/antlr4/BufferedTokenStream.py index 67f894fab..2d168d27c 100644 --- a/runtime/Python3/src/antlr4/BufferedTokenStream.py +++ b/runtime/Python3/src/antlr4/BufferedTokenStream.py @@ -194,7 +194,7 @@ class BufferedTokenStream(TokenStream): self.tokenSource = tokenSource self.tokens = [] self.index = -1 - + self.fetchedEOF = False # Given a starting index, return the index of the next token on channel.