Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
a55f3faf
Commit
a55f3faf
authored
Nov 27, 2016
by
Francis Dupont
Committed by
Tomek Mrugalski
Nov 29, 2016
Browse files
[5014_phase2] Add Dhcp4 and DhcpDdns toplevel configs to pass all tests
parent
2508dd15
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp6/dhcp6_lexer.ll
View file @
a55f3faf
...
...
@@ -738,6 +738,23 @@ JSONString \"{JSONStringCharacter}*\"
}
}
\"
Dhcp4\
" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::CONFIG:
return isc::dhcp::Dhcp6Parser::make_DHCP4(loc);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("
Dhcp4
", loc);
}
}
\"
DhcpDdns\
" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::CONFIG:
return isc::dhcp::Dhcp6Parser::make_DHCPDDNS(loc);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("
DhcpDdns
", loc);
}
}
{JSONString} {
// A string has been matched. It contains the actual string and single quotes.
...
...
src/bin/dhcp6/dhcp6_parser.yy
View file @
a55f3faf
...
...
@@ -124,6 +124,9 @@ using namespace std;
ENABLE_UPDATES "enable-updates"
QUALIFYING_SUFFIX "qualifying-suffix"
DHCP4 "Dhcp4"
DHCPDDNS "DhcpDdns"
// Not real tokens, just a way to signal what the parser is expected to
// parse.
TOPLEVEL_GENERIC_JSON
...
...
@@ -256,6 +259,9 @@ global_objects: global_object
// This represents a single top level entry, e.g. Dhcp6 or DhcpDdns.
global_object: dhcp6_object
| logging_object
| dhcp4_object
| dhcpddns_object
| unknown_map_entry
;
dhcp6_object: DHCP6 {
...
...
@@ -1181,6 +1187,20 @@ qualifying_suffix: QUALIFYING_SUFFIX {
ctx.leave();
};
dhcp4_object: DHCP4 {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("Dhcp4", $4);
ctx.leave();
};
dhcpddns_object: DHCPDDNS {
ctx.enter(ctx.NO_KEYWORD);
} COLON value {
ctx.stack_.back()->set("DhcpDdns", $4);
ctx.leave();
};
%%
void
...
...
src/bin/dhcp6/parser_context.cc
View file @
a55f3faf
...
...
@@ -115,7 +115,7 @@ Parser6Context::context_name()
case
NO_KEYWORD
:
return
(
"__no keyword__"
);
case
CONFIG
:
return
(
"
__config__
"
);
return
(
"
toplevel
"
);
case
DHCP6
:
return
(
"Dhcp6"
);
case
LOGGING
:
...
...
src/bin/dhcp6/tests/parser_unittest.cc
View file @
a55f3faf
...
...
@@ -409,21 +409,27 @@ TEST(ParserTest, errors) {
"expecting }"
);
testError
(
"{ 123 }
\n
"
,
Parser6Context
::
PARSER_DHCP6
,
"<string>:1.3-5: syntax error, unexpected integer, "
"expecting Dhcp6 or Logging"
);
"<string>:1.3-5: syntax error, unexpected integer"
);
testError
(
"{
\"
foo
\"
}
\n
"
,
Parser6Context
::
PARSER_GENERIC_JSON
,
"<string>:1.9: syntax error, unexpected }, "
"expecting :"
);
testError
(
"{
\"
foo
\"
}
\n
"
,
Parser6Context
::
PARSER_DHCP6
,
"<string>:1.3-7: syntax error, unexpected constant string, "
"expecting Dhcp6 or Logging"
);
"<string>:1.9: syntax error, unexpected }, expecting :"
);
testError
(
"{
\"
foo
\"
:null }
\n
"
,
Parser6Context
::
PARSER_DHCP6
,
"<string>:1.3-7: got unexpected keyword "
"
\"
foo
\"
in toplevel map."
);
testError
(
"{
\"
Dhcp6
\"
}
\n
"
,
Parser6Context
::
PARSER_DHCP6
,
"<string>:1.11: syntax error, unexpected }, "
"expecting :"
);
testError
(
"{}{}"
,
testError
(
"{
\"
Dhcp4
\"
:[]
\n
"
,
Parser6Context
::
PARSER_DHCP6
,
"<string>:2.1: syntax error, unexpected end of file, "
"expecting
\"
,
\"
or }"
);
testError
(
"{}{}
\n
"
,
Parser6Context
::
PARSER_GENERIC_JSON
,
"<string>:1.3: syntax error, unexpected {, "
"expecting end of file"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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