const std::string& keyword = $1;
error(@1,
"got unexpected keyword \"" + keyword + "\" in " + where + " map.");
-}
+};
// This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
hooks_params: hooks_param
| hooks_params COMMA hooks_param
+ | unknown_map_entry
;
hooks_param: library
- | parameters;
+ | parameters
+ ;
library: LIBRARY {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("parameters", $4);
ctx.leave();
-}
+};
// --- expired-leases-processing ------------------------
expired_leases_processing: EXPIRED_LEASES_PROCESSING {
expired_leases_param: STRING COLON INTEGER {
ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set($1, value);
-}
+};
// --- subnet6 ------------------------------------------
// This defines subnet6 as a list of maps.
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("prefix", prf);
ctx.leave();
-}
+};
pd_prefix_len: PREFIX_LEN COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("prefix-len", prf);
-}
+};
excluded_prefix: EXCLUDED_PREFIX {
ctx.enter(ctx.NO_KEYWORD);
ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("excluded-prefix", prf);
ctx.leave();
-}
+};
excluded_prefix_len: EXCLUDED_PREFIX_LEN COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("excluded-prefix-len", prf);
-}
+};
pd_delegated_len: DELEGATED_LEN COLON INTEGER {
ElementPtr deleg(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("delegated-len", deleg);
-}
+};
// --- end of pd-pools ---------------------------------------
ElementPtr host(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("hostname", host);
ctx.leave();
-}
+};
reservation_client_classes: CLIENT_CLASSES {
ElementPtr c(new ListElement(ctx.loc2pos(@1)));
ElementPtr test(new StringElement($4, ctx.loc2pos(@4)));
ctx.stack_.back()->set("test", test);
ctx.leave();
-}
+};
// --- end of client classes ---------------------------------
/// @brief Defines currently supported scopes
///
- /// Dhcp6Parser is able to parse several types of scope. Usually, when it
- /// parses a config file, it expects the data to have a map with Dhcp6 in it
- /// and all the parameters within that Dhcp6 map. However, sometimes the
- /// parser is expected to parse only a subset of that information. For example,
- /// it may be asked to parse a structure that is host-reservation only, without
- /// the global 'Dhcp6' or 'reservations' around it. In such case the parser
- /// is being told to start parsing as SUBPARSER_HOST_RESERVATION6.
+ /// Dhcp6Parser is able to parse several types of scope. Usually,
+ /// when it parses a config file, it expects the data to have a map
+ /// with Dhcp6 in it and all the parameters within that Dhcp6 map.
+ /// However, sometimes the parser is expected to parse only a subset
+ /// of that information. For example, it may be asked to parse
+ /// a structure that is host-reservation only, without the global
+ /// 'Dhcp6' or 'reservations' around it. In such case the parser
+ /// is being told to start parsing as PARSER_HOST_RESERVATION6.
typedef enum {
/// This parser will parse the content as generic JSON.
PARSER_JSON,
/// contents of it.
SUBPARSER_DHCP6,
+ /// This will parse the input as interfaces content.
+ PARSER_INTERFACES,
+
/// This will parse the input as Subnet6 content.
PARSER_SUBNET6,
/// This will parse the input as pool6 content.
PARSER_POOL6,
- /// This will parse the input as interfaces content.
- PARSER_INTERFACES,
-
/// This will parse the input as pd-pool content.
PARSER_PD_POOL,
std::vector<isc::data::ElementPtr> stack_;
/// @brief Method called before scanning starts on a string.
+ ///
+ /// @param str string to be parsed
+ /// @param parser_type specifies expected content
void scanStringBegin(const std::string& str, ParserType type);
/// @brief Method called before scanning starts on a file.
- void scanFileBegin(FILE * f, const std::string& filename, ParserType type);
+ ///
+ /// @param f stdio FILE pointer
+ /// @param filename file to be parsed
+ /// @param parser_type specifies expected content
+ void scanFileBegin(FILE* f, const std::string& filename, ParserType type);
/// @brief Method called after the last tokens are scanned.
void scanEnd();
/// @brief Divert input to an include file.
+ ///
+ /// @param filename file to be included
void includeFile(const std::string& filename);
/// @brief Run the parser on the string specified.
///
/// @param loc location within the parsed file when experienced a problem.
/// @param what string explaining the nature of the error.
+ /// @throw Dhcp6ParseError
void error(const isc::dhcp::location& loc, const std::string& what);
/// @brief Error handler
///
/// This is a simplified error reporting tool for possible future
/// cases when the Dhcp6Parser is not able to handle the packet.
+ ///
+ /// @param what string explaining the nature of the error.
+ /// @throw Dhcp6ParseError
void error(const std::string& what);
/// @brief Fatal error handler
///
/// This is for should not happen but fatal errors.
/// Used by YY_FATAL_ERROR macro so required to be static.
+ ///
+ /// @param what string explaining the nature of the error.
+ /// @throw Dhcp6ParseError
static void fatal(const std::string& what);
/// @brief Converts bison's position to one understandable by isc::data::Element
///
/// Convert a bison location into an element position
/// (take the begin, the end is lost)
- /// @brief loc location in bison format
+ ///
+ /// @param loc location in bison format
/// @return Position in format accepted by Element
isc::data::Element::Position loc2pos(isc::dhcp::location& loc);
/// Used while parsing Dhcp6/interfaces structures.
INTERFACES_CONFIG,
- /// Used while parsing Dhcp6/hosts-database structures.
- HOSTS_DATABASE,
-
/// Used while parsing Dhcp6/lease-database structures.
LEASE_DATABASE,
+ /// Used while parsing Dhcp6/hosts-database structures.
+ HOSTS_DATABASE,
+
/// Used while parsing Dhcp6/mac-sources structures.
MAC_SOURCES,
/// will return STRING token if in JSON mode or RENEW_TIMER if
/// in DHCP6 mode. Finally, the stntactic context allows the
/// error message to be more descriptive.
+ ///
+ /// @param ctx the syntactic context to enter into
void enter(const ParserContext& ctx);
/// @brief Leave a syntactic context
+ ///
/// @throw isc::Unexpected if unbalanced
void leave();
/// @brief Get the syntactix context name
+ ///
/// @return printable name of the context.
const std::string contextName();
std::vector<ParserContext> cstack_;
/// @brief Common part of parseXXX
+ ///
+ /// @return Element structure representing parsed text.
isc::data::ConstElementPtr parseCommon();
};