]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/NoViableAltException.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / NoViableAltException.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 "RecognitionException.h"
9 #include "Token.h"
10 #include "atn/ATNConfigSet.h"
11
12 namespace antlr4 {
13
14   /// Indicates that the parser could not decide which of two or more paths
15   /// to take based upon the remaining input. It tracks the starting token
16   /// of the offending input and also knows where the parser was
17   /// in the various paths when the error. Reported by reportNoViableAlternative()
18   class ANTLR4CPP_PUBLIC NoViableAltException : public RecognitionException {
19   public:
20     NoViableAltException(Parser *recognizer); // LL(1) error
21     NoViableAltException(Parser *recognizer, TokenStream *input,Token *startToken,
22       Token *offendingToken, atn::ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx, bool deleteConfigs);
23     ~NoViableAltException();
24     
25     virtual Token* getStartToken() const;
26     virtual atn::ATNConfigSet* getDeadEndConfigs() const;
27
28   private:
29     /// Which configurations did we try at input.index() that couldn't match input.LT(1)?
30     /// Shared pointer that conditionally deletes the configurations (based on flag
31     /// passed during construction)
32     Ref<atn::ATNConfigSet> _deadEndConfigs;
33
34     /// The token object at the start index; the input stream might
35     /// not be buffering tokens so get a reference to it. (At the
36     /// time the error occurred, of course the stream needs to keep a
37     /// buffer all of the tokens but later we might not have access to those.)
38     Token *_startToken;
39
40   };
41
42 } // namespace antlr4