10#include "antlr/CharScanner.hpp"
11#include "antlr/CommonToken.hpp"
13#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
18CharScanner::CharScanner(InputBuffer& cb,
bool case_sensitive )
19 : saveConsumedInput(true)
20 , caseSensitive(case_sensitive)
21 , literals(CharScannerLiteralsLess(this))
22 , inputState(new LexerInputState(cb))
27 setTokenObjectFactory(&CommonToken::factory);
30CharScanner::CharScanner(InputBuffer* cb,
bool case_sensitive )
31 : saveConsumedInput(true)
32 , caseSensitive(case_sensitive)
33 , literals(CharScannerLiteralsLess(this))
34 , inputState(new LexerInputState(cb))
39 setTokenObjectFactory(&CommonToken::factory);
42CharScanner::CharScanner(
const LexerSharedInputState& state,
bool case_sensitive )
43 : saveConsumedInput(true)
44 , caseSensitive(case_sensitive)
45 , literals(CharScannerLiteralsLess(this))
51 setTokenObjectFactory(&CommonToken::factory);
57 ANTLR_USE_NAMESPACE(std)cerr << ex.
toString().c_str() << ANTLR_USE_NAMESPACE(std)endl;
61void CharScanner::reportError(
const ANTLR_USE_NAMESPACE(std)
string& s)
63 if (getFilename() ==
"")
64 ANTLR_USE_NAMESPACE(std)cerr <<
"error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
66 ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() <<
": error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
70void CharScanner::reportWarning(
const ANTLR_USE_NAMESPACE(std)
string& s)
72 if (getFilename() ==
"")
73 ANTLR_USE_NAMESPACE(std)cerr <<
"warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
75 ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() <<
": warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
78void CharScanner::traceIndent()
80 for(
int i = 0; i < traceDepth; i++ )
81 ANTLR_USE_NAMESPACE(std)cout <<
" ";
84void CharScanner::traceIn(
const char* rname)
88 ANTLR_USE_NAMESPACE(std)cout <<
"> lexer " << rname
89 <<
"; c==" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
92void CharScanner::traceOut(
const char* rname)
95 ANTLR_USE_NAMESPACE(std)cout <<
"< lexer " << rname
96 <<
"; c==" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
100#ifndef NO_STATIC_CONSTS
101const int CharScanner::NO_CHAR;
102const int CharScanner::EOF_CHAR;
105#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
virtual std::string toString() const
Return complete error message with line/column number info (if present)