def computeStartState(self, input: InputStream, p: ATNState): initialContext = PredictionContext.EMPTY configs = OrderedATNConfigSet() for i in range(0, len(p.transitions)): target = p.transitions[i].target c = LexerATNConfig(state=target, alt=i + 1, context=initialContext) self.closure(input, c, configs, False, False, False) return configs
def computeTargetState(self, input: InputStream, s: DFAState, t: int): reach = OrderedATNConfigSet() # if we don't find an existing DFA state # Fill reach starting from closure, following t transitions self.getReachableConfigSet(input, s.configs, reach, t) if len(reach) == 0: # we got nowhere on t from s if not reach.hasSemanticContext: # we got nowhere on t, don't throw out this knowledge; it'd # cause a failover from DFA later. self.addDFAEdge(s, t, self.ERROR) # stop when we can't match any more char return self.ERROR # Add an edge from s to target DFA found/created for reach return self.addDFAEdge(s, t, cfgs=reach)