1 /* 2 * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 3 * Use of this file is governed by the BSD 3-clause license that 4 * can be found in the LICENSE.txt file in the project root. 5 */ 6 7 package org.antlr.v4.runtime.atn; 8 9 import org.antlr.v4.runtime.ParserRuleContext; 10 import org.antlr.v4.runtime.Recognizer; 11 import org.antlr.v4.runtime.RuleContext; 12 import org.antlr.v4.runtime.TokenStream; 13 14 /** 15 * This class represents profiling event information for semantic predicate 16 * evaluations which occur during prediction. 17 * 18 * @see ParserATNSimulator#evalSemanticContext 19 * 20 * @since 4.3 21 */ 22 public class PredicateEvalInfo extends DecisionEventInfo { 23 /** 24 * The semantic context which was evaluated. 25 */ 26 public final SemanticContext semctx; 27 /** 28 * The alternative number for the decision which is guarded by the semantic 29 * context {@link #semctx}. Note that other ATN 30 * configurations may predict the same alternative which are guarded by 31 * other semantic contexts and/or {@link SemanticContext#NONE}. 32 */ 33 public final int predictedAlt; 34 /** 35 * The result of evaluating the semantic context {@link #semctx}. 36 */ 37 public final boolean evalResult; 38 39 /** 40 * Constructs a new instance of the {@link PredicateEvalInfo} class with the 41 * specified detailed predicate evaluation information. 42 * 43 * @param decision The decision number 44 * @param input The input token stream 45 * @param startIndex The start index for the current prediction 46 * @param stopIndex The index at which the predicate evaluation was 47 * triggered. Note that the input stream may be reset to other positions for 48 * the actual evaluation of individual predicates. 49 * @param semctx The semantic context which was evaluated 50 * @param evalResult The results of evaluating the semantic context 51 * @param predictedAlt The alternative number for the decision which is 52 * guarded by the semantic context {@code semctx}. See {@link #predictedAlt} 53 * for more information. 54 * @param fullCtx {@code true} if the semantic context was 55 * evaluated during LL prediction; otherwise, {@code false} if the semantic 56 * context was evaluated during SLL prediction 57 * 58 * @see ParserATNSimulator#evalSemanticContext(SemanticContext, ParserRuleContext, int, boolean) 59 * @see SemanticContext#eval(Recognizer, RuleContext) 60 */ PredicateEvalInfo(int decision, TokenStream input, int startIndex, int stopIndex, SemanticContext semctx, boolean evalResult, int predictedAlt, boolean fullCtx)61 public PredicateEvalInfo(int decision, 62 TokenStream input, int startIndex, int stopIndex, 63 SemanticContext semctx, 64 boolean evalResult, 65 int predictedAlt, 66 boolean fullCtx) 67 { 68 super(decision, new ATNConfigSet(), input, startIndex, stopIndex, fullCtx); 69 this.semctx = semctx; 70 this.evalResult = evalResult; 71 this.predictedAlt = predictedAlt; 72 } 73 } 74