本文整理汇总了C#中PredictionContext类的典型用法代码示例。如果您正苦于以下问题:C# PredictionContext类的具体用法?C# PredictionContext怎么用?C# PredictionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PredictionContext类属于命名空间,在下文中一共展示了PredictionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: SingletonPredictionContext
internal SingletonPredictionContext(PredictionContext parent, int returnState)
: base(CalculateHashCode(parent, returnState))
{
System.Diagnostics.Debug.Assert(returnState != EmptyFullStateKey && returnState != EmptyLocalStateKey);
this.parent = parent;
this.returnState = returnState;
}
示例3: 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;
}
示例4: ArrayPredictionContext
internal ArrayPredictionContext(PredictionContext[] parents, int[] returnStates, int hashCode)
: base(hashCode)
{
System.Diagnostics.Debug.Assert(parents.Length == returnStates.Length);
System.Diagnostics.Debug.Assert(returnStates.Length > 1 || returnStates[0] != EmptyFullStateKey, "Should be using PredictionContext.EMPTY instead.");
this.parents = parents;
this.returnStates = returnStates;
}
示例5: 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;
}
示例6: Create
public static PredictionContext Create(PredictionContext parent, int returnState)
{
if (returnState == EMPTY_RETURN_STATE && parent == null)
{
// someone can pass in the bits of an array ctx that mean $
return PredictionContext.EMPTY;
}
return new SingletonPredictionContext(parent, returnState);
}
示例7: Put
public void Put(PredictionContext a, PredictionContext b, PredictionContext value)
{
Dictionary<PredictionContext, PredictionContext> first;
if (!data.TryGetValue(a, out first))
{
first = new Dictionary<PredictionContext, PredictionContext>();
data[a] = first;
}
first[b] = value;
}
示例8: Get
public PredictionContext Get(PredictionContext a, PredictionContext b)
{
Dictionary<PredictionContext, PredictionContext> first;
if (!data.TryGetValue(a, out first))
return null;
PredictionContext value;
if (first.TryGetValue(b, out value))
return value;
else
return null;
}
示例9: Add
/** Add a context to the cache and return it. If the context already exists,
* return that one instead and do not add a new context to the cache.
* Protect shared cache from unsafe thread access.
*/
public PredictionContext Add(PredictionContext ctx)
{
if (ctx == PredictionContext.EMPTY)
return PredictionContext.EMPTY;
PredictionContext existing = cache.Get(ctx);
if (existing != null)
{
return existing;
}
cache.Put(ctx, ctx);
return ctx;
}
示例10: getCachedContext
public PredictionContext getCachedContext(PredictionContext context)
{
if (sharedContextCache == null) return context;
lock (sharedContextCache)
{
PredictionContext.IdentityHashMap visited =
new PredictionContext.IdentityHashMap();
return PredictionContext.GetCachedContext(context,
sharedContextCache,
visited);
}
}
示例11: GetAsCached
public virtual PredictionContext GetAsCached(PredictionContext context)
{
if (!enableCache)
{
return context;
}
PredictionContext result;
if (!contexts.TryGetValue(context, out result))
{
result = context;
contexts[context] = context;
}
return result;
}
示例12: 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;
}
示例13: Join
public virtual PredictionContext Join(PredictionContext x, PredictionContext y)
{
if (!enableCache)
{
return PredictionContext.Join(x, y, this);
}
PredictionContextCache.IdentityCommutativePredictionContextOperands operands = new PredictionContextCache.IdentityCommutativePredictionContextOperands(x, y);
PredictionContext result;
if (joinContexts.TryGetValue(operands, out result))
{
return result;
}
result = PredictionContext.Join(x, y, this);
result = GetAsCached(result);
joinContexts[operands] = result;
return result;
}
示例14: Look
public virtual IntervalSet Look(ATNState s, PredictionContext ctx)
{
return Look(s, null, ctx);
}
示例15: AppendContext
public override PredictionContext AppendContext(PredictionContext suffix, PredictionContextCache
contextCache)
{
return suffix;
}