fix invalid test sequence

This commit is contained in:
Eric Vergnaud 2019-01-01 13:31:01 +01:00
parent cccf6e87da
commit 3ad118f87e
2 changed files with 12 additions and 12 deletions

View File

@ -276,14 +276,14 @@ class BufferedTokenStream(TokenStream):
"""
self.lazyInit()
self.fill()
if start is None:
start = 0
elif isinstance(start, Token):
if isinstance(start, Token):
start = start.tokenIndex
if stop is None or stop >= len(self.tokens):
stop = len(self.tokens) - 1
elif isinstance(stop, Token):
elif start is None:
start = 0
if isinstance(stop, Token):
stop = stop.tokenIndex
elif stop is None or stop >= len(self.tokens):
stop = len(self.tokens) - 1
if start < 0 or stop < 0 or stop<start:
return ""
with StringIO() as buf:

View File

@ -275,14 +275,14 @@ class BufferedTokenStream(TokenStream):
def getText(self, start:int=None, stop:int=None):
self.lazyInit()
self.fill()
if start is None:
start = 0
elif isinstance(start, Token):
if isinstance(start, Token):
start = start.tokenIndex
if stop is None or stop >= len(self.tokens):
stop = len(self.tokens) - 1
elif isinstance(stop, Token):
elif start is None:
start = 0
if isinstance(stop, Token):
stop = stop.tokenIndex
elif stop is None or stop >= len(self.tokens):
stop = len(self.tokens) - 1
if start < 0 or stop < 0 or stop < start:
return ""
with StringIO() as buf: