本文整理汇总了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