]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/atn/AmbiguityInfo.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / atn / AmbiguityInfo.h
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #pragma once
7
8 #include "atn/DecisionEventInfo.h"
9 #include "support/BitSet.h"
10
11 namespace antlr4 {
12 namespace atn {
13
14   /// <summary>
15   /// This class represents profiling event information for an ambiguity.
16   /// Ambiguities are decisions where a particular input resulted in an SLL
17   /// conflict, followed by LL prediction also reaching a conflict state
18   /// (indicating a true ambiguity in the grammar).
19   ///
20   /// <para>
21   /// This event may be reported during SLL prediction in cases where the
22   /// conflicting SLL configuration set provides sufficient information to
23   /// determine that the SLL conflict is truly an ambiguity. For example, if none
24   /// of the ATN configurations in the conflicting SLL configuration set have
25   /// traversed a global follow transition (i.e.
26   /// <seealso cref="ATNConfig#reachesIntoOuterContext"/> is 0 for all configurations), then
27   /// the result of SLL prediction for that input is known to be equivalent to the
28   /// result of LL prediction for that input.</para>
29   ///
30   /// <para>
31   /// In some cases, the minimum represented alternative in the conflicting LL
32   /// configuration set is not equal to the minimum represented alternative in the
33   /// conflicting SLL configuration set. Grammars and inputs which result in this
34   /// scenario are unable to use <seealso cref="PredictionMode#SLL"/>, which in turn means
35   /// they cannot use the two-stage parsing strategy to improve parsing performance
36   /// for that input.</para>
37   /// </summary>
38   /// <seealso cref= ParserATNSimulator#reportAmbiguity </seealso>
39   /// <seealso cref= ANTLRErrorListener#reportAmbiguity
40   ///
41   /// @since 4.3 </seealso>
42   class ANTLR4CPP_PUBLIC AmbiguityInfo : public DecisionEventInfo {
43   public:
44     /// The set of alternative numbers for this decision event that lead to a valid parse.
45     antlrcpp::BitSet ambigAlts;
46
47     /// <summary>
48     /// Constructs a new instance of the <seealso cref="AmbiguityInfo"/> class with the
49     /// specified detailed ambiguity information.
50     /// </summary>
51     /// <param name="decision"> The decision number </param>
52     /// <param name="configs"> The final configuration set identifying the ambiguous
53     /// alternatives for the current input </param>
54     /// <param name="ambigAlts"> The set of alternatives in the decision that lead to a valid parse.
55     ///                  The predicted alt is the min(ambigAlts) </param>
56     /// <param name="input"> The input token stream </param>
57     /// <param name="startIndex"> The start index for the current prediction </param>
58     /// <param name="stopIndex"> The index at which the ambiguity was identified during
59     /// prediction </param>
60     /// <param name="fullCtx"> {@code true} if the ambiguity was identified during LL
61     /// prediction; otherwise, {@code false} if the ambiguity was identified
62     /// during SLL prediction </param>
63     AmbiguityInfo(size_t decision, ATNConfigSet *configs, const antlrcpp::BitSet &ambigAlts, TokenStream *input,
64                   size_t startIndex, size_t stopIndex, bool fullCtx);
65   };
66
67 } // namespace atn
68 } // namespace antlr4