mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[5014_phase2] Defined some config subparsers (to be used for tests)
This commit is contained in:
committed by
Tomek Mrugalski
parent
8d5dca26e6
commit
ad2c19f990
@@ -104,6 +104,20 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
|
||||
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_);
|
||||
|
@@ -131,6 +131,13 @@ using namespace std;
|
||||
// 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"
|
||||
@@ -146,12 +153,18 @@ using namespace std;
|
||||
|
||||
// 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 ---------------------------------
|
||||
@@ -336,6 +349,14 @@ interfaces_config: INTERFACES_CONFIG {
|
||||
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);
|
||||
@@ -517,6 +538,14 @@ hooks_library: LCURLY_BRACKET {
|
||||
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
|
||||
;
|
||||
@@ -603,6 +632,14 @@ subnet6: LCURLY_BRACKET {
|
||||
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
|
||||
@@ -683,6 +720,14 @@ option_data_entry: LCURLY_BRACKET {
|
||||
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
|
||||
@@ -761,6 +806,14 @@ pool_list_entry: LCURLY_BRACKET {
|
||||
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
|
||||
;
|
||||
@@ -809,6 +862,14 @@ pd_pool_entry: LCURLY_BRACKET {
|
||||
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
|
||||
;
|
||||
@@ -867,6 +928,14 @@ reservation: LCURLY_BRACKET {
|
||||
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
|
||||
;
|
||||
|
@@ -38,7 +38,20 @@ public:
|
||||
/// @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.
|
||||
|
Reference in New Issue
Block a user