| 1 |
#ifndef INC_MismatchedCharException_hpp__ |
| 2 |
#define INC_MismatchedCharException_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: MismatchedCharException.hpp,v 1.1 2005-12-02 15:38:02 tim Exp $ |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <antlr/config.hpp> |
| 12 |
#include <antlr/RecognitionException.hpp> |
| 13 |
#include <antlr/BitSet.hpp> |
| 14 |
|
| 15 |
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE |
| 16 |
namespace antlr { |
| 17 |
#endif |
| 18 |
|
| 19 |
class CharScanner; |
| 20 |
|
| 21 |
class ANTLR_API MismatchedCharException : public RecognitionException { |
| 22 |
public: |
| 23 |
// Types of chars |
| 24 |
#ifndef NO_STATIC_CONSTS |
| 25 |
static const int CHAR = 1; |
| 26 |
static const int NOT_CHAR = 2; |
| 27 |
static const int RANGE = 3; |
| 28 |
static const int NOT_RANGE = 4; |
| 29 |
static const int SET = 5; |
| 30 |
static const int NOT_SET = 6; |
| 31 |
#else |
| 32 |
enum { |
| 33 |
CHAR = 1, |
| 34 |
NOT_CHAR = 2, |
| 35 |
RANGE = 3, |
| 36 |
NOT_RANGE = 4, |
| 37 |
SET = 5, |
| 38 |
NOT_SET = 6 |
| 39 |
}; |
| 40 |
#endif |
| 41 |
|
| 42 |
public: |
| 43 |
// One of the above |
| 44 |
int mismatchType; |
| 45 |
|
| 46 |
// what was found on the input stream |
| 47 |
int foundChar; |
| 48 |
|
| 49 |
// For CHAR/NOT_CHAR and RANGE/NOT_RANGE |
| 50 |
int expecting; |
| 51 |
|
| 52 |
// For RANGE/NOT_RANGE (expecting is lower bound of range) |
| 53 |
int upper; |
| 54 |
|
| 55 |
// For SET/NOT_SET |
| 56 |
BitSet set; |
| 57 |
|
| 58 |
protected: |
| 59 |
// who knows...they may want to ask scanner questions |
| 60 |
CharScanner* scanner; |
| 61 |
|
| 62 |
public: |
| 63 |
MismatchedCharException(); |
| 64 |
|
| 65 |
// Expected range / not range |
| 66 |
MismatchedCharException( |
| 67 |
int c, |
| 68 |
int lower, |
| 69 |
int upper_, |
| 70 |
bool matchNot, |
| 71 |
CharScanner* scanner_ |
| 72 |
); |
| 73 |
|
| 74 |
// Expected token / not token |
| 75 |
MismatchedCharException( |
| 76 |
int c, |
| 77 |
int expecting_, |
| 78 |
bool matchNot, |
| 79 |
CharScanner* scanner_ |
| 80 |
); |
| 81 |
|
| 82 |
// Expected BitSet / not BitSet |
| 83 |
MismatchedCharException( |
| 84 |
int c, |
| 85 |
BitSet set_, |
| 86 |
bool matchNot, |
| 87 |
CharScanner* scanner_ |
| 88 |
); |
| 89 |
|
| 90 |
~MismatchedCharException() throw() {} |
| 91 |
|
| 92 |
/** |
| 93 |
* Returns a clean error message (no line number/column information) |
| 94 |
*/ |
| 95 |
ANTLR_USE_NAMESPACE(std)string getMessage() const; |
| 96 |
}; |
| 97 |
|
| 98 |
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE |
| 99 |
} |
| 100 |
#endif |
| 101 |
|
| 102 |
#endif //INC_MismatchedCharException_hpp__ |