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


Python IntervalSet.addRange方法代碼示例

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


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

示例1: SetTransition

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import addRange [as 別名]
class SetTransition(Transition):
    def __init__(self, target, set):
        super(SetTransition, self).__init__(target)
        self.serializationType = self.SET
        if set is not None:
            self.label = set
        else:
            self.label = IntervalSet()
            self.label.addRange(Interval(Token.INVALID_TYPE, Token.INVALID_TYPE + 1))

    def matches(self, symbol, minVocabSymbol, maxVocabSymbol):
        return symbol in self.label

    def __unicode__(self):
        return unicode(self.label)
開發者ID:antlr,項目名稱:antlr4,代碼行數:17,代碼來源:Transition.py

示例2: SetTransition

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import addRange [as 別名]
class SetTransition(Transition):

    def __init__(self, target:ATNState, set:IntervalSet):
        super().__init__(target)
        self.serializationType = self.SET
        if set is not None:
            self.label = set
        else:
            self.label = IntervalSet()
            self.label.addRange(range(Token.INVALID_TYPE, Token.INVALID_TYPE + 1))

    def matches( self, symbol:int, minVocabSymbol:int,  maxVocabSymbol:int):
        return symbol in self.label

    def __str__(self):
        return str(self.label)
開發者ID:Yuxinghan,項目名稱:antlr4-python3,代碼行數:18,代碼來源:Transition.py

示例3: makeLabel

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import addRange [as 別名]
 def makeLabel(self):
     s = IntervalSet()
     s.addRange(range(self.start, self.stop + 1))
     return s
開發者ID:Yuxinghan,項目名稱:antlr4-python3,代碼行數:6,代碼來源:Transition.py

示例4: _LOOK

# 需要導入模塊: from antlr4.IntervalSet import IntervalSet [as 別名]
# 或者: from antlr4.IntervalSet.IntervalSet import addRange [as 別名]
    def _LOOK(self, s:ATNState, stopState:ATNState , ctx:PredictionContext, look:IntervalSet, lookBusy:set,
                     calledRuleStack:set, seeThruPreds:bool, addEOF:bool):
        c = ATNConfig(s, 0, ctx)

        if c in lookBusy:
            return
        lookBusy.add(c)

        if s == stopState:
            if ctx is None:
                look.addOne(Token.EPSILON)
                return
            elif ctx.isEmpty() and addEOF:
                look.addOne(Token.EOF)
                return

        if isinstance(s, RuleStopState ):
            if ctx is None:
                look.addOne(Token.EPSILON)
                return
            elif ctx.isEmpty() and addEOF:
                look.addOne(Token.EOF)
                return

            if ctx != PredictionContext.EMPTY:
                # run thru all possible stack tops in ctx
                for i in range(0, len(ctx)):
                    returnState = self.atn.states[ctx.getReturnState(i)]
                    removed = returnState.ruleIndex in calledRuleStack
                    try:
                        calledRuleStack.discard(returnState.ruleIndex)
                        self._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF)
                    finally:
                        if removed:
                            calledRuleStack.add(returnState.ruleIndex)
                return

        for t in s.transitions:
            if type(t) == RuleTransition:
                if t.target.ruleIndex in calledRuleStack:
                    continue

                newContext = SingletonPredictionContext.create(ctx, t.followState.stateNumber)

                try:
                    calledRuleStack.add(t.target.ruleIndex)
                    self._LOOK(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF)
                finally:
                    calledRuleStack.remove(t.target.ruleIndex)
            elif isinstance(t, AbstractPredicateTransition ):
                if seeThruPreds:
                    self._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF)
                else:
                    look.addOne(self.HIT_PRED)
            elif t.isEpsilon:
                self._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF)
            elif type(t) == WildcardTransition:
                look.addRange( range(Token.MIN_USER_TOKEN_TYPE, self.atn.maxTokenType + 1) )
            else:
                set_ = t.label
                if set_ is not None:
                    if isinstance(t, NotSetTransition):
                        set_ = set_.complement(Token.MIN_USER_TOKEN_TYPE, self.atn.maxTokenType)
                    look.addSet(set_)
開發者ID:DanMcLaughlin,項目名稱:antlr4,代碼行數:66,代碼來源:LL1Analyzer.py


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