8 #define MASTER_LEXER_H 1
17 #include <boost/noncopyable.hpp>
21 namespace master_lexer_internal {
108 "called with invalid type: " << type);
127 MasterToken(
const char* str_beg,
size_t str_len,
bool quoted =
false) :
130 val_.str_region_.beg = str_beg;
131 val_.str_region_.len = str_len;
139 val_.number_ = number;
151 val_.error_code_ = error_code;
167 "Token::getStringRegion() for non string-variant type");
169 return (val_.str_region_);
208 "Token::getString() for non string-variant type");
210 ret.assign(val_.str_region_.beg,
211 val_.str_region_.beg + val_.str_region_.len);
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_);
323 isc::dns::
Exception(file, line, error_token.getErrorText().c_str()),
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
const StringRegion & getStringRegion() const
Return the value of a string-variant token.
ErrorCode getErrorCode() const
Return the error code of a error type token.
ErrorCode
Enumeration for lexer error codes.
bool pushSource(const char *filename, std::string *error=NULL)
Open a file and make it the current input source of MasterLexer.
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...
size_t getSourceLine() const
Return the input source line number.
Error detected in getting a token.
size_t getPosition() const
Return the position of lexer in the pushed sources so far.
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.
void getString(std::string &ret) const
Fill in a string with the value of a string-variant token.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
White spaces at the beginning of a line after an end of line or at the beginning of file (if asked...
Unbalanced quotations detected.
Unbalanced parentheses detected.
recognize begin-of-line spaces after an end-of-line
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.
std::string getSourceName() const
Return the name of the current input source name.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
const MasterToken & getNextToken(Options options=NONE)
Parse and return another token from the input.
void popSource()
Stop using the most recently opened input source (file or stream).
std::string getErrorText() const
Return a textual description of the error of a error type token.
Number is expected but not recognized.
Defines the logger used by the top-level component of kea-dhcp-ddns.
size_t getTotalSourceSize() const
Return the total size of pushed sources.
void ungetToken()
Return the last token back to the lexer.
A simple representation of a range of a string.
MasterLexer()
The constructor.
Options
Options for getNextToken.
uint32_t getNumber() const
Return the value of a string-variant token as a string object.
A generic exception that is thrown if a function is called in a prohibited way.
size_t getSourceCount() const
Get number of sources inside the lexer.
recognize numeric text as integer
Tokenization state for MasterLexer.
A decimal number (unsigned 32-bit)
MasterToken(ErrorCode error_code)
Constructor for error type of token.
Max integer corresponding to no-value (type only) types.
Type getType() const
Return the token type.
Unexpected quotes character detected.
MasterLexer::Options operator|(MasterLexer::Options o1, MasterLexer::Options o2)
Operator to combine MasterLexer options.
ReadError(const char *file, size_t line, const char *what)
~MasterLexer()
The destructor.
std::string getString() const
Return the value of a string-variant token as a string object.
The lexer reaches the end of line or file unexpectedly.
MasterToken(Type type)
Constructor for non-value type of token.
Tokenizer for parsing DNS master files.
Max integer corresponding to valid error codes.