public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, int actionIndex ) { if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None) { if (actionIndex != -1) { return(new ATNConfig.ActionSemanticContextATNConfig(actionIndex, semanticContext, state, alt, context)); } else { return(new ATNConfig.SemanticContextATNConfig(semanticContext, state, alt, context )); } } else { if (actionIndex != -1) { return(new ATNConfig.ActionATNConfig(actionIndex, state, alt, context)); } else { return(new Antlr4.Runtime.Atn.ATNConfig(state, alt, context)); } } }
private Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, int actionIndex) { if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None) { if (actionIndex != -1) { return(new ATNConfig.ActionSemanticContextATNConfig(actionIndex, semanticContext, this, state, context)); } else { return(new ATNConfig.SemanticContextATNConfig(semanticContext, this, state, context )); } } else { if (actionIndex != -1) { return(new ATNConfig.ActionATNConfig(actionIndex, this, state, context)); } else { return(new Antlr4.Runtime.Atn.ATNConfig(this, state, context)); } } }
protected internal override bool EvalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt) { bool result = base.EvalSemanticContext(pred, parserCallStack, alt); if (!(pred is SemanticContext.PrecedencePredicate)) { bool fullContext = _llStopIndex >= 0; int stopIndex = fullContext ? _llStopIndex : _sllStopIndex; decisions[currentDecision].predicateEvals.Add(new PredicateEvalInfo(currentState, currentDecision, _input, _startIndex, stopIndex, pred, result, alt)); } return(result); }
protected override bool EvalSemanticContext(SemanticContext pred, ParserRuleContext parserCallStack, int alt, bool fullCtx) { bool result = base.EvalSemanticContext(pred, parserCallStack, alt, fullCtx); if (!(pred is SemanticContext.PrecedencePredicate)) { bool fullContext = llStopIndex >= 0; int stopIndex = fullContext ? llStopIndex : sllStopIndex; decisions[currentDecision].predicateEvals.Add( new PredicateEvalInfo(null, currentDecision, input, startIndex, stopIndex, pred, result, alt /*, fullCtx*/) ); } return(result); }
public static SemanticContext And(SemanticContext a, SemanticContext b) { if (a == null || a == None) { return(b); } if (b == null || b == None) { return(a); } SemanticContext.AND result = new SemanticContext.AND(a, b); if (result.opnds.Length == 1) { return(result.opnds[0]); } return(result); }
/// <seealso cref="ParserATNSimulator.GetPredsForAmbigAlts(Antlr4.Runtime.Sharpen.BitSet, ATNConfigSet, int)"/> public static SemanticContext Or(SemanticContext a, SemanticContext b) { if (a == null) { return(b); } if (b == null) { return(a); } if (a == None || b == None) { return(None); } SemanticContext.OR result = new SemanticContext.OR(a, b); if (result.opnds.Length == 1) { return(result.opnds[0]); } return(result); }
public override SemanticContext EvalPrecedence <Symbol, ATNInterpreter>(Recognizer <Symbol, ATNInterpreter> parser, RuleContext parserCallStack) { bool differs = false; IList <SemanticContext> operands = new List <SemanticContext>(); foreach (SemanticContext context in opnds) { SemanticContext evaluated = context.EvalPrecedence(parser, parserCallStack); differs |= (evaluated != context); if (evaluated == None) { // The OR context is true if any element is true return(None); } else { if (evaluated != null) { // Reduce the result by skipping false elements operands.Add(evaluated); } } } if (!differs) { return(this); } if (operands.Count == 0) { // all elements were false, so the OR context is false return(null); } SemanticContext result = operands[0]; for (int i = 1; i < operands.Count; i++) { result = SemanticContext.Or(result, operands[i]); } return(result); }
public SemanticContextATNConfig(Antlr4.Runtime.Atn.SemanticContext semanticContext, ATNConfig c, ATNState state, PredictionContext context) : base(c, state, context) { this.semanticContext = semanticContext; }
public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, SemanticContext semanticContext, ATNConfig c, ATNState state, PredictionContext context, bool passedThroughNonGreedyDecision) : base(semanticContext, c, state, context) { this.lexerActionExecutor = lexerActionExecutor; this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision; }
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy) { return(Transform(state, this.context, semanticContext, checkNonGreedy, this.ActionExecutor)); }
private Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext, bool checkNonGreedy, LexerActionExecutor lexerActionExecutor) { bool passedThroughNonGreedy = checkNonGreedy && CheckNonGreedyDecision(this, state); if (semanticContext != Antlr4.Runtime.Atn.SemanticContext.None) { if (lexerActionExecutor != null || passedThroughNonGreedy) { return(new ATNConfig.ActionSemanticContextATNConfig(lexerActionExecutor, semanticContext, this, state, context, passedThroughNonGreedy)); } else { return(new ATNConfig.SemanticContextATNConfig(semanticContext, this, state, context)); } } else { if (lexerActionExecutor != null || passedThroughNonGreedy) { return(new ATNConfig.ActionATNConfig(lexerActionExecutor, this, state, context, passedThroughNonGreedy)); } else { return(new Antlr4.Runtime.Atn.ATNConfig(this, state, context)); } } }
public ActionSemanticContextATNConfig(LexerActionExecutor lexerActionExecutor, [NotNull] SemanticContext semanticContext, [NotNull] ATNState state, int alt, [Nullable] PredictionContext context, bool passedThroughNonGreedyDecision) : base(semanticContext, state, alt, context) { this.lexerActionExecutor = lexerActionExecutor; this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision; }
/// <summary> /// Constructs a new instance of the /// <see cref="PredicateEvalInfo"/> /// class with the /// specified detailed predicate evaluation information. /// </summary> /// <param name="state">The simulator state</param> /// <param name="decision">The decision number</param> /// <param name="input">The input token stream</param> /// <param name="startIndex">The start index for the current prediction</param> /// <param name="stopIndex"> /// The index at which the predicate evaluation was /// triggered. Note that the input stream may be reset to other positions for /// the actual evaluation of individual predicates. /// </param> /// <param name="semctx">The semantic context which was evaluated</param> /// <param name="evalResult">The results of evaluating the semantic context</param> /// <param name="predictedAlt"> /// The alternative number for the decision which is /// guarded by the semantic context /// <paramref name="semctx"/> /// . See /// <see cref="predictedAlt"/> /// for more information. /// </param> /// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, ParserRuleContext, int)"/> /// <seealso cref="SemanticContext.Eval"/> public PredicateEvalInfo(SimulatorState state, int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt) : base(decision, state, input, startIndex, stopIndex, state.useContext) { this.semctx = semctx; this.evalResult = evalResult; this.predictedAlt = predictedAlt; }
public ActionSemanticContextATNConfig(int actionIndex, SemanticContext semanticContext , ATNConfig c, ATNState state, PredictionContext context) : base(semanticContext , c, state, context) { this.actionIndex = actionIndex; }
public Antlr4.Runtime.Atn.ATNConfig Transform(ATNState state, Antlr4.Runtime.Atn.SemanticContext semanticContext) { return(Transform(state, this.context, semanticContext, this.ActionIndex)); }
public static Antlr4.Runtime.Atn.ATNConfig Create(ATNState state, int alt, PredictionContext context, Antlr4.Runtime.Atn.SemanticContext semanticContext) { return(Create(state, alt, context, semanticContext, null)); }
public ATNConfig(ATNConfig c, SemanticContext semanticContext) : this(c, c.state, c.context, semanticContext) { }
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)); } } }
/// <summary> /// Constructs a new instance of the /// <see cref="PredicateEvalInfo"/> /// class with the /// specified detailed predicate evaluation information. /// </summary> /// <param name="decision">The decision number</param> /// <param name="input">The input token stream</param> /// <param name="startIndex">The start index for the current prediction</param> /// <param name="stopIndex"> /// The index at which the predicate evaluation was /// triggered. Note that the input stream may be reset to other positions for /// the actual evaluation of individual predicates. /// </param> /// <param name="semctx">The semantic context which was evaluated</param> /// <param name="evalResult">The results of evaluating the semantic context</param> /// <param name="predictedAlt"> /// The alternative number for the decision which is /// guarded by the semantic context /// <paramref name="semctx"/> /// . See /// <see cref="predictedAlt"/> /// for more information. /// </param> /// <param name="fullCtx">{@code true} if the semantic context was /// evaluated during LL prediction; otherwise, {@code false} if the semantic /// context was evaluated during SLL prediction /// </param> /// /// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, ParserRuleContext, int, bool)"/> /// <seealso cref="SemanticContext.Eval"/> public PredicateEvalInfo(int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt, bool fullCtx) : base(decision, new ATNConfigSet(), input, startIndex, stopIndex, fullCtx) { this.semctx = semctx; this.evalResult = evalResult; this.predictedAlt = predictedAlt; }