14 #include <boost/lexical_cast.hpp> 23 : sfile_(0), ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false)
35 return (parseCommon());
40 FILE* f = fopen(filename.c_str(),
"r");
45 return (parseCommon());
49 D2ParserContext::parseCommon() {
55 int res = parser.
parse();
75 const std::string& what,
100 const std::string& file = *loc.begin.filename;
101 const uint32_t line = loc.begin.line;
102 const uint32_t pos = loc.begin.column;
114 "missing parameter '" << name <<
"' (" 115 <<
stack_.back()->getPosition() <<
") [" 117 << open_loc <<
" and " << close_loc <<
"]");
130 <<
" map (previous at " << value->getPosition() <<
")");
133 <<
" entries in JSON" 134 <<
" map (previous at " << value->getPosition() <<
")");
142 cstack_.push_back(
ctx_);
149 if (cstack_.empty()) {
150 fatal(
"unbalanced syntactic context");
153 ctx_ = cstack_.back();
162 return (
"__no keyword__");
170 return (
"tsig-keys");
174 return(
"digest-bits");
178 return(
"forward-ddns");
180 return(
"reverse-ddns");
182 return(
"ddns-domain");
184 return(
"ddns-domains");
186 return(
"dns-server");
188 return(
"dns-servers");
190 return(
"control-socket");
194 return (
"output-options");
196 return (
"ncr-protocol");
198 return (
"ncr-format");
200 return (
"hooks-libraries");
202 return (
"__unknown__");
208 const std::string& what) {
209 std::ostringstream msg;
210 msg << loc <<
": " << what;
217 warning(loc,
"Extraneous comma. A piece of configuration may have been omitted.");
Used while parsing a list of tsig-keys.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Define the isc::d2::parser class.
Used while parsing DhcpDdns/loggers/output_options structures.
const isc::log::MessageID DHCP_DDNS_CONFIG_SYNTAX_WARNING
Used while parsing content of a dns-server.
virtual int parse()
Parse.
Used while parsing content of DhcpDdns/tsig-keys/algorithm.
void set_debug_level(debug_level_type l)
Set the current debugging level.
Used while parsing content of DhcpDdns/forward-ddns.
This one is used in pure JSON mode.
void warning(const isc::d2::location &loc, const std::string &what)
Warning handler.
virtual ~D2ParserContext()
destructor.
void require(const std::string &name, isc::data::Element::Position open_loc, isc::data::Element::Position close_loc)
Check if a required parameter is present.
boost::shared_ptr< Element > ElementPtr
void scanEnd()
Method called after the last tokens are scanned.
Used while parsing content of a tsig-key.
void warnAboutExtraCommas(const isc::d2::location &loc)
Warning for extra commas.
Used while parsing DhcpDdns/loggers structures.
void unique(const std::string &name, isc::data::Element::Position loc)
Check if a parameter is already present.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
static void fatal(const std::string &what)
Fatal error handler.
Used while parsing content of DhcpDdns/tsig-keys/secret.
Used while parsing content of a ddns-domain.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Used while parsing DhcpDdns/hooks-libraries.
Used while parsing content of DhcpDdns/reverse-ddns.
void leave()
Leave a syntactic context.
isc::log::Logger d2_to_dns_logger("d2-to-dns")
Used while parsing content of a control-socket.
Used while parsing DhcpDdns/ncr-protocol.
boost::shared_ptr< const Element > ConstElementPtr
ParserType
Defines currently supported scopes.
Used while parsing DhcpDdns/ncr-format.
Represents the position of the data element within a configuration string.
Defines the logger used by the top-level component of kea-lfc.
void enter(const ParserContext &ctx)
Enter a new syntactic context.
Evaluation error exception raised when trying to parse.
void error(const isc::d2::location &loc, const std::string &what, size_t pos=0)
Error handler.
Used while parsing content of DhcpDdns.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.
Used while parsing a list of ddns-domains.
ParserContext
Defines syntactic contexts for lexical tie-ins.
D2ParserContext()
Default constructor.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Used while parsing content of DhcpDdns/tsig-keys/digest-bits.
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
ParserContext ctx_
Current syntactic context.
Used while parsing content of list of dns-servers.
isc::data::Element::Position loc2pos(isc::d2::location &loc)
Converts bison's position to one understood by isc::data::Element.
const std::string contextName()
Get the syntax context name.