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


C# PredictionContext.GetChild方法代码示例

本文整理汇总了C#中PredictionContext.GetChild方法的典型用法代码示例。如果您正苦于以下问题:C# PredictionContext.GetChild方法的具体用法?C# PredictionContext.GetChild怎么用?C# PredictionContext.GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PredictionContext的用法示例。


在下文中一共展示了PredictionContext.GetChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetChild

 public virtual PredictionContext GetChild(PredictionContext context, int invokingState)
 {
     if (!enableCache)
     {
         return context.GetChild(invokingState);
     }
     PredictionContextCache.PredictionContextAndInt operands = new PredictionContextCache.PredictionContextAndInt(context, invokingState);
     PredictionContext result;
     if (!childContexts.TryGetValue(operands, out result))
     {
         result = context.GetChild(invokingState);
         result = GetAsCached(result);
         childContexts[operands] = result;
     }
     return result;
 }
开发者ID:sharwell,项目名称:antlr4cs,代码行数:16,代码来源:PredictionContextCache.cs

示例2: Look


//.........这里部分代码省略.........
                 look.Add(TokenConstants.Eof);
                 return;
             }
         }
         for (int i = 0; i < ctx.Size; i++)
         {
             if (ctx.GetReturnState(i) != PredictionContext.EmptyFullStateKey)
             {
                 ATNState returnState = atn.states[ctx.GetReturnState(i)];
                 //					System.out.println("popping back to "+retState);
                 for (int j = 0; j < ctx.Size; j++)
                 {
                     bool removed = calledRuleStack.Get(returnState.ruleIndex);
                     try
                     {
                         calledRuleStack.Clear(returnState.ruleIndex);
                         Look(returnState, stopState, ctx.GetParent(j), look, lookBusy, calledRuleStack, seeThruPreds
                             , addEOF);
                     }
                     finally
                     {
                         if (removed)
                         {
                             calledRuleStack.Set(returnState.ruleIndex);
                         }
                     }
                 }
                 return;
             }
         }
     }
     int n = s.NumberOfTransitions;
     for (int i_1 = 0; i_1 < n; i_1++)
     {
         Transition t = s.Transition(i_1);
         if (t.GetType() == typeof(RuleTransition))
         {
             if (calledRuleStack.Get(((RuleTransition)t).target.ruleIndex))
             {
                 continue;
             }
             PredictionContext newContext = ctx.GetChild(((RuleTransition)t).followState.stateNumber
                 );
             try
             {
                 calledRuleStack.Set(((RuleTransition)t).target.ruleIndex);
                 Look(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds
                     , addEOF);
             }
             finally
             {
                 calledRuleStack.Clear(((RuleTransition)t).target.ruleIndex);
             }
         }
         else
         {
             if (t is AbstractPredicateTransition)
             {
                 if (seeThruPreds)
                 {
                     Look(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF
                         );
                 }
                 else
                 {
                     look.Add(HitPred);
                 }
             }
             else
             {
                 if (t.IsEpsilon)
                 {
                     Look(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF
                         );
                 }
                 else
                 {
                     if (t.GetType() == typeof(WildcardTransition))
                     {
                         look.AddAll(IntervalSet.Of(TokenConstants.MinUserTokenType, atn.maxTokenType));
                     }
                     else
                     {
                         //				System.out.println("adding "+ t);
                         IntervalSet set = t.Label;
                         if (set != null)
                         {
                             if (t is NotSetTransition)
                             {
                                 set = set.Complement(IntervalSet.Of(TokenConstants.MinUserTokenType, atn.maxTokenType
                                     ));
                             }
                             look.AddAll(set);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:101,代码来源:LL1Analyzer.cs


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