1 /* 2 * [The "BSD license"] 3 * Copyright (c) 2014 Terence Parr 4 * Copyright (c) 2014 Sam Harwell 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 module antlr.v4.runtime.atn.PredicateEvalInfo; 32 33 import antlr.v4.runtime.TokenStream; 34 import antlr.v4.runtime.atn.ATNConfigSet; 35 import antlr.v4.runtime.atn.DecisionEventInfo; 36 import antlr.v4.runtime.atn.SemanticContext; 37 38 // Class PredicateEvalInfo 39 /** 40 * This class represents profiling event information for semantic predicate 41 * evaluations which occur during prediction. 42 * 43 * @see ParserATNSimulator#evalSemanticContext 44 * 45 * @since 4.3 46 */ 47 class PredicateEvalInfo : DecisionEventInfo 48 { 49 50 /** 51 * The semantic context which was evaluated. 52 */ 53 public SemanticContext semctx; 54 55 /** 56 * The alternative number for the decision which is guarded by the semantic 57 * context {@link #semctx}. Note that other ATN 58 * configurations may predict the same alternative which are guarded by 59 * other semantic contexts and/or {@link SemanticContext#NONE}. 60 */ 61 public int predictedAlt; 62 63 /** 64 * The result of evaluating the semantic context {@link #semctx}. 65 */ 66 public bool evalResult; 67 68 /** 69 * Constructs a new instance of the {@link PredicateEvalInfo} class with the 70 * specified detailed predicate evaluation information. 71 * 72 * @param decision The decision number 73 * @param input The input token stream 74 * @param startIndex The start index for the current prediction 75 * @param stopIndex The index at which the predicate evaluation was 76 * triggered. Note that the input stream may be reset to other positions for 77 * the actual evaluation of individual predicates. 78 * @param semctx The semantic context which was evaluated 79 * @param evalResult The results of evaluating the semantic context 80 * @param predictedAlt The alternative number for the decision which is 81 * guarded by the semantic context {@code semctx}. See {@link #predictedAlt} 82 * for more information. 83 * @param fullCtx {@code true} if the semantic context was 84 * evaluated during LL prediction; otherwise, {@code false} if the semantic 85 * context was evaluated during SLL prediction 86 * 87 * @see ParserATNSimulator#evalSemanticContext(SemanticContext, ParserRuleContext, int, boolean) 88 * @see SemanticContext#eval(Recognizer, RuleContext) 89 */ 90 public this(int decision, TokenStream input, int startIndex, int stopIndex, SemanticContext semctx, 91 bool evalResult, int predictedAlt, bool fullCtx) 92 { 93 super(decision, new ATNConfigSet(), input, startIndex, stopIndex, fullCtx); 94 this.semctx = semctx; 95 this.evalResult = evalResult; 96 this.predictedAlt = predictedAlt; 97 } 98 99 }