Enable running debug mode of ParserATNSimulator

This is to have appropriate logs during debug and avoid crashing in some occasions when startIndex=stopIndex

range(startIndex, stopIndex) is equivalent to an array of values from startIndex to stopIndex-1 thus when startIndex=stopIndex range(startIndex, stopIndex+1) = [startIndex] which is not exactly an interval and would break getText that is expecting an interval as a Tuple.
This commit is contained in:
sinopsysHK 2018-05-16 23:37:21 +08:00
parent 8005cfd090
commit 58ef6bbc96
1 changed files with 3 additions and 3 deletions

View File

@ -1608,7 +1608,7 @@ class ParserATNSimulator(ATNSimulator):
def reportAttemptingFullContext(self, dfa:DFA, conflictingAlts:set, configs:ATNConfigSet, startIndex:int, stopIndex:int):
if ParserATNSimulator.debug or ParserATNSimulator.retry_debug:
interval = range(startIndex, stopIndex + 1)
interval = (startIndex, stopIndex + 1)
print("reportAttemptingFullContext decision=" + str(dfa.decision) + ":" + str(configs) +
", input=" + self.parser.getTokenStream().getText(interval))
if self.parser is not None:
@ -1616,7 +1616,7 @@ class ParserATNSimulator(ATNSimulator):
def reportContextSensitivity(self, dfa:DFA, prediction:int, configs:ATNConfigSet, startIndex:int, stopIndex:int):
if ParserATNSimulator.debug or ParserATNSimulator.retry_debug:
interval = range(startIndex, stopIndex + 1)
interval = (startIndex, stopIndex + 1)
print("reportContextSensitivity decision=" + str(dfa.decision) + ":" + str(configs) +
", input=" + self.parser.getTokenStream().getText(interval))
if self.parser is not None:
@ -1642,7 +1642,7 @@ class ParserATNSimulator(ATNSimulator):
# }
# i++;
# }
interval = range(startIndex, stopIndex + 1)
interval = (startIndex, stopIndex + 1)
print("reportAmbiguity " + str(ambigAlts) + ":" + str(configs) +
", input=" + self.parser.getTokenStream().getText(interval))
if self.parser is not None: