| 1 | #ifndef INC_LLkParser_hpp__ | 
| 2 | #define INC_LLkParser_hpp__ | 
| 3 |  | 
| 4 | /* ANTLR Translator Generator | 
| 5 | * Project led by Terence Parr at http://www.jGuru.com | 
| 6 | * Software rights: http://www.antlr.org/license.html | 
| 7 | * | 
| 8 | * $Id$ | 
| 9 | */ | 
| 10 |  | 
| 11 | #include <antlr/config.hpp> | 
| 12 | #include <antlr/Parser.hpp> | 
| 13 |  | 
| 14 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 15 | namespace antlr { | 
| 16 | #endif | 
| 17 |  | 
| 18 | /**An LL(k) parser. | 
| 19 | * | 
| 20 | * @see antlr.Token | 
| 21 | * @see antlr.TokenBuffer | 
| 22 | * @see antlr.LL1Parser | 
| 23 | */ | 
| 24 | class ANTLR_API LLkParser : public Parser { | 
| 25 | public: | 
| 26 | LLkParser(const ParserSharedInputState& lexer, int k_); | 
| 27 |  | 
| 28 | LLkParser(TokenBuffer& tokenBuf, int k_); | 
| 29 |  | 
| 30 | LLkParser(TokenStream& lexer, int k_); | 
| 31 |  | 
| 32 | /** Consume another token from the input stream.  Can only write sequentially! | 
| 33 | * If you need 3 tokens ahead, you must consume() 3 times. | 
| 34 | * <p> | 
| 35 | * Note that it is possible to overwrite tokens that have not been matched. | 
| 36 | * For example, calling consume() 3 times when k=2, means that the first token | 
| 37 | * consumed will be overwritten with the 3rd. | 
| 38 | */ | 
| 39 | virtual inline void consume() | 
| 40 | { | 
| 41 | inputState->getInput().consume(); | 
| 42 | } | 
| 43 |  | 
| 44 | virtual inline int LA(unsigned int i) | 
| 45 | { | 
| 46 | return inputState->getInput().LA(i); | 
| 47 | } | 
| 48 |  | 
| 49 | virtual inline RefToken LT(unsigned int i) | 
| 50 | { | 
| 51 | return inputState->getInput().LT(i); | 
| 52 | } | 
| 53 | protected: | 
| 54 | /// the lookahead this LL(k) parser is using. | 
| 55 | int k; | 
| 56 | private: | 
| 57 | void trace(const char* ee, const char* rname); | 
| 58 | public: | 
| 59 | virtual void traceIn(const char* rname); | 
| 60 | virtual void traceOut(const char* rname); | 
| 61 | }; | 
| 62 |  | 
| 63 | #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE | 
| 64 | } | 
| 65 | #endif | 
| 66 |  | 
| 67 | #endif //INC_LLkParser_hpp__ |