8 #define MASTER_LEXER_H 1 17 #include <boost/noncopyable.hpp> 21 namespace master_lexer_internal {
53 NOVALUE_TYPE_MAX = INITIAL_WS,
106 if (type > NOVALUE_TYPE_MAX) {
108 "called with invalid type: " << type);
127 MasterToken(
const char* str_beg,
size_t str_len,
bool quoted =
false) :
128 type_(quoted ? QSTRING : STRING)
130 val_.str_region_.beg = str_beg;
131 val_.str_region_.len = str_len;
139 val_.number_ = number;
147 if (!(error_code < MAX_ERROR_CODE)) {
151 val_.error_code_ = error_code;
165 if (type_ != STRING && type_ != QSTRING) {
167 "Token::getStringRegion() for non string-variant type");
169 return (val_.str_region_);
206 if (type_ != STRING && type_ != QSTRING) {
208 "Token::getString() for non string-variant type");
210 ret.assign(val_.str_region_.beg,
211 val_.str_region_.beg + val_.str_region_.len);
219 if (type_ != NUMBER) {
221 "Token::getNumber() for non number type");
223 return (val_.number_);
231 if (type_ !=
ERROR) {
233 "Token::getErrorCode() for non error type");
235 return (val_.error_code_);
247 std::string getErrorText()
const;
308 ReadError(
const char* file,
size_t line,
const char* what) :
323 isc::dns::
Exception(file, line, error_token.getErrorText().c_str()),
385 bool pushSource(
const char* filename, std::string*
error = NULL);
417 void pushSource(std::istream& input);
436 size_t getSourceCount()
const;
453 std::string getSourceName()
const;
469 size_t getSourceLine()
const;
497 size_t getTotalSourceSize()
const;
536 size_t getPosition()
const;
638 bool eol_ok =
false);
658 struct MasterLexerImpl;
659 MasterLexerImpl* impl_;
668 return (static_cast<MasterLexer::Options>(
669 static_cast<unsigned>(o1) | static_cast<unsigned>(o2)));
674 #endif // MASTER_LEXER_H ErrorCode
Enumeration for lexer error codes.
MasterToken(uint32_t number)
Constructor for number type of token.
static const size_t SOURCE_SIZE_UNKNOWN
Special value for input source size meaning "unknown".
const char * beg
The start address of the string.
size_t len
The length of the string in bytes.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
ErrorCode getErrorCode() const
Return the error code of a error type token.
std::string getString() const
Return the value of a string-variant token as a string object.
Exception thrown from a wrapper version of MasterLexer::getNextToken() for non fatal errors...
The lexer is just initialized and has no token.
LexerError(const char *file, size_t line, MasterToken error_token)
MasterToken(const char *str_beg, size_t str_len, bool quoted=false)
Constructor for string and quoted-string types of token.
Type getType() const
Return the token type.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
uint32_t getNumber() const
Return the value of a string-variant token as a string object.
Unbalanced parentheses detected.
A generic exception that is thrown when an unexpected error condition occurs.
Type
Enumeration for token types.
A single string quoted by double-quotes (").
Exception thrown when we fail to read from the input stream or file.
Number is expected but not recognized.
Defines the logger used by the top-level component of kea-lfc.
void getString(std::string &ret) const
Fill in a string with the value of a string-variant token.
A simple representation of a range of a string.
Options
Options for getNextToken.
A generic exception that is thrown if a function is called in a prohibited way.
Tokenization state for MasterLexer.
A decimal number (unsigned 32-bit)
MasterToken(ErrorCode error_code)
Constructor for error type of token.
Unexpected quotes character detected.
const StringRegion & getStringRegion() const
Return the value of a string-variant token.
MasterLexer::Options operator|(MasterLexer::Options o1, MasterLexer::Options o2)
Operator to combine MasterLexer options.
ReadError(const char *file, size_t line, const char *what)
MasterToken(Type type)
Constructor for non-value type of token.
Tokenizer for parsing DNS master files.