当前位置: 首页>>代码示例>>C#>>正文


C# Atn.ATNState类代码示例

本文整理汇总了C#中Antlr4.Runtime.Atn.ATNState的典型用法代码示例。如果您正苦于以下问题:C# ATNState类的具体用法?C# ATNState怎么用?C# ATNState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ATNState类属于Antlr4.Runtime.Atn命名空间,在下文中一共展示了ATNState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDecisionLookahead

 public virtual IntervalSet[] GetDecisionLookahead(ATNState s)
 {
     //		System.out.println("LOOK("+s.stateNumber+")");
     if (s == null)
     {
         return null;
     }
     IntervalSet[] look = new IntervalSet[s.NumberOfTransitions];
     for (int alt = 0; alt < s.NumberOfTransitions; alt++)
     {
         look[alt] = new IntervalSet();
         HashSet<ATNConfig> lookBusy = new HashSet<ATNConfig>();
         bool seeThruPreds = false;
         // fail to get lookahead upon pred
         Look(s.Transition(alt).target, null, PredictionContext.EmptyFull, look[alt], lookBusy
             , new BitSet(), seeThruPreds, false);
         // Wipe out lookahead for this alternative if we found nothing
         // or we had a predicate when we !seeThruPreds
         if (look[alt].Size() == 0 || look[alt].Contains(HitPred))
         {
             look[alt] = null;
         }
     }
     return look;
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:25,代码来源:LL1Analyzer.cs

示例2: ATNConfig

 protected internal ATNConfig(ATNState state, int alt, PredictionContext context)
 {
     System.Diagnostics.Debug.Assert((alt & unchecked((int)(0xFFFFFF))) == alt);
     this.state = state;
     this.altAndOuterContextDepth = alt & unchecked((int)(0x7FFFFFFF));
     this.context = context;
 }
开发者ID:nickdurcholz,项目名称:antlr4cs,代码行数:7,代码来源:ATNConfig.cs

示例3: DFA

 public DFA(ATNState atnStartState, int decision)
 {
     this.atnStartState = atnStartState;
     this.decision = decision;
     if (this.atnStartState.atn.grammarType == ATNType.Lexer)
     {
         minDfaEdge = LexerATNSimulator.MinDfaEdge;
         maxDfaEdge = LexerATNSimulator.MaxDfaEdge;
     }
     else
     {
         minDfaEdge = TokenConstants.Eof;
         maxDfaEdge = atnStartState.atn.maxTokenType;
     }
     this.emptyEdgeMap = new Antlr4.Runtime.Dfa.EmptyEdgeMap<DFAState>(minDfaEdge, maxDfaEdge);
     this.emptyContextEdgeMap = new Antlr4.Runtime.Dfa.EmptyEdgeMap<DFAState>(-1, atnStartState.atn.states.Count - 1);
     bool isPrecedenceDfa = false;
     if (atnStartState is StarLoopEntryState)
     {
         if (((StarLoopEntryState)atnStartState).precedenceRuleDecision)
         {
             isPrecedenceDfa = true;
             this.s0.Set(new DFAState(emptyPrecedenceEdges, EmptyContextEdgeMap, new ATNConfigSet()));
             this.s0full.Set(new DFAState(emptyPrecedenceEdges, EmptyContextEdgeMap, new ATNConfigSet()));
         }
     }
     this.precedenceDfa = isPrecedenceDfa;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:28,代码来源:DFA.cs

示例4: Create

 public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, LexerActionExecutor lexerActionExecutor)
 {
     if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None)
     {
         if (lexerActionExecutor != null)
         {
             return new ATNConfig.ActionSemanticContextATNConfig(lexerActionExecutor, semanticContext, state, alt, context, false);
         }
         else
         {
             return new ATNConfig.SemanticContextATNConfig(semanticContext, state, alt, context);
         }
     }
     else
     {
         if (lexerActionExecutor != null)
         {
             return new ATNConfig.ActionATNConfig(lexerActionExecutor, state, alt, context, false);
         }
         else
         {
             return new Antlr4.Runtime.Atn.ATNConfig(state, alt, context);
         }
     }
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:25,代码来源:ATNConfig.cs

示例5: ActionTransition

 public ActionTransition(ATNState target, int ruleIndex, int actionIndex, bool isCtxDependent)
     : base(target)
 {
     // e.g., $i ref in action
     this.ruleIndex = ruleIndex;
     this.actionIndex = actionIndex;
     this.isCtxDependent = isCtxDependent;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:8,代码来源:ActionTransition.cs

示例6: RuleTransition

 public RuleTransition(RuleStartState ruleStart, int ruleIndex, int precedence, ATNState followState)
     : base(ruleStart)
 {
     // no Rule object at runtime
     this.ruleIndex = ruleIndex;
     this.precedence = precedence;
     this.followState = followState;
 }
开发者ID:RainerBosch,项目名称:antlr4,代码行数:8,代码来源:RuleTransition.cs

示例7: ATNConfig

 protected internal ATNConfig(Antlr4.Runtime.Atn.ATNConfig c, ATNState state, PredictionContext
      context)
 {
     this.state = state;
     this.altAndOuterContextDepth = c.altAndOuterContextDepth & unchecked((int)(0x7FFFFFFF
         ));
     this.context = context;
 }
开发者ID:pabloescribano,项目名称:antlr4cs,代码行数:8,代码来源:ATNConfig.cs

示例8: PredicateTransition

 public PredicateTransition(ATNState target, int ruleIndex, int predIndex, bool isCtxDependent)
     : base(target)
 {
     // e.g., $i ref in pred
     this.ruleIndex = ruleIndex;
     this.predIndex = predIndex;
     this.isCtxDependent = isCtxDependent;
 }
开发者ID:RainerBosch,项目名称:antlr4,代码行数:8,代码来源:PredicateTransition.cs

示例9: Transition

 protected internal Transition(ATNState target)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target cannot be null.");
     }
     this.target = target;
 }
开发者ID:antlr,项目名称:antlr4,代码行数:8,代码来源:Transition.cs

示例10: SetTransition

 public SetTransition(ATNState target, IntervalSet set) : base(target)
 {
     // TODO (sam): should we really allow null here?
     if (set == null)
     {
         set = IntervalSet.Of(TokenConstants.InvalidType);
     }
     this.set = set;
 }
开发者ID:pabloescribano,项目名称:antlr4cs,代码行数:9,代码来源:SetTransition.cs

示例11: Check

        /** From state s, look for any transition to a rule that is currently
         *  being traced.  When tracing r, visitedPerRuleCheck has r
         *  initially.  If you reach a rule stop state, return but notify the
         *  invoking rule that the called rule is nullable. This implies that
         *  invoking rule must look at follow transition for that invoking state.
         *
         *  The visitedStates tracks visited states within a single rule so
         *  we can avoid epsilon-loop-induced infinite recursion here.  Keep
         *  filling the cycles in listOfRecursiveCycles and also, as a
         *  side-effect, set leftRecursiveRules.
         */
        public virtual bool Check(Rule enclosingRule, ATNState s, ISet<ATNState> visitedStates)
        {
            if (s is RuleStopState)
                return true;
            if (visitedStates.Contains(s))
                return false;
            visitedStates.Add(s);

            //System.out.println("visit "+s);
            int n = s.NumberOfTransitions;
            bool stateReachesStopState = false;
            for (int i = 0; i < n; i++)
            {
                Transition t = s.Transition(i);
                if (t is RuleTransition)
                {
                    RuleTransition rt = (RuleTransition)t;
                    Rule r = g.GetRule(rt.ruleIndex);
                    if (rulesVisitedPerRuleCheck.Contains((RuleStartState)t.target))
                    {
                        AddRulesToCycle(enclosingRule, r);
                    }
                    else
                    {
                        // must visit if not already visited; mark target, pop when done
                        rulesVisitedPerRuleCheck.Add((RuleStartState)t.target);
                        // send new visitedStates set per rule invocation
                        bool nullable = Check(r, t.target, new HashSet<ATNState>());
                        // we're back from visiting that rule
                        rulesVisitedPerRuleCheck.Remove((RuleStartState)t.target);
                        if (nullable)
                        {
                            stateReachesStopState |= Check(enclosingRule, rt.followState, visitedStates);
                        }
                    }
                }
                else if (t.IsEpsilon)
                {
                    stateReachesStopState |= Check(enclosingRule, t.target, visitedStates);
                }
                // else ignore non-epsilon transitions
            }
            return stateReachesStopState;
        }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:55,代码来源:LeftRecursionDetector.cs

示例12: NextTokens

 public virtual IntervalSet NextTokens(ATNState s)
 {
     if (s.nextTokenWithinRule != null)
     {
         return s.nextTokenWithinRule;
     }
     s.nextTokenWithinRule = NextTokens(s, PredictionContext.EmptyLocal);
     s.nextTokenWithinRule.SetReadonly(true);
     return s.nextTokenWithinRule;
 }
开发者ID:rharrisxtheta,项目名称:antlr4cs,代码行数:10,代码来源:ATN.cs

示例13: EpsilonTransition

 public EpsilonTransition(ATNState target, int outermostPrecedenceReturn)
     : base(target)
 {
     this.outermostPrecedenceReturn = outermostPrecedenceReturn;
 }
开发者ID:RainerBosch,项目名称:antlr4,代码行数:5,代码来源:EpsilonTransition.cs

示例14: AbstractPredicateTransition

 public AbstractPredicateTransition(ATNState target) : base(target)
 {
 }
开发者ID:pabloescribano,项目名称:antlr4cs,代码行数:3,代码来源:AbstractPredicateTransition.cs

示例15: DFA

 public DFA(ATNState atnStartState)
     : this(atnStartState, 0)
 {
 }
开发者ID:RainerBosch,项目名称:antlr4,代码行数:4,代码来源:DFA.cs


注:本文中的Antlr4.Runtime.Atn.ATNState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。