Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Adam Osuchowski
Kea
Commits
ad2c19f9
Commit
ad2c19f9
authored
Nov 28, 2016
by
Francis Dupont
Committed by
Tomek Mrugalski
Nov 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5014_phase2] Defined some config subparsers (to be used for tests)
parent
8d5dca26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
3 deletions
+99
-3
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_lexer.ll
+14
-0
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/dhcp6_parser.yy
+71
-2
src/bin/dhcp6/parser_context.h
src/bin/dhcp6/parser_context.h
+14
-1
No files found.
src/bin/dhcp6/dhcp6_lexer.ll
View file @
ad2c19f9
...
...
@@ -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_
)
;
...
...
src/bin/dhcp6/dhcp6_parser.yy
View file @
ad2c19f9
...
...
@@ -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
;
...
...
src/bin/dhcp6/parser_context.h
View file @
ad2c19f9
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment