當前位置: 首頁>>代碼示例>>Python>>正文


Python IntervalSet.removeOne方法代碼示例

本文整理匯總了Python中antlr4.IntervalSet.IntervalSet.removeOne方法的典型用法代碼示例。如果您正苦於以下問題:Python IntervalSet.removeOne方法的具體用法?Python IntervalSet.removeOne怎麽用?Python IntervalSet.removeOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在antlr4.IntervalSet.IntervalSet的用法示例。


在下文中一共展示了IntervalSet.removeOne方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getErrorRecoverySet

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import removeOne [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.removeOne(Token.EPSILON)
     return recoverSet
開發者ID:lecode-official,項目名稱:antlr4,代碼行數:15,代碼來源:ErrorStrategy.py

示例2: getExpectedTokens

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import removeOne [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.removeOne(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.removeOne(Token.EPSILON)
         ctx = ctx.parentCtx
     if Token.EPSILON in following:
         expected.addOne(Token.EOF)
     return expected
開發者ID:CodeGrimoire,項目名稱:antlr4,代碼行數:22,代碼來源:ATN.py


注:本文中的antlr4.IntervalSet.IntervalSet.removeOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。