Browse Source

[5020fd] Unspecialized raw/udp, added new syntactic context

Francis Dupont 8 years ago
parent
commit
01622260e4

+ 4 - 6
src/bin/dhcp4/dhcp4_lexer.cc

@@ -1670,10 +1670,9 @@ case 15:
 YY_RULE_SETUP
 #line 199 "dhcp4_lexer.ll"
 {
-    std::cout << "RAW regexp" << std::endl;
     switch(driver.ctx_) {
-    case isc::dhcp::Parser4Context::INTERFACES_CONFIG:
-        return  isc::dhcp::Dhcp4Parser::make_DHCP_SOCKET_TYPE_RAW(driver.loc_);
+    case isc::dhcp::Parser4Context::DHCP_SOCKET_TYPE:
+        return  isc::dhcp::Dhcp4Parser::make_RAW(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("raw", driver.loc_);
     }
@@ -1683,10 +1682,9 @@ case 16:
 YY_RULE_SETUP
 #line 209 "dhcp4_lexer.ll"
 {
-    std::cout << "RAW regexp" << std::endl;
     switch(driver.ctx_) {
-    case isc::dhcp::Parser4Context::INTERFACES_CONFIG:
-        return  isc::dhcp::Dhcp4Parser::make_DHCP_SOCKET_TYPE_UDP(driver.loc_);
+    case isc::dhcp::Parser4Context::DHCP_SOCKET_TYPE:
+        return  isc::dhcp::Dhcp4Parser::make_UDP(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("udp", driver.loc_);
     }

+ 5 - 7
src/bin/dhcp4/dhcp4_lexer.ll

@@ -1,4 +1,4 @@
-/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2017 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
@@ -197,20 +197,18 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
 }
 
 \"raw\" {
-    std::cout << "RAW regexp" << std::endl;
     switch(driver.ctx_) {
-    case isc::dhcp::Parser4Context::INTERFACES_CONFIG:
-        return  isc::dhcp::Dhcp4Parser::make_DHCP_SOCKET_TYPE_RAW(driver.loc_);
+    case isc::dhcp::Parser4Context::DHCP_SOCKET_TYPE:
+        return  isc::dhcp::Dhcp4Parser::make_RAW(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("raw", driver.loc_);
     }
 }
 
 \"udp\" {
-    std::cout << "RAW regexp" << std::endl;
     switch(driver.ctx_) {
-    case isc::dhcp::Parser4Context::INTERFACES_CONFIG:
-        return  isc::dhcp::Dhcp4Parser::make_DHCP_SOCKET_TYPE_UDP(driver.loc_);
+    case isc::dhcp::Parser4Context::DHCP_SOCKET_TYPE:
+        return  isc::dhcp::Dhcp4Parser::make_UDP(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("udp", driver.loc_);
     }

File diff suppressed because it is too large
+ 847 - 826
src/bin/dhcp4/dhcp4_parser.cc


+ 19 - 14
src/bin/dhcp4/dhcp4_parser.h

@@ -40,7 +40,7 @@
 #ifndef YY_PARSER4_DHCP4_PARSER_H_INCLUDED
 # define YY_PARSER4_DHCP4_PARSER_H_INCLUDED
 // //                    "%code requires" blocks.
-#line 17 "dhcp4_parser.yy" // lalr1.cc:377
+#line 17 "dhcp4_parser.yy" // lalr1.cc:392
 
 #include <string>
 #include <cc/data.h>
@@ -52,7 +52,7 @@ using namespace isc::dhcp;
 using namespace isc::data;
 using namespace std;
 
-#line 56 "dhcp4_parser.h" // lalr1.cc:377
+#line 56 "dhcp4_parser.h" // lalr1.cc:392
 
 # include <cassert>
 # include <cstdlib> // std::abort
@@ -135,9 +135,9 @@ using namespace std;
 # endif /* ! defined YYDEBUG */
 #endif  /* ! defined PARSER4_DEBUG */
 
-#line 14 "dhcp4_parser.yy" // lalr1.cc:377
+#line 14 "dhcp4_parser.yy" // lalr1.cc:392
 namespace isc { namespace dhcp {
-#line 141 "dhcp4_parser.h" // lalr1.cc:377
+#line 141 "dhcp4_parser.h" // lalr1.cc:392
 
 
 
@@ -305,6 +305,7 @@ namespace isc { namespace dhcp {
     union union_type
     {
       // value
+      // socket_type
       char dummy1[sizeof(ElementPtr)];
 
       // "boolean"
@@ -352,8 +353,8 @@ namespace isc { namespace dhcp {
         TOKEN_INTERFACES_CONFIG = 266,
         TOKEN_INTERFACES = 267,
         TOKEN_DHCP_SOCKET_TYPE = 268,
-        TOKEN_DHCP_SOCKET_TYPE_RAW = 269,
-        TOKEN_DHCP_SOCKET_TYPE_UDP = 270,
+        TOKEN_RAW = 269,
+        TOKEN_UDP = 270,
         TOKEN_ECHO_CLIENT_ID = 271,
         TOKEN_MATCH_CLIENT_ID = 272,
         TOKEN_NEXT_SERVER = 273,
@@ -606,11 +607,11 @@ namespace isc { namespace dhcp {
 
     static inline
     symbol_type
-    make_DHCP_SOCKET_TYPE_RAW (const location_type& l);
+    make_RAW (const location_type& l);
 
     static inline
     symbol_type
-    make_DHCP_SOCKET_TYPE_UDP (const location_type& l);
+    make_UDP (const location_type& l);
 
     static inline
     symbol_type
@@ -1262,6 +1263,7 @@ namespace isc { namespace dhcp {
       switch (other.type_get ())
     {
       case 116: // value
+      case 155: // socket_type
         value.copy< ElementPtr > (other.value);
         break;
 
@@ -1299,6 +1301,7 @@ namespace isc { namespace dhcp {
       switch (this->type_get ())
     {
       case 116: // value
+      case 155: // socket_type
         value.copy< ElementPtr > (v);
         break;
 
@@ -1395,6 +1398,7 @@ namespace isc { namespace dhcp {
     switch (yytype)
     {
       case 116: // value
+      case 155: // socket_type
         value.template destroy< ElementPtr > ();
         break;
 
@@ -1438,6 +1442,7 @@ namespace isc { namespace dhcp {
       switch (this->type_get ())
     {
       case 116: // value
+      case 155: // socket_type
         value.move< ElementPtr > (s.value);
         break;
 
@@ -1600,15 +1605,15 @@ namespace isc { namespace dhcp {
   }
 
   Dhcp4Parser::symbol_type
-  Dhcp4Parser::make_DHCP_SOCKET_TYPE_RAW (const location_type& l)
+  Dhcp4Parser::make_RAW (const location_type& l)
   {
-    return symbol_type (token::TOKEN_DHCP_SOCKET_TYPE_RAW, l);
+    return symbol_type (token::TOKEN_RAW, l);
   }
 
   Dhcp4Parser::symbol_type
-  Dhcp4Parser::make_DHCP_SOCKET_TYPE_UDP (const location_type& l)
+  Dhcp4Parser::make_UDP (const location_type& l)
   {
-    return symbol_type (token::TOKEN_DHCP_SOCKET_TYPE_UDP, l);
+    return symbol_type (token::TOKEN_UDP, l);
   }
 
   Dhcp4Parser::symbol_type
@@ -2140,9 +2145,9 @@ namespace isc { namespace dhcp {
   }
 
 
-#line 14 "dhcp4_parser.yy" // lalr1.cc:377
+#line 14 "dhcp4_parser.yy" // lalr1.cc:392
 } } // isc::dhcp
-#line 2146 "dhcp4_parser.h" // lalr1.cc:377
+#line 2151 "dhcp4_parser.h" // lalr1.cc:392
 
 
 

+ 16 - 18
src/bin/dhcp4/dhcp4_parser.yy

@@ -1,4 +1,4 @@
-/* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2016-2017 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
@@ -53,8 +53,8 @@ using namespace std;
   INTERFACES_CONFIG "interfaces-config"
   INTERFACES "interfaces"
   DHCP_SOCKET_TYPE "dhcp-socket-type"
-  DHCP_SOCKET_TYPE_RAW "raw"
-  DHCP_SOCKET_TYPE_UDP "udp"
+  RAW "raw"
+  UDP "udp"
 
   ECHO_CLIENT_ID "echo-client-id"
   MATCH_CLIENT_ID "match-client-id"
@@ -187,6 +187,7 @@ using namespace std;
 %token <bool> BOOLEAN "boolean"
 
 %type <ElementPtr> value
+%type <ElementPtr> socket_type
 
 %printer { yyoutput << $$; } <*>;
 
@@ -445,19 +446,16 @@ interfaces_list: INTERFACES {
     ctx.leave();
 };
 
-dhcp_socket_type: dhcp_socket_type_raw
-                | dhcp_socket_type_udp
-                ;
-
-dhcp_socket_type_raw: DHCP_SOCKET_TYPE COLON DHCP_SOCKET_TYPE_RAW {
-    ElementPtr type(new StringElement("raw", ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("dhcp-socket-type", type);
+dhcp_socket_type: DHCP_SOCKET_TYPE {
+    ctx.enter(ctx.DHCP_SOCKET_TYPE);
+} COLON socket_type {
+    ctx.stack_.back()->set("dhcp-socket-type", $4);
+    ctx.leave();
 };
 
-dhcp_socket_type_udp: DHCP_SOCKET_TYPE COLON DHCP_SOCKET_TYPE_UDP {
-    ElementPtr type(new StringElement("udp", ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("dhcp-socket-type", type);
-};
+socket_type: RAW { $$ = ElementPtr(new StringElement("raw", ctx.loc2pos(@1))); }
+           | UDP { $$ = ElementPtr(new StringElement("udp", ctx.loc2pos(@1))); }
+           ;
 
 lease_database: LEASE_DATABASE {
     ElementPtr i(new MapElement(ctx.loc2pos(@1)));
@@ -1371,11 +1369,11 @@ control_socket_params: control_socket_param
                      | control_socket_params COMMA control_socket_param
                      ;
 
-control_socket_param: socket_type
-                    | socket_name
+control_socket_param: control_socket_type
+                    | control_socket_name
                     ;
 
-socket_type: SOCKET_TYPE {
+control_socket_type: SOCKET_TYPE {
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr stype(new StringElement($4, ctx.loc2pos(@4)));
@@ -1383,7 +1381,7 @@ socket_type: SOCKET_TYPE {
     ctx.leave();
 };
 
-socket_name: SOCKET_NAME {
+control_socket_name: SOCKET_NAME {
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));

+ 3 - 1
src/bin/dhcp4/parser_context.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2017 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
@@ -127,6 +127,8 @@ Parser4Context::contextName()
         return ("Logging");
     case INTERFACES_CONFIG:
         return ("interfaces-config");
+    case DHCP_SOCKET_TYPE:
+        return ("dhcp-socket-type");
     case LEASE_DATABASE:
         return ("lease-database");
     case HOSTS_DATABASE:

+ 4 - 1
src/bin/dhcp4/parser_context.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2017 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
@@ -193,6 +193,9 @@ public:
         /// Used while parsing Dhcp4/interfaces structures.
         INTERFACES_CONFIG,
 
+        /// Used while parsing Dhcp4/interfaces/dhcp-socket-type structures.
+        DHCP_SOCKET_TYPE,
+
         /// Used while parsing Dhcp4/lease-database structures.
         LEASE_DATABASE,