本文整理汇总了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;
}
示例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);
}
}
}
}
}
}
}