本文整理汇总了C#中Antlr4.Runtime.Atn.ATNState类的典型用法代码示例。如果您正苦于以下问题:C# ATNState类的具体用法?C# ATNState怎么用?C# ATNState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ATNState类属于Antlr4.Runtime.Atn命名空间,在下文中一共展示了ATNState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ComputeStartState
protected internal virtual ATNConfigSet ComputeStartState(ICharStream input, ATNState
p)
{
PredictionContext initialContext = PredictionContext.EmptyFull;
ATNConfigSet configs = new OrderedATNConfigSet();
for (int i = 0; i < p.NumberOfTransitions; i++)
{
ATNState target = p.Transition(i).target;
ATNConfig c = ATNConfig.Create(target, i + 1, initialContext);
Closure(input, c, configs, false);
}
return configs;
}
开发者ID:hustsii,项目名称:antlr4cs,代码行数:13,代码来源:LexerATNSimulator.cs
示例17: NotSetTransition
public NotSetTransition(ATNState target, IntervalSet set) : base(target, set)
{
}
开发者ID:pabloescribano,项目名称:antlr4cs,代码行数:3,代码来源:NotSetTransition.cs
示例18: ComputeStartState
protected ATNConfigSet ComputeStartState(ATNState p,
RuleContext ctx,
bool fullCtx)
{
// always at least the implicit call to start rule
PredictionContext initialContext = PredictionContext.FromRuleContext(atn, ctx);
ATNConfigSet configs = new ATNConfigSet(fullCtx);
for (int i = 0; i < p.NumberOfTransitions; i++)
{
ATNState target = p.Transition(i).target;
ATNConfig c = new ATNConfig(target, i + 1, initialContext);
HashSet<ATNConfig> closureBusy = new HashSet<ATNConfig>();
Closure(c, configs, closureBusy, true, fullCtx, false);
}
return configs;
}
开发者ID:antlr,项目名称:antlr4,代码行数:18,代码来源:ParserATNSimulator.cs
示例19: VisitState
protected internal virtual void VisitState(ATNState p)
{
int edge;
if (p.NumberOfTransitions > 1)
{
ErrorHandler.Sync(this);
edge = Interpreter.AdaptivePredict(_input, ((DecisionState)p).decision, _ctx);
}
else
{
edge = 1;
}
Transition transition = p.Transition(edge - 1);
switch (transition.TransitionType)
{
case TransitionType.Epsilon:
{
if (pushRecursionContextStates.Get(p.stateNumber) && !(transition.target is LoopEndState))
{
InterpreterRuleContext ctx = new InterpreterRuleContext(_parentContextStack.Peek().Item1, _parentContextStack.Peek().Item2, _ctx.RuleIndex);
PushNewRecursionContext(ctx, atn.ruleToStartState[p.ruleIndex].stateNumber, _ctx.RuleIndex);
}
break;
}
case TransitionType.Atom:
{
Match(((AtomTransition)transition).label);
break;
}
case TransitionType.Range:
case TransitionType.Set:
case TransitionType.NotSet:
{
if (!transition.Matches(_input.La(1), TokenConstants.MinUserTokenType, 65535))
{
_errHandler.RecoverInline(this);
}
MatchWildcard();
break;
}
case TransitionType.Wildcard:
{
MatchWildcard();
break;
}
case TransitionType.Rule:
{
RuleStartState ruleStartState = (RuleStartState)transition.target;
int ruleIndex = ruleStartState.ruleIndex;
InterpreterRuleContext ctx_1 = new InterpreterRuleContext(_ctx, p.stateNumber, ruleIndex);
if (ruleStartState.isPrecedenceRule)
{
EnterRecursionRule(ctx_1, ruleStartState.stateNumber, ruleIndex, ((RuleTransition)transition).precedence);
}
else
{
EnterRule(ctx_1, transition.target.stateNumber, ruleIndex);
}
break;
}
case TransitionType.Predicate:
{
PredicateTransition predicateTransition = (PredicateTransition)transition;
if (!Sempred(_ctx, predicateTransition.ruleIndex, predicateTransition.predIndex))
{
throw new FailedPredicateException(this);
}
break;
}
case TransitionType.Action:
{
ActionTransition actionTransition = (ActionTransition)transition;
Action(_ctx, actionTransition.ruleIndex, actionTransition.actionIndex);
break;
}
case TransitionType.Precedence:
{
if (!Precpred(_ctx, ((PrecedencePredicateTransition)transition).precedence))
{
throw new FailedPredicateException(this, string.Format("precpred(_ctx, {0})", ((PrecedencePredicateTransition)transition).precedence));
}
break;
}
default:
{
throw new NotSupportedException("Unrecognized ATN transition type.");
}
}
State = transition.target.stateNumber;
}
开发者ID:nickdurcholz,项目名称:antlr4cs,代码行数:98,代码来源:ParserInterpreter.cs
示例20: AddState
public virtual void AddState(ATNState state)
{
if (state != null)
{
state.atn = this;
state.stateNumber = states.Count;
}
states.Add(state);
}
开发者ID:rharrisxtheta,项目名称:antlr4cs,代码行数:9,代码来源:ATN.cs
注:本文中的Antlr4.Runtime.Atn.ATNState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论