def getErrorRecoverySet(self, recognizer:Parser): atn = recognizer._interp.atn ctx = recognizer._ctx recoverSet = IntervalSet() while ctx is not None and ctx.invokingState>=0: # compute what follows who invoked us invokingState = atn.states[ctx.invokingState] rt = invokingState.transitions[0] follow = atn.nextTokens(rt.followState) recoverSet.addSet(follow) ctx = ctx.parentCtx recoverSet.remove(Token.EPSILON) return recoverSet
def getErrorRecoverySet(self, recognizer): atn = recognizer._interp.atn ctx = recognizer._ctx recoverSet = IntervalSet() while ctx is not None and ctx.invokingState>=0: # compute what follows who invoked us invokingState = atn.states[ctx.invokingState] rt = invokingState.transitions[0] follow = atn.nextTokens(rt.followState) recoverSet.addSet(follow) ctx = ctx.parentCtx recoverSet.remove(Token.EPSILON) return recoverSet
def getExpectedTokens(self, stateNumber: int, ctx: RuleContext): if stateNumber < 0 or stateNumber >= len(self.states): raise Exception("Invalid state number.") s = self.states[stateNumber] following = self.nextTokens(s) if Token.EPSILON not in following: return following expected = IntervalSet() expected.addSet(following) expected.remove(Token.EPSILON) while ctx != None and ctx.invokingState >= 0 and Token.EPSILON in following: invokingState = self.states[ctx.invokingState] rt = invokingState.transitions[0] following = self.nextTokens(rt.followState) expected.addSet(following) expected.remove(Token.EPSILON) ctx = ctx.parentCtx if Token.EPSILON in following: expected.addOne(Token.EOF) return expected
def getExpectedTokens(self, stateNumber, ctx): if stateNumber < 0 or stateNumber >= len(self.states): raise Exception("Invalid state number.") s = self.states[stateNumber] following = self.nextTokens(s) if Token.EPSILON not in following: return following expected = IntervalSet() expected.addSet(following) expected.remove(Token.EPSILON) while (ctx != None and ctx.invokingState >= 0 and Token.EPSILON in following): invokingState = self.states[ctx.invokingState] rt = invokingState.transitions[0] following = self.nextTokens(rt.followState) expected.addSet(following) expected.remove(Token.EPSILON) ctx = ctx.parentCtx if Token.EPSILON in following: expected.addOne(Token.EOF) return expected