From 3e6767088db0a794a6288e62082ec1eab33c9ad7 Mon Sep 17 00:00:00 2001 From: Patrick Stahl Date: Tue, 21 Jan 2025 19:52:07 +0100 Subject: [PATCH 1/2] fix set access in ParserInterpreter.py Signed-off-by: Patrick Stahl --- runtime/Python3/src/antlr4/ParserInterpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Python3/src/antlr4/ParserInterpreter.py b/runtime/Python3/src/antlr4/ParserInterpreter.py index 5525eff3a9..e775a5708f 100644 --- a/runtime/Python3/src/antlr4/ParserInterpreter.py +++ b/runtime/Python3/src/antlr4/ParserInterpreter.py @@ -108,7 +108,7 @@ def visitState(self, p:ATNState): tt = transition.serializationType if tt==Transition.EPSILON: - if self.pushRecursionContextStates[p.stateNumber] and not isinstance(transition.target, LoopEndState): + if p.stateNumber in self.pushRecursionContextStates and not isinstance(transition.target, LoopEndState): t = self._parentContextStack[-1] ctx = InterpreterRuleContext(t[0], t[1], self._ctx.ruleIndex) self.pushNewRecursionContext(ctx, self.atn.ruleToStartState[p.ruleIndex].stateNumber, self._ctx.ruleIndex) From e2d0dd86ba66c2319943fea751edeb06092cbf0f Mon Sep 17 00:00:00 2001 From: Patrick Stahl Date: Tue, 21 Jan 2025 20:03:15 +0100 Subject: [PATCH 2/2] fix set access in ParserInterpreter.py Signed-off-by: Patrick Stahl --- runtime/Python3/src/antlr4/ParserInterpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Python3/src/antlr4/ParserInterpreter.py b/runtime/Python3/src/antlr4/ParserInterpreter.py index e775a5708f..e7f55fb181 100644 --- a/runtime/Python3/src/antlr4/ParserInterpreter.py +++ b/runtime/Python3/src/antlr4/ParserInterpreter.py @@ -58,7 +58,7 @@ def __init__(self, grammarFileName:str, tokenNames:list, ruleNames:list, atn:ATN self._interp = ParserATNSimulator(self, atn, self.decisionToDFA, self.sharedContextCache) # Begin parsing at startRuleIndex# - def parse(self, startRuleIndex:int): + def parse(self, startRuleIndex:int): startRuleStartState = self.atn.ruleToStartState[startRuleIndex] rootContext = InterpreterRuleContext(None, ATNState.INVALID_STATE_NUMBER, startRuleIndex) if startRuleStartState.isPrecedenceRule: