switch (start_token_value) {
case Parser6Context::PARSER_DHCP6:
return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_DHCP6(driver.loc_);
+ case Parser6Context::SUBPARSER_INTERFACES6:
+ return isc::dhcp::Dhcp6Parser::make_SUB_INTERFACES6(driver.loc_);
+ case Parser6Context::SUBPARSER_SUBNET6:
+ return isc::dhcp::Dhcp6Parser::make_SUB_SUBNET6(driver.loc_);
+ case Parser6Context::SUBPARSER_POOL6:
+ return isc::dhcp::Dhcp6Parser::make_SUB_POOL6(driver.loc_);
+ case Parser6Context::SUBPARSER_PD_POOL:
+ return isc::dhcp::Dhcp6Parser::make_SUB_PD_POOL(driver.loc_);
+ case Parser6Context::SUBPARSER_HOST_RESERVATION6:
+ return isc::dhcp::Dhcp6Parser::make_SUB_RESERVATION(driver.loc_);
+ case Parser6Context::SUBPARSER_OPTION_DATA:
+ return isc::dhcp::Dhcp6Parser::make_SUB_OPTION_DATA(driver.loc_);
+ case Parser6Context::SUBPARSER_HOOKS_LIBRARY:
+ return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
case Parser6Context::PARSER_GENERIC_JSON:
default:
return isc::dhcp::Dhcp6Parser::make_TOPLEVEL_GENERIC_JSON(driver.loc_);
// parse.
TOPLEVEL_GENERIC_JSON
TOPLEVEL_DHCP6
+ SUB_INTERFACES6
+ SUB_SUBNET6
+ SUB_POOL6
+ SUB_PD_POOL
+ SUB_RESERVATION
+ SUB_OPTION_DATA
+ SUB_HOOKS_LIBRARY
;
%token <std::string> STRING "constant string"
// The whole grammar starts with a map, because the config file
// constists of Dhcp, Logger and DhcpDdns entries in one big { }.
-// %start map - this will parse everything as generic JSON
-// %start dhcp6_map - this will parse everything with Dhcp6 syntax checking
+// We made the same for subparsers.
%start start;
start: TOPLEVEL_GENERIC_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } map2
| TOPLEVEL_DHCP6 { ctx.ctx_ = ctx.CONFIG; } syntax_map
+ | SUB_INTERFACES6 { ctx.ctx_ = ctx.INTERFACES_CONFIG; } sub_interfaces6
+ | SUB_SUBNET6 { ctx.ctx_ = ctx.SUBNET6; } sub_subnet6
+ | SUB_POOL6 { ctx.ctx_ = ctx.POOLS; } sub_pool6
+ | SUB_PD_POOL { ctx.ctx_ = ctx.PD_POOLS; } sub_pd_pool
+ | SUB_RESERVATION { ctx.ctx_ = ctx.RESERVATIONS; } sub_reservation
+ | SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
+ | SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
;
// ---- generic JSON parser ---------------------------------
ctx.leave();
};
+sub_interfaces6: LCURLY_BRACKET {
+ // Parse the interfaces-config map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} interface_config_map RCURLY_BRACKET {
+ // parsing completed
+};
+
interface_config_map: INTERFACES {
ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("interfaces", l);
ctx.stack_.pop_back();
};
+sub_hooks_library: LCURLY_BRACKET {
+ // Parse the hooks-libraries list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} hooks_params RCURLY_BRACKET {
+ // parsing completed
+};
+
hooks_params: hooks_param
| hooks_params COMMA hooks_param
;
ctx.stack_.pop_back();
};
+sub_subnet6: LCURLY_BRACKET {
+ // Parse the subnet6 list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} subnet6_params RCURLY_BRACKET {
+ // parsing completed
+};
+
// This defines that subnet can have one or more parameters.
subnet6_params: subnet6_param
| subnet6_params COMMA subnet6_param
ctx.stack_.pop_back();
};
+sub_option_data: LCURLY_BRACKET {
+ // Parse the option-data list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} option_data_params RCURLY_BRACKET {
+ // parsing completed
+};
+
// This defines parameters specified inside the map that itself
// is an entry in option-data list.
option_data_params: %empty
ctx.stack_.pop_back();
};
+sub_pool6: LCURLY_BRACKET {
+ // Parse the pool list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} pool_params RCURLY_BRACKET {
+ // parsing completed
+};
+
pool_params: pool_param
| pool_params COMMA pool_param
;
ctx.stack_.pop_back();
};
+sub_pd_pool: LCURLY_BRACKET {
+ // Parse the pd-pool list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} pd_pool_params RCURLY_BRACKET {
+ // parsing completed
+};
+
pd_pool_params: pd_pool_param
| pd_pool_params COMMA pd_pool_param
;
ctx.stack_.pop_back();
};
+sub_reservation: LCURLY_BRACKET {
+ // Parse the reservations list entry map
+ ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.push_back(m);
+} reservation_params RCURLY_BRACKET {
+ // parsing completed
+};
+
reservation_params: %empty
| not_empty_reservation_params
;
/// @brief Defines currently support the content supported
typedef enum {
PARSER_GENERIC_JSON, // This will parse the content as generic JSON
- PARSER_DHCP6 // This will parse the content as DHCP6 config
+ PARSER_DHCP6, // This will parse the content as DHCP6 config
+ // DHCP6 config subparsers
+ SUBPARSER_INTERFACES6,
+ SUBPARSER_SUBNET6,
+ SUBPARSER_POOL6,
+ SUBPARSER_PD_POOL,
+ SUBPARSER_HOST_RESERVATION6,
+ // Common DHCP subparsers
+ // SUBPARSER_OPTION_DEF,
+ SUBPARSER_OPTION_DATA,
+ SUBPARSER_HOOKS_LIBRARY,
+ // SUBPARSER_CONTROL_SOCKET,
+ // SUBPARSER_D2_CLIENT,
+ // SUBPARSER_LEASE_EXPIRATION
} ParserType;
/// @brief Default constructor.