 |
Kea
1.5.0
|
Go to the documentation of this file.
13 #include <boost/lexical_cast.hpp>
21 : sfile_(0), ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false)
29 return (parseCommon());
34 FILE* f = fopen(filename.c_str(),
"r");
39 return (parseCommon());
43 D2ParserContext::parseCommon() {
47 parser.set_debug_level(trace_parsing_);
49 int res = parser.parse();
89 const std::string& file = *loc.begin.filename;
90 const uint32_t line = loc.begin.line;
91 const uint32_t pos = loc.begin.column;
98 cstack_.push_back(
ctx_);
105 if (cstack_.empty()) {
106 fatal(
"unbalanced syntactic context");
109 ctx_ = cstack_.back();
118 return (
"__no keyword__");
126 return (
"tsig-keys");
130 return(
"digest-bits");
134 return(
"forward-ddns");
136 return(
"reverse-ddns");
138 return(
"ddns-domain");
140 return(
"ddns-domains");
142 return(
"dns-server");
144 return(
"dns-servers");
150 return (
"output-options");
152 return (
"ncr-protocol");
154 return (
"ncr-format");
156 return (
"__unknown__");
static void fatal(const std::string &what)
Fatal error handler.
@ DNS_SERVERS
Used while parsing content of Logging.
ParserType
Defines currently supported scopes.
@ LOGGERS
Used while parsing Logging/loggers structures.
void leave()
Leave a syntactic context.
ParserContext
Defines syntactic contexts for lexical tie-ins.
@ ALGORITHM
Used while parsing content of DhcpDdns/tsig-keys/digest-bits.
@ OUTPUT_OPTIONS
Used while parsing Logging/loggers/output_options structures.
@ NO_KEYWORD
This one is used in pure JSON mode.
@ DDNS_DOMAIN
Used while parsing a list of ddns-domains.
@ REVERSE_DDNS
Used while parsing content of a ddns-domain.
D2ParserContext()
Default constructor.
@ NCR_FORMAT
Used while parsing DhcpDdns/ncr-format.
@ DHCPDDNS
Used while parsing content of a tsig-key.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
@ CONFIG
Used while parsing content of DhcpDdns.
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
const std::string contextName()
Get the syntax context name.
@ DDNS_DOMAINS
Used while parsing content of a dns-server.
Defines the logger used by the top-level component of kea-dhcp-ddns.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::Element::Position loc2pos(isc::d2::location &loc)
Converts bison's position to one understood by isc::data::Element.
ParserContext ctx_
Current syntactic context.
@ NCR_PROTOCOL
Used while parsing DhcpDdns/ncr-protocol.
Represents the position of the data element within a configuration string.
void error(const isc::d2::location &loc, const std::string &what)
Error handler.
@ FORWARD_DDNS
Used while parsing content of DhcpDdns/reverse-ddns.
void scanEnd()
Method called after the last tokens are scanned.
@ DNS_SERVER
Used while parsing content of list of dns-servers.
@ DIGEST_BITS
Used while parsing content of DhcpDdns/tsig-keys/secret.
@ TSIG_KEY
Used while parsing a list of tsig-keys.
@ TSIG_KEYS
Used while parsing content of DhcpDdns/tsig-keys/algorithm.
void enter(const ParserContext &ctx)
Enter a new syntactic context.
boost::shared_ptr< Element > ElementPtr
@ SECRET
Used while parsing content of DhcpDdns/forward-ddns.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
Evaluation error exception raised when trying to parse.