Merge pull request #1616 from ericvergnaud/fix-#1584-other-targets
fix #1584 for C#, JavaScript and Python targets
This commit is contained in:
commit
7f0c990645
|
@ -371,6 +371,7 @@ namespace Antlr4.Runtime
|
||||||
this._tokenSource = tokenSource;
|
this._tokenSource = tokenSource;
|
||||||
tokens.Clear();
|
tokens.Clear();
|
||||||
p = -1;
|
p = -1;
|
||||||
|
this.fetchedEOF = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IList<IToken> GetTokens()
|
public virtual IList<IToken> GetTokens()
|
||||||
|
|
|
@ -234,6 +234,7 @@ BufferedTokenStream.prototype.setTokenSource = function(tokenSource) {
|
||||||
this.tokenSource = tokenSource;
|
this.tokenSource = tokenSource;
|
||||||
this.tokens = [];
|
this.tokens = [];
|
||||||
this.index = -1;
|
this.index = -1;
|
||||||
|
this.fetchedEOF = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,8 +281,7 @@ BufferedTokenStream.prototype.getHiddenTokensToRight = function(tokenIndex,
|
||||||
if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
|
if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
|
||||||
throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
|
throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
|
||||||
}
|
}
|
||||||
var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1,
|
var nextOnChannel = this.nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL);
|
||||||
Lexer.DEFAULT_TOKEN_CHANNEL);
|
|
||||||
var from_ = tokenIndex + 1;
|
var from_ = tokenIndex + 1;
|
||||||
// if none onchannel to right, nextOnChannel=-1 so set to = last token
|
// if none onchannel to right, nextOnChannel=-1 so set to = last token
|
||||||
var to = nextOnChannel === -1 ? this.tokens.length - 1 : nextOnChannel;
|
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) {
|
if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
|
||||||
throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
|
throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;
|
||||||
}
|
}
|
||||||
var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1,
|
var prevOnChannel = this.previousTokenOnChannel(tokenIndex - 1, Lexer.DEFAULT_TOKEN_CHANNEL);
|
||||||
Lexer.DEFAULT_TOKEN_CHANNEL);
|
|
||||||
if (prevOnChannel === tokenIndex - 1) {
|
if (prevOnChannel === tokenIndex - 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ class BufferedTokenStream(TokenStream):
|
||||||
self.tokenSource = tokenSource
|
self.tokenSource = tokenSource
|
||||||
self.tokens = []
|
self.tokens = []
|
||||||
self.index = -1
|
self.index = -1
|
||||||
|
self.fetchedEOF = False
|
||||||
|
|
||||||
|
|
||||||
# Given a starting index, return the index of the next token on channel.
|
# Given a starting index, return the index of the next token on channel.
|
||||||
|
|
|
@ -194,7 +194,7 @@ class BufferedTokenStream(TokenStream):
|
||||||
self.tokenSource = tokenSource
|
self.tokenSource = tokenSource
|
||||||
self.tokens = []
|
self.tokens = []
|
||||||
self.index = -1
|
self.index = -1
|
||||||
|
self.fetchedEOF = False
|
||||||
|
|
||||||
|
|
||||||
# Given a starting index, return the index of the next token on channel.
|
# Given a starting index, return the index of the next token on channel.
|
||||||
|
|
Loading…
Reference in New Issue