}
}
+\"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.
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
// 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 {
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
"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");