class XPathLexer(Lexer): atn = ATNDeserializer().deserialize(serializedATN()) decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)] TOKEN_REF = 1 RULE_REF = 2 ANYWHERE = 3 ROOT = 4 WILDCARD = 5 BANG = 6 ID = 7 STRING = 8 modeNames = ["DEFAULT_MODE"] literalNames = ["<INVALID>", "'//'", "'/'", "'*'", "'!'"] symbolicNames = [ "<INVALID>", "TOKEN_REF", "RULE_REF", "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "STRING" ] ruleNames = [ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar", "NameStartChar", "STRING" ] grammarFileName = "XPathLexer.g4" def __init__(self, input=None): super().__init__(input) self.checkVersion("4.6") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None def action(self, localctx: RuleContext, ruleIndex: int, actionIndex: int): if self._actions is None: actions = dict() actions[4] = self.ID_action self._actions = actions _action = self._actions.get(ruleIndex, None) if _action is not None: _action(localctx, actionIndex) else: raise Exception("No registered action for:" + str(ruleIndex)) def ID_action(self, localctx: RuleContext, actionIndex: int): if actionIndex == 0: char = self.text[0] if char.isupper(): self.type = XPathLexer.TOKEN_REF else: self.type = XPathLexer.RULE_REF
def getATNWithBypassAlts(self): serializedAtn = self.getSerializedATN() if serializedAtn is None: raise UnsupportedOperationException("The current parser does not support an ATN with bypass alternatives.") result = self.bypassAltsAtnCache.get(serializedAtn, None) if result is None: deserializationOptions = ATNDeserializationOptions() deserializationOptions.generateRuleBypassTransitions = True result = ATNDeserializer(deserializationOptions).deserialize(serializedAtn) self.bypassAltsAtnCache[serializedAtn] = result return result