Example #1
0
 def match(self, input:InputStream , mode:int):
     self.mode = mode
     mark = input.mark()
     try:
         self.startIndex = input.index
         self.prevAccept.reset()
         dfa = self.decisionToDFA[mode]
         if dfa.s0 is None:
             return self.matchATN(input)
         else:
             return self.execATN(input, dfa.s0)
     finally:
         input.release(mark)
Example #2
0
 def match(self, input:InputStream , mode:int):
     self.match_calls += 1
     self.mode = mode
     mark = input.mark()
     try:
         self.startIndex = input.index
         self.prevAccept.reset()
         dfa = self.decisionToDFA[mode]
         if dfa.s0 is None:
             return self.matchATN(input)
         else:
             return self.execATN(input, dfa.s0)
     finally:
         input.release(mark)
    def evaluatePredicate(self, input:InputStream, ruleIndex:int, predIndex:int, speculative:bool):
        # assume true if no recognizer was provided
        if self.recog is None:
            return True

        if not speculative:
            return self.recog.sempred(None, ruleIndex, predIndex)

        savedcolumn = self.column
        savedLine = self.line
        index = input.index
        marker = input.mark()
        try:
            self.consume(input)
            return self.recog.sempred(None, ruleIndex, predIndex)
        finally:
            self.column = savedcolumn
            self.line = savedLine
            input.seek(index)
            input.release(marker)