本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: Transition
protected internal Transition(ATNState target)
{
if (target == null)
{
throw new ArgumentNullException("target cannot be null.");
}
this.target = target;
}
示例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;
}
示例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;
}
示例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;
}
示例13: EpsilonTransition
public EpsilonTransition(ATNState target, int outermostPrecedenceReturn)
: base(target)
{
this.outermostPrecedenceReturn = outermostPrecedenceReturn;
}
示例14: AbstractPredicateTransition
public AbstractPredicateTransition(ATNState target) : base(target)
{
}
示例15: DFA
public DFA(ATNState atnStartState)
: this(atnStartState, 0)
{
}