]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/antlr2/src/MismatchedCharException.cpp
1 /* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
5 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/src/MismatchedCharException.cpp#2 $
8 #include "antlr/CharScanner.hpp"
9 #include "antlr/MismatchedCharException.hpp"
10 #include "antlr/String.hpp"
12 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16 MismatchedCharException::MismatchedCharException()
17 : RecognitionException("Mismatched char")
20 // Expected range / not range
21 MismatchedCharException::MismatchedCharException(
27 ) : RecognitionException("Mismatched char",
28 scanner_
->getFilename(),
29 scanner_
->getLine(), scanner_
->getColumn())
30 , mismatchType(matchNot
? NOT_RANGE
: RANGE
)
38 // Expected token / not token
39 MismatchedCharException::MismatchedCharException(
44 ) : RecognitionException("Mismatched char",
45 scanner_
->getFilename(),
46 scanner_
->getLine(), scanner_
->getColumn())
47 , mismatchType(matchNot
? NOT_CHAR
: CHAR
)
49 , expecting(expecting_
)
54 // Expected BitSet / not BitSet
55 MismatchedCharException::MismatchedCharException(
60 ) : RecognitionException("Mismatched char",
61 scanner_
->getFilename(),
62 scanner_
->getLine(), scanner_
->getColumn())
63 , mismatchType(matchNot
? NOT_SET
: SET
)
70 ANTLR_USE_NAMESPACE(std
)string
MismatchedCharException::getMessage() const
72 ANTLR_USE_NAMESPACE(std
)string s
;
74 switch (mismatchType
) {
76 s
+= "expecting '" + charName(expecting
) + "', found '" + charName(foundChar
) + "'";
79 s
+= "expecting anything but '" + charName(expecting
) + "'; got it anyway";
82 s
+= "expecting token in range: '" + charName(expecting
) + "'..'" + charName(upper
) + "', found '" + charName(foundChar
) + "'";
85 s
+= "expecting token NOT in range: " + charName(expecting
) + "'..'" + charName(upper
) + "', found '" + charName(foundChar
) + "'";
90 s
+= ANTLR_USE_NAMESPACE(std
)string("expecting ") + (mismatchType
== NOT_SET
? "NOT " : "") + "one of (";
91 ANTLR_USE_NAMESPACE(std
)vector
<unsigned int> elems
= set
.toArray();
92 for ( unsigned int i
= 0; i
< elems
.size(); i
++ )
95 s
+= charName(elems
[i
]);
98 s
+= "), found '" + charName(foundChar
) + "'";
102 s
+= RecognitionException::getMessage();
109 #ifndef NO_STATIC_CONSTS
110 const int MismatchedCharException::CHAR
;
111 const int MismatchedCharException::NOT_CHAR
;
112 const int MismatchedCharException::RANGE
;
113 const int MismatchedCharException::NOT_RANGE
;
114 const int MismatchedCharException::SET
;
115 const int MismatchedCharException::NOT_SET
;
118 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE