13 #include <boost/lexical_cast.hpp>
21 : sfile_(nullptr), ctx_(NO_KEYWORD), trace_scanning_(false),
22 trace_parsing_(false) {
31 return (parseCommon());
36 FILE* f = fopen(filename.c_str(),
"r");
41 return (parseCommon());
45 Parser6Context::parseCommon() {
49 parser.set_debug_level(trace_parsing_);
51 int res = parser.parse();
71 const std::string& what,
92 const std::string& file = *loc.begin.filename;
93 const uint32_t line = loc.begin.line;
94 const uint32_t pos = loc.begin.column;
105 "missing parameter '" << name <<
"' ("
106 <<
stack_.back()->getPosition() <<
") ["
108 << open_loc <<
" and " << close_loc <<
"]");
120 <<
" map (previous at " << value->getPosition() <<
")");
123 <<
" entries in JSON"
124 <<
" map (previous at " << value->getPosition() <<
")");
131 cstack_.push_back(
ctx_);
138 if (cstack_.empty()) {
139 fatal(
"unbalanced syntactic context");
142 ctx_ = cstack_.back();
150 return (
"__no keyword__");
156 return (
"interfaces-config");
158 return (
"lease-database");
160 return (
"hosts-database");
162 return (
"database-type");
164 return (
"database-on-fail");
166 return (
"mac-sources");
168 return (
"host-reservation-identifiers");
170 return (
"hooks-libraries");
174 return (
"reservation-mode");
176 return (
"option-def");
178 return (
"option-data");
180 return (
"client-classes");
182 return (
"expired-leases-processing");
184 return (
"server-id");
186 return (
"duid-type");
188 return (
"control-socket");
190 return (
"dhcp-queue-control");
192 return (
"multi-threading");
198 return (
"reservations");
204 return (
"output-options");
206 return (
"dhcp-ddns");
208 return (
"ncr-protocol");
210 return (
"ncr-format");
212 return (
"replace-client-name");
214 return (
"shared-networks");
216 return (
"sanity-checks");
218 return (
"config-control");
220 return (
"config-database");
222 return (
"compatibility");
224 return (
"__unknown__");
Used while parsing Dhcp6/lease-database structures.
ParserContext ctx_
Current syntactic context.
Used while parsing Dhcp6/option-def structures.
Define the isc::dhcp::parser class.
Used while parsing config-control/config-databases.
void enter(const ParserContext &ctx)
Enter a new syntactic context.
Used while parsing Dhcp6/client-classes structures.
Used while parsing Dhcp6/dhcp-queue-control structures.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Used while parsing Dhcp6/reservations structures.
isc::data::Element::Position loc2pos(isc::dhcp::location &loc)
Converts bison's position to one understandable by isc::data::Element.
This one is used in pure JSON mode.
Used while parsing Dhcp6/config-control.
boost::shared_ptr< Element > ElementPtr
Used while parsing Dhcp6/dhcp-ddns/ncr-protocol.
Used while parsing Dhcp6/dhcp-ddns/ncr-format.
virtual ~Parser6Context()
destructor
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
Used while parsing Dhcp6/*-database/on-fail.
Used while parsing Dhcp6/server-id/type structures.
Used while parsing Dhcp6/expired-leases-processing.
static void fatal(const std::string &what)
Fatal error handler.
Used while parsing Dhcp6/mac-sources structures.
Evaluation error exception raised when trying to parse.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Used while parsing Dhcp6/loggers/output_options structures.
Used while parsing content of Dhcp6.
ParserType
Defines currently supported scopes.
void leave()
Leave a syntactic context.
Used while parsing Dhcp6/*-database/type.
boost::shared_ptr< const Element > ConstElementPtr
const std::string contextName()
Get the syntactic context name.
Used while parsing Dhcp6/subnet6/pd-pools structures.
Used while parsing Dhcp6/option-data, Dhcp6/subnet6/option-data or anywhere option-data is present (c...
Used while parsing Dhcp6/hosts-database[s] structures.
Used while parsing Dhcp6/loggers structures.
void scanEnd()
Method called after the last tokens are scanned.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
Parser6Context()
Default constructor.
void error(const isc::dhcp::location &loc, const std::string &what, size_t pos=0)
Error handler.
Represents the position of the data element within a configuration string.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Used while parsing Dhcp6/interfaces structures.
ParserContext
Defines syntactic contexts for lexical tie-ins.
Used while parsing shared-networks structures.
Used while parsing Dhcp6/dhcp-ddns/replace-client-name.
void unique(const std::string &name, isc::data::Element::Position loc)
Check if a parameter is already present.
Used while parsing Dhcp6/control-socket structures.
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.
Used while parsing Dhcp6/host-reservation-identifiers.
Used while parsing compatibility parameters.
Used while parsing Dhcp6/subnet6/relay structures.
Used while parsing Dhcp6/multi-threading structures.
Used while parsing Dhcp6/subnet6/pools structures.
Used while parsing Dhcp6/reservation-mode.
Used while parsing Dhcp6/hooks-libraries.
Used while parsing Dhcp6/Subnet6 structures.
Used while parsing Dhcp6/dhcp-ddns.
Used while parsing Dhcp6/server-id structures.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.