summaryrefslogtreecommitdiffstats
path: root/lib/antlr/antlr/MismatchedCharException.hpp
blob: cc77f9e46e130d597f7f0f1e39c397b5653778ae (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef INC_MismatchedCharException_hpp__
#define INC_MismatchedCharException_hpp__

/* 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.hpp>
#include <antlr/RecognitionException.hpp>
#include <antlr/BitSet.hpp>

#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
namespace antlr {
#endif

class CharScanner;

class ANTLR_API MismatchedCharException : public RecognitionException {
public:
	// Types of chars
#ifndef NO_STATIC_CONSTS
	static const int CHAR = 1;
	static const int NOT_CHAR = 2;
	static const int RANGE = 3;
	static const int NOT_RANGE = 4;
	static const int SET = 5;
	static const int NOT_SET = 6;
#else
	enum {
		CHAR = 1,
		NOT_CHAR = 2,
		RANGE = 3,
		NOT_RANGE = 4,
		SET = 5,
		NOT_SET = 6
	};
#endif

public:
	// One of the above
	int mismatchType;

	// what was found on the input stream
	int foundChar;

	// For CHAR/NOT_CHAR and RANGE/NOT_RANGE
	int expecting;

	// For RANGE/NOT_RANGE (expecting is lower bound of range)
	int upper;

	// For SET/NOT_SET
	BitSet set;

protected:
	// who knows...they may want to ask scanner questions
	CharScanner* scanner;

public:
	MismatchedCharException();

	// Expected range / not range
	MismatchedCharException(
		int c,
		int lower,
		int upper_,
		bool matchNot,
		CharScanner* scanner_
	);

	// Expected token / not token
	MismatchedCharException(
		int c,
		int expecting_,
		bool matchNot,
		CharScanner* scanner_
	);

	// Expected BitSet / not BitSet
	MismatchedCharException(
		int c,
		BitSet set_,
		bool matchNot,
		CharScanner* scanner_
	);

	~MismatchedCharException() throw() {}

	/**
	 * Returns a clean error message (no line number/column information)
	 */
	ANTLR_USE_NAMESPACE(std)string getMessage() const;
};

#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
}
#endif

#endif //INC_MismatchedCharException_hpp__