forked from jasder/antlr
Merge pull request #1551 from KvanTTT/master
fix 'CommonToken' object has no attribute 'stopIndex' in Python{2|3}
This commit is contained in:
commit
0774117889
|
@ -59,12 +59,12 @@ class ListTokenSource(TokenSource):
|
|||
# have to calculate the result from the line/column of the previous
|
||||
# token, along with the text of the token.
|
||||
lastToken = self.tokens[len(self.tokens) - 1]
|
||||
tokenText = lastToken.getText()
|
||||
tokenText = lastToken.text
|
||||
if tokenText is not None:
|
||||
lastNewLine = tokenText.rfind('\n')
|
||||
if lastNewLine >= 0:
|
||||
return len(tokenText) - lastNewLine - 1
|
||||
return lastToken.column + lastToken.stopIndex - lastToken.startIndex + 1
|
||||
return lastToken.column + lastToken.stop - lastToken.start + 1
|
||||
|
||||
# only reach this if tokens is empty, meaning EOF occurs at the first
|
||||
# position in the input
|
||||
|
@ -78,7 +78,7 @@ class ListTokenSource(TokenSource):
|
|||
if self.eofToken is None:
|
||||
start = -1
|
||||
if len(self.tokens) > 0:
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stopIndex
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stop
|
||||
if previousStop != -1:
|
||||
start = previousStop + 1
|
||||
stop = max(-1, start - 1)
|
||||
|
|
|
@ -59,12 +59,12 @@ class ListTokenSource(TokenSource):
|
|||
# have to calculate the result from the line/column of the previous
|
||||
# token, along with the text of the token.
|
||||
lastToken = self.tokens[len(self.tokens) - 1]
|
||||
tokenText = lastToken.getText()
|
||||
tokenText = lastToken.text
|
||||
if tokenText is not None:
|
||||
lastNewLine = tokenText.rfind('\n')
|
||||
if lastNewLine >= 0:
|
||||
return len(tokenText) - lastNewLine - 1
|
||||
return lastToken.column + lastToken.stopIndex - lastToken.startIndex + 1
|
||||
return lastToken.column + lastToken.stop - lastToken.start + 1
|
||||
|
||||
# only reach this if tokens is empty, meaning EOF occurs at the first
|
||||
# position in the input
|
||||
|
@ -78,7 +78,7 @@ class ListTokenSource(TokenSource):
|
|||
if self.eofToken is None:
|
||||
start = -1
|
||||
if len(self.tokens) > 0:
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stopIndex
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stop
|
||||
if previousStop != -1:
|
||||
start = previousStop + 1
|
||||
stop = max(-1, start - 1)
|
||||
|
|
Loading…
Reference in New Issue