![]() |
Kea
1.5.0
|
Evaluation context, an interface to the expression evaluation. More...
#include <parser_context.h>
Public Types | |
| enum | ParserContext { NO_KEYWORD, CONFIG, DHCPDDNS, TSIG_KEY, TSIG_KEYS, ALGORITHM, DIGEST_BITS, SECRET, FORWARD_DDNS, REVERSE_DDNS, DDNS_DOMAIN, DDNS_DOMAINS, DNS_SERVER, DNS_SERVERS, LOGGING, LOGGERS, OUTPUT_OPTIONS, NCR_PROTOCOL, NCR_FORMAT } |
| Defines syntactic contexts for lexical tie-ins. More... | |
| enum | ParserType { PARSER_JSON, PARSER_DHCPDDNS, PARSER_SUB_DHCPDDNS, PARSER_TSIG_KEY, PARSER_TSIG_KEYS, PARSER_DDNS_DOMAIN, PARSER_DDNS_DOMAINS, PARSER_DNS_SERVER, PARSER_DNS_SERVERS } |
| Defines currently supported scopes. More... | |
Public Member Functions | |
| D2ParserContext () | |
| Default constructor. More... | |
| const std::string | contextName () |
| Get the syntax context name. More... | |
| void | enter (const ParserContext &ctx) |
| Enter a new syntactic context. More... | |
| void | error (const isc::d2::location &loc, const std::string &what) |
| Error handler. More... | |
| void | error (const std::string &what) |
| Error handler. More... | |
| void | includeFile (const std::string &filename) |
| Divert input to an include file. More... | |
| void | leave () |
| Leave a syntactic context. More... | |
| isc::data::Element::Position | loc2pos (isc::d2::location &loc) |
| Converts bison's position to one understood by isc::data::Element. More... | |
| isc::data::ElementPtr | parseFile (const std::string &filename, ParserType parser_type) |
| Run the parser on the file specified. More... | |
| isc::data::ElementPtr | parseString (const std::string &str, ParserType parser_type) |
| Run the parser on the string specified. More... | |
| void | scanEnd () |
| Method called after the last tokens are scanned. More... | |
| void | scanFileBegin (FILE *f, const std::string &filename, ParserType type) |
| Method called before scanning starts on a file. More... | |
| void | scanStringBegin (const std::string &str, ParserType type) |
| Method called before scanning starts on a string. More... | |
Static Public Member Functions | |
| static void | fatal (const std::string &what) |
| Fatal error handler. More... | |
Public Attributes | |
| ParserContext | ctx_ |
| Current syntactic context. More... | |
| std::string | file_ |
| File name. More... | |
| std::vector< std::string > | files_ |
| File name stack. More... | |
| isc::d2::location | loc_ |
| Location of the current token. More... | |
| std::vector< isc::d2::location > | locs_ |
| Location stack. More... | |
| FILE * | sfile_ |
| sFile (aka FILE) More... | |
| std::vector< FILE * > | sfiles_ |
| sFile (aka FILE) stack More... | |
| std::vector< isc::data::ElementPtr > | stack_ |
| JSON elements being parsed. More... | |
| std::vector< struct yy_buffer_state * > | states_ |
| Lexer state stack. More... | |
Evaluation context, an interface to the expression evaluation.
Definition at line 36 of file d2/parser_context.h.
Defines syntactic contexts for lexical tie-ins.
Definition at line 164 of file d2/parser_context.h.
Defines currently supported scopes.
D2Parser may eventually support multiple levels of parsing scope. Currently it supports only the D2 module scope which expects the data to be parsed to be a map containing the DhcpDdns element and its constituents.
Definition at line 47 of file d2/parser_context.h.
| isc::d2::D2ParserContext::D2ParserContext | ( | ) |
Default constructor.
Definition at line 20 of file d2/parser_context.cc.
| const std::string isc::d2::D2ParserContext::contextName | ( | ) |
Get the syntax context name.
Definition at line 114 of file d2/parser_context.cc.
References ALGORITHM, CONFIG, ctx_, DDNS_DOMAIN, DDNS_DOMAINS, DHCPDDNS, DIGEST_BITS, DNS_SERVER, DNS_SERVERS, FORWARD_DDNS, LOGGERS, LOGGING, NCR_FORMAT, NCR_PROTOCOL, NO_KEYWORD, OUTPUT_OPTIONS, REVERSE_DDNS, SECRET, TSIG_KEY, and TSIG_KEYS.
Referenced by isc::d2::D2Parser::parse().
| void isc::d2::D2ParserContext::enter | ( | const ParserContext & | ctx | ) |
Enter a new syntactic context.
Entering a new syntactic context is useful in several ways. First, it allows the parser to avoid conflicts. Second, it allows the lexer to return different tokens depending on context (e.g. if "name" string is detected, the lexer will return STRING token if in JSON mode or NAME if in TSIG_KEY mode. Finally, the syntactic context allows the error message to be more descriptive if the input string does not parse properly.
| ctx | the syntactic context to enter into |
Definition at line 96 of file d2/parser_context.cc.
References ctx_.
Referenced by isc::d2::D2Parser::parse().
| void isc::d2::D2ParserContext::error | ( | const isc::d2::location & | loc, |
| const std::string & | what | ||
| ) |
Error handler.
| loc | location within the parsed file when experienced a problem. |
| what | string explaining the nature of the error. |
| D2ParseError |
Definition at line 69 of file d2/parser_context.cc.
References isc_throw.
Referenced by isc::d2::D2Parser::error().
| void isc::d2::D2ParserContext::error | ( | const std::string & | what | ) |
Error handler.
This is a simplified error reporting tool for reporting parsing errors.
| what | string explaining the nature of the error. |
| D2ParseError |
Definition at line 75 of file d2/parser_context.cc.
References isc_throw.
|
static |
Fatal error handler.
This is for should not happen but fatal errors. Used by YY_FATAL_ERROR macro so required to be static.
| what | string explaining the nature of the error. |
| D2ParseError |
Definition at line 81 of file d2/parser_context.cc.
References isc_throw.
Referenced by leave().
| void D2ParserContext::includeFile | ( | const std::string & | filename | ) |
Divert input to an include file.
| filename | file to be included |
Definition at line 3512 of file d2_lexer.cc.
References BEGIN, INITIAL, and YY_CURRENT_BUFFER.
| void isc::d2::D2ParserContext::leave | ( | ) |
Leave a syntactic context.
| isc::Unexpected | if unbalanced |
Definition at line 103 of file d2/parser_context.cc.
Referenced by isc::d2::D2Parser::parse().
Here is the call graph for this function:| isc::data::Element::Position isc::d2::D2ParserContext::loc2pos | ( | isc::d2::location & | loc | ) |
Converts bison's position to one understood by isc::data::Element.
Convert a bison location into an element position (take the begin, the end is lost)
| loc | location in bison format |
Definition at line 87 of file d2/parser_context.cc.
Referenced by isc::d2::D2Parser::parse().
| isc::data::ElementPtr isc::d2::D2ParserContext::parseFile | ( | const std::string & | filename, |
| ParserType | parser_type | ||
| ) |
Run the parser on the file specified.
This method parses specified file. Depending on the value of parser_type, parser may either check only that the input is valid JSON, or may do more specific syntax checking. See ParserType for supported syntax checkers.
| filename | file to be parsed |
| parser_type | specifies expected content |
Definition at line 33 of file d2/parser_context.cc.
References isc_throw, and scanFileBegin().
Here is the call graph for this function:| isc::data::ElementPtr isc::d2::D2ParserContext::parseString | ( | const std::string & | str, |
| ParserType | parser_type | ||
| ) |
Run the parser on the string specified.
This method parses specified string. Depending on the value of parser_type, parser may either check only that the input is valid JSON, or may do more specific syntax checking. See ParserType for supported syntax checkers.
| str | string to be parsed |
| parser_type | specifies expected content |
Definition at line 26 of file d2/parser_context.cc.
References scanStringBegin().
Here is the call graph for this function:| void D2ParserContext::scanEnd | ( | ) |
Method called after the last tokens are scanned.
Definition at line 3491 of file d2_lexer.cc.
| void D2ParserContext::scanFileBegin | ( | FILE * | f, |
| const std::string & | filename, | ||
| ParserType | type | ||
| ) |
Method called before scanning starts on a file.
| f | stdio FILE pointer |
| filename | file to be parsed |
| type | specifies expected content |
Definition at line 3469 of file d2_lexer.cc.
References yy_flex_debug.
Referenced by parseFile().
| void D2ParserContext::scanStringBegin | ( | const std::string & | str, |
| ParserType | type | ||
| ) |
Method called before scanning starts on a string.
| str | string to be parsed |
| type | specifies expected content |
Definition at line 3451 of file d2_lexer.cc.
References yy_flex_debug.
Referenced by parseString().
| ParserContext isc::d2::D2ParserContext::ctx_ |
Current syntactic context.
Definition at line 253 of file d2/parser_context.h.
Referenced by contextName(), enter(), leave(), and isc::d2::D2Parser::parse().
| std::string isc::d2::D2ParserContext::file_ |
File name.
Definition at line 225 of file d2/parser_context.h.
| std::vector<std::string> isc::d2::D2ParserContext::files_ |
File name stack.
Definition at line 228 of file d2/parser_context.h.
| isc::d2::location isc::d2::D2ParserContext::loc_ |
Location of the current token.
The lexer will keep updating it. This variable will be useful for logging errors.
Definition at line 234 of file d2/parser_context.h.
| std::vector<isc::d2::location> isc::d2::D2ParserContext::locs_ |
Location stack.
Definition at line 237 of file d2/parser_context.h.
| FILE* isc::d2::D2ParserContext::sfile_ |
sFile (aka FILE)
Definition at line 243 of file d2/parser_context.h.
| std::vector<FILE*> isc::d2::D2ParserContext::sfiles_ |
sFile (aka FILE) stack
This is a stack of files. Typically there's only one file (the one being currently parsed), but there may be more if one file includes another.
Definition at line 250 of file d2/parser_context.h.
| std::vector<isc::data::ElementPtr> isc::d2::D2ParserContext::stack_ |
JSON elements being parsed.
Definition at line 80 of file d2/parser_context.h.
Referenced by isc::d2::D2Parser::parse().
| std::vector<struct yy_buffer_state*> isc::d2::D2ParserContext::states_ |
Lexer state stack.
Definition at line 240 of file d2/parser_context.h.