Commit a55f3faf authored by Francis Dupont's avatar Francis Dupont Committed by Tomek Mrugalski

[5014_phase2] Add Dhcp4 and DhcpDdns toplevel configs to pass all tests

parent 2508dd15
......@@ -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.
......
......@@ -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
......
......@@ -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:
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment