def getDecisionLookahead(self, s:ATNState): if s is None: return None count = len(s.transitions) look = [] * count for alt in range(0, count): look[alt] = set() lookBusy = set() seeThruPreds = False # fail to get lookahead upon pred self._LOOK(s.transition(alt).target, None, PredictionContext.EMPTY, look[alt], lookBusy, set(), seeThruPreds, False) # Wipe out lookahead for this alternative if we found nothing # or we had a predicate when we !seeThruPreds if len(look[alt])==0 or self.HIT_PRED in look[alt]: look[alt] = None return look
def getDecisionLookahead(self, s: ATNState): if s is None: return None count = len(s.transitions) look = [] * count for alt in range(0, count): look[alt] = set() lookBusy = set() seeThruPreds = False # fail to get lookahead upon pred self._LOOK(s.transition(alt).target, None, PredictionContext.EMPTY, \ look[alt], lookBusy, set(), seeThruPreds, False) # Wipe out lookahead for this alternative if we found nothing # or we had a predicate when we !seeThruPreds if len(look[alt]) == 0 or self.HIT_PRED in look[alt]: look[alt] = None return look
def addState(self, state: ATNState): if state is not None: state.atn = self state.stateNumber = len(self.states) self.states.append(state)
def nextTokensNoContext(self, s: ATNState): if s.nextTokenWithinRule is not None: return s.nextTokenWithinRule s.nextTokenWithinRule = self.nextTokensInContext(s, None) s.nextTokenWithinRule.readonly = True return s.nextTokenWithinRule