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 Parser4Context::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() <<
")");
134 cstack_.push_back(
ctx_);
141 if (cstack_.empty()) {
142 fatal(
"unbalanced syntactic context");
145 ctx_ = cstack_.back();
153 return (
"__no keyword__");
159 return (
"interfaces-config");
161 return (
"dhcp-socket-type");
163 return (
"outbound-interface");
165 return (
"lease-database");
167 return (
"hosts-database");
169 return (
"database-type");
171 return (
"database-on-fail");
173 return (
"host-reservation-identifiers");
175 return (
"hooks-libraries");
179 return (
"reservation-mode");
181 return (
"option-def");
183 return (
"option-data");
185 return (
"client-classes");
187 return (
"expired-leases-processing");
189 return (
"server-id");
191 return (
"control-socket");
193 return (
"dhcp-queue-control");
195 return (
"multi-threading");
199 return (
"reservations");
205 return (
"output-options");
207 return (
"dhcp-ddns");
209 return (
"ncr-protocol");
211 return (
"ncr-format");
213 return (
"replace-client-name");
215 return (
"shared-networks");
217 return (
"sanity-checks");
219 return (
"config-control");
221 return (
"config-database");
223 return (
"compatibility");
225 return (
"__unknown__");
231 const std::string& what) {
232 std::ostringstream msg;
233 msg << loc <<
": " << what;
240 warning(loc,
"Extraneous comma. A piece of configuration may have been omitted.");
Used while parsing Dhcp4/hosts-database[s] structures.
Used while parsing Dhcp4/*-database/on-fail.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Used while parsing Dhcp4/dhcp-ddns/ncr-protocol.
Used while parsing Dhcp4/hooks-libraries.
ParserContext
Defines syntactic contexts for lexical tie-ins.
void leave()
Leave a syntactic context.
Used while parsing Dhcp4/dhcp-ddns/ncr-format.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
Used while parsing Dhcp4/interfaces/outbound-interface structures.
Used while parsing Dhcp4/client-classes structures.
const std::string contextName()
Get the syntactic context name.
isc::data::Element::Position loc2pos(isc::dhcp::location &loc)
Converts bison's position to one understandable by isc::data::Element.
Used while parsing Dhcp4/*-database/type.
Used while parsing Dhcp4/host-reservation-identifiers.
Used while parsing Dhcp4/multi-threading structures.
boost::shared_ptr< Element > ElementPtr
void enter(const ParserContext &ctx)
Enter a new syntactic context.
Used while parsing Dhcp4/reservations structures.
Used while parsing Dhcp4/lease-database structures.
void scanEnd()
Method called after the last tokens are scanned.
Used while parsing Dhcp4/dhcp-ddns.
Used while parsing Dhcp4/interfaces/dhcp-socket-type structures.
Used while parsing Dhcp4/server-id structures.
isc::data::ElementPtr parseString(const std::string &str, ParserType parser_type)
Run the parser on the string specified.
Define the isc::dhcp::parser class.
Used while parsing Dhcp4/control-socket structures.
virtual int parse()
Parse.
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
Used while parsing Dhcp4/subnet4/pools structures.
Parser4Context()
Default constructor.
Used while parsing Dhcp4/dhcp-queue-control structures.
Used while parsing shared-networks structures.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ParserContext ctx_
Current syntactic context.
std::vector< isc::data::ElementPtr > stack_
JSON elements being parsed.
Used while parsing Dhcp4/dhcp-ddns/replace-client-name.
Used while parsing Dhcp4/loggers/output_options structures.
ParserType
Defines currently supported scopes.
boost::shared_ptr< const Element > ConstElementPtr
Used while parsing Dhcp4/Subnet4 structures.
void scanFileBegin(FILE *f, const std::string &filename, ParserType type)
Method called before scanning starts on a file.
Evaluation error exception raised when trying to parse.
Used while parsing Dhcp4/option-def structures.
Used while parsing Dhcp4/option-data, Dhcp4/subnet4/option-data or anywhere option-data is present (c...
Used while parsing Dhcp4/interfaces structures.
Used while parsing content of Dhcp4.
Represents the position of the data element within a configuration string.
Used while parsing Dhcp4/subnet4relay 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.
Defines the logger used by the top-level component of kea-lfc.
void set_debug_level(debug_level_type l)
Set the current debugging level.
void warnAboutExtraCommas(const isc::dhcp::location &loc)
Warning for extra commas.
Used while parsing Dhcp4/loggers structures.
This one is used in pure JSON mode.
Used while parsing compatibility parameters.
void scanStringBegin(const std::string &str, ParserType type)
Method called before scanning starts on a string.
void unique(const std::string &name, isc::data::Element::Position loc)
Check if a parameter is already present.
void error(const isc::dhcp::location &loc, const std::string &what, size_t pos=0)
Error handler.
Used while parsing Dhcp4/expired-leases-processing.
Used while parsing config-control/config-databases.
static void fatal(const std::string &what)
Fatal error handler.
Contains declarations for loggers used by the DHCPv4 server component.
virtual ~Parser4Context()
destructor
Used while parsing Dhcp4/config-control.
Used while parsing Dhcp4/reservation-mode.
void warning(const isc::dhcp::location &loc, const std::string &what)
Warning handler.
const isc::log::MessageID DHCP4_CONFIG_SYNTAX_WARNING