]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#916] Checkpoint before regen 2
authorFrancis Dupont <fdupont@isc.org>
Fri, 29 May 2020 16:10:16 +0000 (18:10 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 8 Jul 2020 12:32:45 +0000 (14:32 +0200)
12 files changed:
src/bin/agent/agent_lexer.ll
src/bin/agent/agent_parser.yy
src/bin/agent/parser_context.cc
src/bin/agent/parser_context.h
src/bin/d2/d2_lexer.ll
src/bin/d2/d2_parser.yy
src/bin/d2/parser_context.cc
src/bin/d2/parser_context.h
src/bin/netconf/netconf_lexer.ll
src/bin/netconf/netconf_parser.yy
src/bin/netconf/parser_context.cc
src/bin/netconf/parser_context.h

index e96227224c7445b3251527fc1382a4eb3caf508f..c4331a5b8e3251081731c53b76812b25ef70f8ed 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -312,19 +312,9 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
-\"Logging\" {
-    switch(driver.ctx_) {
-    case ParserContext::CONFIG:
-        return AgentParser::make_LOGGING(driver.loc_);
-    default:
-        return AgentParser::make_STRING("Logging", driver.loc_);
-    }
-}
-
 \"loggers\" {
     switch(driver.ctx_) {
     case ParserContext::AGENT:
-    case ParserContext::LOGGING:
         return AgentParser::make_LOGGERS(driver.loc_);
     default:
         return AgentParser::make_STRING("loggers", driver.loc_);
@@ -412,33 +402,6 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
-\"Dhcp4\" {
-    switch(driver.ctx_) {
-    case ParserContext::CONFIG:
-        return AgentParser::make_DHCP4(driver.loc_);
-    default:
-        return AgentParser::make_STRING("Dhcp4", driver.loc_);
-    }
-}
-
-\"Dhcp6\" {
-    switch(driver.ctx_) {
-    case ParserContext::CONFIG:
-        return AgentParser::make_DHCP6(driver.loc_);
-    default:
-        return AgentParser::make_STRING("Dhcp6", driver.loc_);
-    }
-}
-
-\"DhcpDdns\" {
-    switch(driver.ctx_) {
-    case ParserContext::CONFIG:
-        return AgentParser::make_DHCPDDNS(driver.loc_);
-    default:
-        return AgentParser::make_STRING("DhcpDdns", driver.loc_);
-    }
-}
-
 {JSONString} {
     /* A string has been matched. It contains the actual string and single quotes.
        We need to get those quotes out of the way and just use its content, e.g.
index 9ee2c012bc8d358b971b53f156fe29a6452f5045..89a60eba1da98fe22de28869d21dce178df09baa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -67,7 +67,6 @@ using namespace std;
   LIBRARY "library"
   PARAMETERS "parameters"
 
-  LOGGING "Logging"
   LOGGERS "loggers"
   NAME "name"
   OUTPUT_OPTIONS "output_options"
@@ -79,10 +78,6 @@ using namespace std;
   MAXVER "maxver"
   PATTERN "pattern"
 
-  DHCP4 "Dhcp4"
-  DHCP6 "Dhcp6"
-  DHCPDDNS "DhcpDdns"
-
   // Not real tokens, just a way to signal what the parser is expected to
   // parse. This define the starting point. It either can be full grammar
   // (START_AGENT), part of the grammar related to control-agent (START_SUB_AGENT)
@@ -106,7 +101,7 @@ using namespace std;
 %%
 
 // The whole grammar starts with a map, because the config file
-// consists of Control-Agent, DhcpX, Logger and DhcpDdns entries in one big { }.
+// consists of only Control-Agent entry in one big { }.
 %start start;
 
 // The starting token can be one of those listed below. Note these are
@@ -219,8 +214,7 @@ unknown_map_entry: STRING COLON {
           "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
 };
 
-// This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
-// DhcpDdns or Logging objects.
+// This defines the top-level { } that holds only Control-agent object.
 agent_syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // the content of the map
@@ -232,18 +226,12 @@ agent_syntax_map: LCURLY_BRACKET {
     // for it.
 };
 
-// This represents top-level entries: Control-agent, Logging, possibly others
+// This represents top-level entries: Control-agent.
 global_objects: global_object
-              | global_objects COMMA global_object
               ;
 
-// This represents a single top level entry, e.g. Control-agent, Dhcp6 or DhcpDdns.
+// This represents a single top level entry, e.g. Control-agent.
 global_object: agent_object
-             | logging_object
-             | dhcp4_json_object
-             | dhcp6_json_object
-             | dhcpddns_json_object
-             | unknown_map_entry
              ;
 
 // This define the Control-agent object.
@@ -493,55 +481,8 @@ socket_type_value : UNIX { $$ = ElementPtr(new StringElement("unix", ctx.loc2pos
 
 // --- control-sockets end here ------------------------------------------------
 
-// JSON entries for other global objects (Dhcp4,Dhcp6 and DhcpDdns)
-dhcp4_json_object: DHCP4 {
-    ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
-    ctx.stack_.back()->set("Dhcp4", $4);
-    ctx.leave();
-};
-
-dhcp6_json_object: DHCP6 {
-    ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
-    ctx.stack_.back()->set("Dhcp6", $4);
-    ctx.leave();
-};
-
-dhcpddns_json_object: DHCPDDNS {
-    ctx.enter(ctx.NO_KEYWORDS);
-} COLON value {
-    ctx.stack_.back()->set("DhcpDdns", $4);
-    ctx.leave();
-};
-
-// --- Logging starts here -----------------------------------------------------
-
-// This defines the top level "Logging" object. It parses
-// the following "Logging": { ... }. The ... is defined
-// by logging_params
-logging_object: LOGGING {
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->set("Logging", m);
-    ctx.stack_.push_back(m);
-    ctx.enter(ctx.LOGGING);
-} COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-    ctx.leave();
-};
-
-// This defines the list of allowed parameters that may appear
-// in the top-level Logging object. It can either be a single
-// parameter or several parameters separated by commas.
-logging_params: logging_param
-              | logging_params COMMA logging_param
-              ;
-
-// There's currently only one parameter defined, which is "loggers".
-logging_param: loggers;
+// --- Loggers starts here -----------------------------------------------------
 
-// "loggers", the only parameter currently defined in "Logging" object,
-// is "Loggers": [ ... ].
 loggers: LOGGERS {
     ElementPtr l(new ListElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->set("loggers", l);
@@ -558,7 +499,7 @@ loggers_entries: logger_entry
                | loggers_entries COMMA logger_entry
                ;
 
-// This defines a single entry defined in loggers in Logging.
+// This defines a single entry defined in loggers.
 logger_entry: LCURLY_BRACKET {
     ElementPtr l(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->add(l);
index 9f389d76affb12e09276d199f8b69343ec8ffe23..1c48fc0cd96aa6df8b4ef2b75978fbe9c922307a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -123,8 +123,6 @@ ParserContext::contextName()
         return ("toplevel");
     case AGENT:
         return ("Control-agent");
-    case LOGGING:
-        return ("Logging");
     case CONTROL_SOCKETS:
         return ("control-sockets");
     case SERVER:
index c7271a89ea58a956b9c757de9ae0f55ef6abe7e9..d03dd0e41cf51fe3ac5fffae4d58b713c31d7734 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -152,15 +152,12 @@ public:
         ///< This one is used in pure JSON mode.
         NO_KEYWORDS,
 
-        ///< Used while parsing top level (that contains Control-agent, Logging and others)
+        ///< Used while parsing top level (that contains Control-agent)
         CONFIG,
 
         ///< Used while parsing content of Agent.
         AGENT,
 
-        ///< Used while parsing content of Logging.
-        LOGGING,
-
         ///< Used while parsing Control-agent/control-sockets.
         CONTROL_SOCKETS,
 
index e28d3dce57c1ec7246c4fc4a08438b341586cd19..689a41531e954a6798dac4a4aa0bb19bf4980661 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -419,20 +419,9 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
-
-\"Logging\" {
-    switch(driver.ctx_) {
-    case isc::d2::D2ParserContext::CONFIG:
-        return isc::d2::D2Parser::make_LOGGING(driver.loc_);
-    default:
-        return isc::d2::D2Parser::make_STRING("Logging", driver.loc_);
-    }
-}
-
 \"loggers\" {
     switch(driver.ctx_) {
     case isc::d2::D2ParserContext::DHCPDDNS:
-    case isc::d2::D2ParserContext::LOGGING:
         return isc::d2::D2Parser::make_LOGGERS(driver.loc_);
     default:
         return isc::d2::D2Parser::make_STRING("loggers", driver.loc_);
@@ -524,34 +513,6 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
-\"Dhcp4\" {
-    switch(driver.ctx_) {
-    case isc::d2::D2ParserContext::CONFIG:
-        return isc::d2::D2Parser::make_DHCP4(driver.loc_);
-    default:
-        return isc::d2::D2Parser::make_STRING("Dhcp4", driver.loc_);
-    }
-}
-
-\"Dhcp6\" {
-    switch(driver.ctx_) {
-    case isc::d2::D2ParserContext::CONFIG:
-        return isc::d2::D2Parser::make_DHCP6(driver.loc_);
-    default:
-        return isc::d2::D2Parser::make_STRING("Dhcp6", driver.loc_);
-    }
-}
-
-\"Control-agent\" {
-    switch(driver.ctx_) {
-    case isc::d2::D2ParserContext::CONFIG:
-        return isc::d2::D2Parser::make_CONTROL_AGENT(driver.loc_);
-    default:
-        return isc::d2::D2Parser::make_STRING("Control-agent", driver.loc_);
-    }
-}
-
-
 {JSONString} {
     /* A string has been matched. It contains the actual string and single quotes.
        We need to get those quotes out of the way and just use its content, e.g.
index 0130e7a62ef3e5c928fc36b3bcf2c5768fa4db58..4c7a67f014580cefde789ab972408be71cf75808 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -49,10 +49,6 @@ using namespace std;
   RCURLY_BRACKET "}"
   NULL_TYPE "null"
 
-  DHCP6 "Dhcp6"
-  DHCP4 "Dhcp4"
-  CONTROL_AGENT "Control-agent"
-
   DHCPDDNS "DhcpDdns"
   IP_ADDRESS "ip-address"
   PORT "port"
@@ -79,7 +75,6 @@ using namespace std;
   SOCKET_TYPE "socket-type"
   SOCKET_NAME "socket-name"
 
-  LOGGING "Logging"
   LOGGERS "loggers"
   NAME "name"
   OUTPUT_OPTIONS "output_options"
@@ -215,8 +210,7 @@ unknown_map_entry: STRING COLON {
 };
 
 
-// This defines the top-level { } that holds Control-agent, Dhcp6, Dhcp4,
-// DhcpDdns or Logging objects.
+// This defines the top-level { } that holds only DhcpDdns object.
 syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // the content of the map
@@ -228,18 +222,12 @@ syntax_map: LCURLY_BRACKET {
     // for it.
 };
 
-// This represents top-level entries: Dhcp6, Dhcp4, DhcpDdns, Logging
+// This represents top-level entries: DhcpDdns.
 global_objects: global_object
-              | global_objects COMMA global_object
               ;
 
-// This represents a single top level entry, e.g. Dhcp6 or DhcpDdns.
-global_object: dhcp6_json_object
-             | logging_object
-             | dhcp4_json_object
-             | dhcpddns_object
-             | control_agent_json_object
-             | unknown_map_entry
+// This represents a single top level entry, e.g. DhcpDdns.
+global_object: dhcpddns_object
              ;
 
 // --- dhcp ddns ---------------------------------------------
@@ -711,55 +699,8 @@ control_socket_name: SOCKET_NAME {
     ctx.leave();
 };
 
-// ----------------------------------------------------------------
-
-dhcp6_json_object: DHCP6 {
-    ctx.enter(ctx.NO_KEYWORD);
-} COLON value {
-    ctx.stack_.back()->set("Dhcp6", $4);
-    ctx.leave();
-};
-
-dhcp4_json_object: DHCP4 {
-    ctx.enter(ctx.NO_KEYWORD);
-} COLON value {
-    ctx.stack_.back()->set("Dhcp4", $4);
-    ctx.leave();
-};
-
-control_agent_json_object: CONTROL_AGENT {
-    ctx.enter(ctx.NO_KEYWORD);
-} COLON value {
-    ctx.stack_.back()->set("Control-agent", $4);
-    ctx.leave();
-};
-
-// --- logging entry -----------------------------------------
-
-// This defines the top level "Logging" object. It parses
-// the following "Logging": { ... }. The ... is defined
-// by logging_params
-logging_object: LOGGING {
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->set("Logging", m);
-    ctx.stack_.push_back(m);
-    ctx.enter(ctx.LOGGING);
-} COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-    ctx.leave();
-};
-
-// This defines the list of allowed parameters that may appear
-// in the top-level Logging object. It can either be a single
-// parameter or several parameters separated by commas.
-logging_params: logging_param
-              | logging_params COMMA logging_param
-              ;
-
-// There's currently only one parameter defined, which is "loggers".
-logging_param: loggers;
+// --- loggers entry -----------------------------------------
 
-// "loggers", the only parameter currently defined in "Logging" object,
 // is "Loggers": [ ... ].
 loggers: LOGGERS {
     ElementPtr l(new ListElement(ctx.loc2pos(@1)));
@@ -777,7 +718,7 @@ loggers_entries: logger_entry
                | loggers_entries COMMA logger_entry
                ;
 
-// This defines a single entry defined in loggers in Logging.
+// This defines a single entry defined in loggers.
 logger_entry: LCURLY_BRACKET {
     ElementPtr l(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->add(l);
index 7532d64a3a6ed88bc2bc7092c65d7c7fad2fdbe6..18a3cd61dc32240532403e82b657f17590753f5e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -144,8 +144,6 @@ D2ParserContext::contextName()
         return("dns-servers");
     case CONTROL_SOCKET:
         return("control-socket");
-    case LOGGING:
-        return ("Logging");
     case LOGGERS:
         return ("loggers");
     case OUTPUT_OPTIONS:
index 179862ea84f635bab7eb8d43a1b88e63d2143aa2..de3dddd3230e0996c1a8e6993326833cef098aac 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -48,7 +48,7 @@ public:
         /// This parser will parse the content as generic JSON.
         PARSER_JSON,
 
-        ///< Used for parsing top level (contains DhcpDdns, Logging, others)
+        ///< Used for parsing top level (contains DhcpDdns)
         PARSER_DHCPDDNS,
 
         ///< Used for parsing content of DhcpDdns.
@@ -165,7 +165,7 @@ public:
         ///< This one is used in pure JSON mode.
         NO_KEYWORD,
 
-        ///< Used while parsing top level (contains DhcpDdns, Logging, ...)
+        ///< Used while parsing top level (contains DhcpDdns).
         CONFIG,
 
         ///< Used while parsing content of DhcpDdns.
@@ -207,9 +207,6 @@ public:
         ///< Used while parsing content of a control-socket
         CONTROL_SOCKET,
 
-        ///< Used while parsing content of Logging
-        LOGGING,
-
         /// Used while parsing DhcpDdns/loggers structures.
         LOGGERS,
 
index c0227c9b8fca60f6001754b5c0c06b89c990d5a0..3886a35459b39a6f7a273f2f63afae6b3f60e0a9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -380,19 +380,9 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
-\"Logging\" {
-    switch(driver.ctx_) {
-    case ParserContext::CONFIG:
-        return NetconfParser::make_LOGGING(driver.loc_);
-    default:
-        return NetconfParser::make_STRING("Logging", driver.loc_);
-    }
-}
-
 \"loggers\" {
     switch(driver.ctx_) {
     case ParserContext::NETCONF:
-    case ParserContext::LOGGING:
         return NetconfParser::make_LOGGERS(driver.loc_);
     default:
         return NetconfParser::make_STRING("loggers", driver.loc_);
index 438e253fb38c4977315c2944c8d99f28f956123b..a72e93e045181dc2ef475dbc660bd930793e517b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -75,7 +75,6 @@ using namespace std;
   LIBRARY "library"
   PARAMETERS "parameters"
 
-  LOGGING "Logging"
   LOGGERS "loggers"
   NAME "name"
   OUTPUT_OPTIONS "output_options"
@@ -223,7 +222,7 @@ unknown_map_entry: STRING COLON {
           "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
 };
 
-// This defines the top-level { } that holds Netconf or Logging objects.
+// This defines the top-level { } that holds Netconf object.
 netconf_syntax_map: LCURLY_BRACKET {
     // This code is executed when we're about to start parsing
     // the content of the map
@@ -235,14 +234,13 @@ netconf_syntax_map: LCURLY_BRACKET {
     // for it.
 };
 
-// This represents top-level entries: Netconf, Logging, possibly others
+// This represents top-level entries: Netconf.
 global_objects: global_object
               | global_objects COMMA global_object
               ;
 
-// This represents a single top level entry, e.g. Netconf or Logging.
+// This represents a single top level entry, e.g. Netconf.
 global_object: netconf_object
-             | logging_object
              ;
 
 // This define the Netconf object.
@@ -252,6 +250,9 @@ netconf_object: NETCONF {
     // top level map (that's already on the stack) and put the new map
     // on the stack as well, so child elements will be able to add
     // themselves to it.
+
+    // Prevent against duplicate.
+    ctx.unique("Netconf, ctx.loc2pos(@1));
     ElementPtr m(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->set("Netconf", m);
     ctx.stack_.push_back(m);
@@ -558,33 +559,8 @@ socket_url: SOCKET_URL {
 
 // --- managed-servers end here ------------------------------------------------
 
-// --- Logging starts here -----------------------------------------------------
-
-// This defines the top level "Logging" object. It parses
-// the following "Logging": { ... }. The ... is defined
-// by logging_params
-logging_object: LOGGING {
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->set("Logging", m);
-    ctx.stack_.push_back(m);
-    ctx.enter(ctx.LOGGING);
-} COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-    ctx.leave();
-};
-
-// This defines the list of allowed parameters that may appear
-// in the top-level Logging object. It can either be a single
-// parameter or several parameters separated by commas.
-logging_params: logging_param
-              | logging_params COMMA logging_param
-              ;
-
-// There's currently only one parameter defined, which is "loggers".
-logging_param: loggers;
+// --- Loggers starts here -----------------------------------------------------
 
-// "loggers", the only parameter currently defined in "Logging" object,
-// is "Loggers": [ ... ].
 loggers: LOGGERS {
     ElementPtr l(new ListElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->set("loggers", l);
@@ -601,7 +577,7 @@ loggers_entries: logger_entry
                | loggers_entries COMMA logger_entry
                ;
 
-// This defines a single entry defined in loggers in Logging.
+// This defines a single entry defined in loggers.
 logger_entry: LCURLY_BRACKET {
     ElementPtr l(new MapElement(ctx.loc2pos(@1)));
     ctx.stack_.back()->add(l);
index 154c5627b56d4c47e682825f24b42461984308a6..aa437d3b4cca5794b9f03b5dc055f3cf339d349f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -111,6 +111,18 @@ ParserContext::require(const std::string& name,
     }
 }
 
+void
+ParserContext::unique(const std::string& name,
+                      isc::data::Element::Position loc)
+{
+    ConstElementPtr value = stack_.back()->get(name);
+    if (value) {
+        isc_throw(ParseError, loc << ": duplicate " << name
+                  << " entries in " << contextName()
+                  << " map (previous at " << value->getPosition() << ")");
+    }
+}
+
 void
 ParserContext::enter(const LexerContext& ctx)
 {
@@ -138,8 +150,6 @@ ParserContext::contextName()
         return ("toplevel");
     case NETCONF:
         return ("Netconf");
-    case LOGGING:
-        return ("Logging");
     case MANAGED_SERVERS:
         return ("managed-servers");
     case SERVER:
index b83fc09ecb50b26fb2a18747cf647c317d8432ed..c1ac1f897bca2c5f634eb3e51c386e2dd0e61dbb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -161,20 +161,28 @@ public:
                  isc::data::Element::Position open_loc,
                  isc::data::Element::Position close_loc);
 
+    /// @brief Check if a parameter is already present
+    ///
+    /// Check if a parameter is already present in the map at the top
+    /// of the stack and raise an error when it is.
+    ///
+    /// @param name name of the parameter to check
+    /// @param loc location of the current parameter
+    /// @throw ParseError
+    void unique(const std::string& name,
+                isc::data::Element::Position loc);
+
     /// @brief Defines syntactic contexts for lexical tie-ins
     typedef enum {
         ///< This one is used in pure JSON mode.
         NO_KEYWORDS,
 
-        ///< Used while parsing top level (that contains Netconf, Logging and others)
+        ///< Used while parsing top level (that contains Netconf)
         CONFIG,
 
         ///< Used while parsing content of Netconf.
         NETCONF,
 
-        ///< Used while parsing content of Logging.
-        LOGGING,
-
         /// Used while parsing Netconf/managed-servers.
         MANAGED_SERVERS,