예제 #1
0
 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
예제 #2
0
class XPathLexer(Lexer):

    _serializedATN = \
        "\3\uacf5\uee8c\u4f5d\u8b0d\u4a45\u78bd\u1b2f\u3378\2\n\64\b\1\4\2\t\2" + \
        "\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\3\2\3\2\3" + \
        "\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\7\6\37\n\6\f\6\16\6\"\13\6\3\6\3\6\3\7" + \
        "\3\7\5\7(\n\7\3\b\3\b\3\t\3\t\7\t.\n\t\f\t\16\t\61\13\t\3\t\3\t\3/\n\3" + \
        "\5\1\5\6\1\7\7\1\t\b\1\13\t\2\r\2\1\17\2\1\21\n\1\3\2\4\7\2\62;aa\u00b9" + \
        "\u00b9\u0302\u0371\u2041\u2042\17\2C\\c|\u00c2\u00d8\u00da\u00f8\u00fa" + \
        "\u0301\u0372\u037f\u0381\u2001\u200e\u200f\u2072\u2191\u2c02\u2ff1\u3003" + \
        "\ud801\uf902\ufdd1\ufdf2\uffff\64\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2" + \
        "\2\t\3\2\2\2\2\13\3\2\2\2\2\21\3\2\2\2\3\23\3\2\2\2\5\26\3\2\2\2\7\30" + \
        "\3\2\2\2\t\32\3\2\2\2\13\34\3\2\2\2\r\'\3\2\2\2\17)\3\2\2\2\21+\3\2\2" + \
        "\2\23\24\7\61\2\2\24\25\7\61\2\2\25\4\3\2\2\2\26\27\7\61\2\2\27\6\3\2" + \
        "\2\2\30\31\7,\2\2\31\b\3\2\2\2\32\33\7#\2\2\33\n\3\2\2\2\34 \5\17\b\2" + \
        "\35\37\5\r\7\2\36\35\3\2\2\2\37\"\3\2\2\2 \36\3\2\2\2 !\3\2\2\2!#\3\2" + \
        "\2\2\" \3\2\2\2#$\b\6\2\2$\f\3\2\2\2%(\5\17\b\2&(\t\2\2\2\'%\3\2\2\2\'" + \
        "&\3\2\2\2(\16\3\2\2\2)*\t\3\2\2*\20\3\2\2\2+/\7)\2\2,.\13\2\2\2-,\3\2" + \
        "\2\2.\61\3\2\2\2/\60\3\2\2\2/-\3\2\2\2\60\62\3\2\2\2\61/\3\2\2\2\62\63" + \
        "\7)\2\2\63\22\3\2\2\2\6\2 \'/"

    _ATN = ATNSimulator.deserialize(_serializedATN)

    _decisionToDFA = [ DFA(s) for s in _ATN.decisionToState ]

    _sharedContextCache = PredictionContextCache()

    TOKEN_REF=1
    RULE_REF=2
    ANYWHERE=3
    ROOT=4
    WILDCARD=5
    BANG=6
    ID=7
    STRING=8

    modeNames = [ "DEFAULT_MODE" ]

    tokenNames = ["<INVALID>", "TOKEN_REF", "RULE_REF", "'//'", "'/'", "'*'", "'!'", "ID", "STRING" ]

    ruleNames = [ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar", "NameStartChar", "STRING" ]

    def __init__(self, input:InputStream):
        super().__init__(input)
        self._interp = LexerATNSimulator(self, self._ATN, self._decisionToDFA, self._sharedContextCache)
        self.grammarFileName = "XPathLexer.g4"


    def action(self, localctx:RuleContext, ruleIndex:int, actionIndex:int):
        if ruleIndex==4:
            self.ID_action(localctx, actionIndex)

    def ID_action(self, localctx:RuleContext, actionIndex:int):
        if actionIndex==0:
            text = self.text
            if text[0].isuppercase():
                self._type = self.TOKEN_REF
            else:
                self._type = self.RULE_REF
예제 #3
0
 def __init__(self, grammarFileName, tokenNames, ruleNames, atn, input):
     super(ParserInterpreter, self).__init__(input)
     self.grammarFileName = grammarFileName
     self.atn = atn
     self.tokenNames = tokenNames
     self.ruleNames = ruleNames
     self.decisionToDFA = [ DFA(state) for state in atn.decisionToState ]
     self.sharedContextCache = PredictionContextCache()
     self._parentContextStack = list()
     # identify the ATN states where pushNewRecursionContext must be called
     self.pushRecursionContextStates = set()
     for state in atn.states:
         if not isinstance(state, StarLoopEntryState):
             continue
         if state.isPrecedenceDecision:
             self.pushRecursionContextStates.add(state.stateNumber)
     # get atn simulator that knows how to do predictions
     self._interp = ParserATNSimulator(self, atn, self.decisionToDFA, self.sharedContextCache)