summaryrefslogtreecommitdiffstats
path: root/lib/antlr/antlr/LLkParser.h
blob: d9d2d9fd28096e8cdd0277dccf1ebb4202d1de98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef INC_LLkParser_h__
#define INC_LLkParser_h__

/* ANTLR Translator Generator
 * Project led by Terence Parr at http://www.jGuru.com
 * Software rights: http://www.antlr.org/license.html
 *
 * $Id$
 */

#include <antlr/config.h>
#include <antlr/Parser.h>

#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
namespace antlr {
#endif

/**An LL(k) parser.
 *
 * @see antlr.Token
 * @see antlr.TokenBuffer
 * @see antlr.LL1Parser
 */
class ANTLR_API LLkParser : public Parser {
public:
	LLkParser(const ParserSharedInputState& lexer, int k_);

	LLkParser(TokenBuffer& tokenBuf, int k_);

	LLkParser(TokenStream& lexer, int k_);

	/** Consume another token from the input stream.  Can only write sequentially!
	 * If you need 3 tokens ahead, you must consume() 3 times.
	 * <p>
	 * Note that it is possible to overwrite tokens that have not been matched.
	 * For example, calling consume() 3 times when k=2, means that the first token
	 * consumed will be overwritten with the 3rd.
	 */
	virtual inline void consume()
	{
		inputState->getInput().consume();
	}

	virtual inline int LA(unsigned int i)
	{
		return inputState->getInput().LA(i);
	}

	virtual inline RefToken LT(unsigned int i)
	{
		return inputState->getInput().LT(i);
	}
protected:
	/// the lookahead this LL(k) parser is using.
	int k;
private:
	void trace(const char* ee, const char* rname);
public:
	virtual void traceIn(const char* rname);
	virtual void traceOut(const char* rname);
};

#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
}
#endif

#endif //INC_LLkParser_h__