]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5014_phase2] Add Dhcp4 and DhcpDdns toplevel configs to pass all tests
authorFrancis Dupont <fdupont@isc.org>
Sun, 27 Nov 2016 18:55:05 +0000 (19:55 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 29 Nov 2016 18:58:37 +0000 (19:58 +0100)
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/parser_context.cc
src/bin/dhcp6/tests/parser_unittest.cc

index b93b988ef061f65947c968e25a8bd7482a9e10a6..d8b04064edb220143ad5eaf1ac3402443bd8f32a 100644 (file)
@@ -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.
index 24567f7c40028d93aa7ac492c2bee234b9c67237..b0d1d1e1aeac249d59781e5f2cbdb9920aa665ca 100644 (file)
@@ -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
index 78aa4d8c0d43c5eb1a1e5f617e3ddcf3228e0a70..db5eec4dba8e03e188977adbadbcc4559750762d 100644 (file)
@@ -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:
index 1315fac84e4a25d909dc85c67e2b65653fd66bfa..a974237fdeb0e2a100d080e077be736359ed7399 100644 (file)
@@ -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");