本文整理匯總了Python中antlr4.IntervalSet.IntervalSet.remove方法的典型用法代碼示例。如果您正苦於以下問題:Python IntervalSet.remove方法的具體用法?Python IntervalSet.remove怎麽用?Python IntervalSet.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類antlr4.IntervalSet.IntervalSet
的用法示例。
在下文中一共展示了IntervalSet.remove方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getErrorRecoverySet
# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import remove [as 別名]
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
示例2: getExpectedTokens
# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import remove [as 別名]
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