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 /**
39  * This class represents profiling event information for semantic predicate
40  * evaluations which occur during prediction.
41  *
42  * @see ParserATNSimulator#evalSemanticContext
43  *
44  * @since 4.3
45  */
46 class PredicateEvalInfo : DecisionEventInfo
47 {
48 
49     /**
50      * The semantic context which was evaluated.
51      */
52     public SemanticContext semctx;
53 
54     /**
55      * The alternative number for the decision which is guarded by the semantic
56      * context {@link #semctx}. Note that other ATN
57      * configurations may predict the same alternative which are guarded by
58      * other semantic contexts and/or {@link SemanticContext#NONE}.
59      */
60     public int predictedAlt;
61 
62     /**
63      * The result of evaluating the semantic context {@link #semctx}.
64      */
65     public bool evalResult;
66 
67     /**
68      * Constructs a new instance of the {@link PredicateEvalInfo} class with the
69      * specified detailed predicate evaluation information.
70      *
71      *  @param decision The decision number
72      *  @param input The input token stream
73      *  @param startIndex The start index for the current prediction
74      *  @param stopIndex The index at which the predicate evaluation was
75      * triggered. Note that the input stream may be reset to other positions for
76      * the actual evaluation of individual predicates.
77      *  @param semctx The semantic context which was evaluated
78      *  @param evalResult The results of evaluating the semantic context
79      *  @param predictedAlt The alternative number for the decision which is
80      * guarded by the semantic context {@code semctx}. See {@link #predictedAlt}
81      * for more information.
82      *  @param fullCtx {@code true} if the semantic context was
83      * evaluated during LL prediction; otherwise, {@code false} if the semantic
84      * context was evaluated during SLL prediction
85      *
86      *  @see ParserATNSimulator#evalSemanticContext(SemanticContext, ParserRuleContext, int, boolean)
87      *  @see SemanticContext#eval(Recognizer, RuleContext)
88      */
89     public this(int decision, TokenStream input, size_t startIndex, size_t stopIndex, SemanticContext semctx,
90                 bool evalResult, int predictedAlt, bool fullCtx)
91     {
92         super(decision, new ATNConfigSet(), input, startIndex, stopIndex, fullCtx);
93         this.semctx = semctx;
94         this.evalResult = evalResult;
95         this.predictedAlt = predictedAlt;
96     }
97 
98 }