OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
LLkParser.hpp
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
15namespace antlr {
16#endif
17
18/**An LL(k) parser.
19 *
20 * @see antlr.Token
21 * @see antlr.TokenBuffer
22 * @see antlr.LL1Parser
23 */
24class ANTLR_API LLkParser : public Parser {
25public:
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 }
53protected:
54 /// the lookahead this LL(k) parser is using.
55 int k;
56private:
57 void trace(const char* ee, const char* rname);
58public:
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__
An LL(k) parser.
Definition LLkParser.hpp:24
virtual void consume()
Consume another token from the input stream.
Definition LLkParser.hpp:39
virtual int LA(unsigned int i)
Return the token type of the ith token of lookahead where i=1 is the current token being examined by ...
Definition LLkParser.hpp:44
int k
the lookahead this LL(k) parser is using.
Definition LLkParser.hpp:55
virtual RefToken LT(unsigned int i)
Return the i-th token of lookahead.
Definition LLkParser.hpp:49
A generic ANTLR parser (LL(k) for k>=1) containing a bunch of utility routines useful at any lookahea...
Definition Parser.hpp:64
A Stream of Token objects fed to the parser from a TokenStream that can be rewound via mark()/rewind(...
This interface allows any object to pretend it is a stream of tokens.