14 #include <boost/lexical_cast.hpp> 23 : sfile_(nullptr), ctx_(NO_KEYWORD), trace_scanning_(false),
24 trace_parsing_(false) {
33 return (parseCommon());
38 FILE* f = fopen(filename.c_str(),
"r");
43 return (parseCommon());
47 Parser6Context::parseCommon() {
53 int res = parser.
parse();
73 const std::string& what,
94 const std::string& file = *loc.begin.filename;
95 const uint32_t line = loc.begin.line;
96 const uint32_t pos = loc.begin.column;
107 "missing parameter '" << name <<
"' (" 108 <<
stack_.back()->getPosition() <<
") [" 110 << open_loc <<
" and " << close_loc <<
"]");
122 <<
" map (previous at " << value->getPosition() <<
")");
125 <<
" entries in JSON" 126 <<
" map (previous at " << value->getPosition() <<
")");
133 cstack_.push_back(
ctx_);
140 if (cstack_.empty()) {
141 fatal(
"unbalanced syntactic context");
144 ctx_ = cstack_.back();
152 return (
"__no keyword__");
158 return (
"interfaces-config");
160 return (
"lease-database");
162 return (
"hosts-database");
164 return (
"database-type");
166 return (
"database-on-fail");
168 return (
"mac-sources");
170 return (
"host-reservation-identifiers");
172 return (
"hooks-libraries");
176 return (
"reservation-mode");
178 return (
"option-def");
180 return (
"option-data");
182 return (
"client-classes");
184 return (
"expired-leases-processing");
186 return (
"server-id");
188 return (
"duid-type");
190 return (
"control-socket");
192 return (
"dhcp-queue-control");
194 return (
"multi-threading");
200 return (
"reservations");
206 return (
"output-options");
208 return (
"dhcp-ddns");
210 return (
"ncr-protocol");
212 return (
"ncr-format");
214 return (
"replace-client-name");
216 return (
"shared-networks");
218 return (
"sanity-checks");
220 return (
"config-control");
222 return (
"config-database");
224 return (
"compatibility");
226 return (
"__unknown__");
232 const std::string& what) {
233 std::ostringstream msg;
234 msg << loc <<
": " << what;
241 warning(loc,
"Extraneous comma. A piece of configuration may have been omitted.");
Used while parsing Dhcp6/lease-database structures.
ParserContext ctx_
Current syntactic context.
void warnAboutExtraCommas(const isc::dhcp::location &loc)
Warning for extra commas.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
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.
void set_debug_level(debug_level_type l)
Set the current debugging level.
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.
void warning(const isc::dhcp::location &loc, const std::string &what)
Warning handler.
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-lfc.
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.
const isc::log::MessageID DHCP6_CONFIG_SYNTAX_WARNING
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.
virtual int parse()
Parse.
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.
isc::log::Logger dhcp6_logger(DHCP6_APP_LOGGER_NAME)
Base logger for DHCPv6 server.
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.