8#include "antlr/CharScanner.hpp"
9#include "antlr/MismatchedCharException.hpp"
10#include "antlr/String.hpp"
12#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16MismatchedCharException::MismatchedCharException()
17 : RecognitionException(
"Mismatched char")
21MismatchedCharException::MismatchedCharException(
27) : RecognitionException(
"Mismatched char",
28 scanner_->getFilename(),
29 scanner_->getLine(), scanner_->getColumn())
30 , mismatchType(matchNot ? NOT_RANGE : RANGE)
39MismatchedCharException::MismatchedCharException(
44) : RecognitionException(
"Mismatched char",
45 scanner_->getFilename(),
46 scanner_->getLine(), scanner_->getColumn())
47 , mismatchType(matchNot ? NOT_CHAR : CHAR)
49 , expecting(expecting_)
55MismatchedCharException::MismatchedCharException(
60) : RecognitionException(
"Mismatched char",
61 scanner_->getFilename(),
62 scanner_->getLine(), scanner_->getColumn())
63 , mismatchType(matchNot ? NOT_SET : SET)
70ANTLR_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
110const int MismatchedCharException::CHAR;
111const int MismatchedCharException::NOT_CHAR;
112const int MismatchedCharException::RANGE;
113const int MismatchedCharException::NOT_RANGE;
114const int MismatchedCharException::SET;
115const int MismatchedCharException::NOT_SET;
118#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE