Remove a bad file/look at the include options for parser building.
[m6w6/libmemcached] / libmemcached / options / parser.yy
index e61f69ca892e479f58f57a80636d9cb789b4ef24..d309c2278e0b6691c732cf7e35610390036815d0 100644 (file)
@@ -40,7 +40,6 @@
 #include <stdint.h>
 
 #include <libmemcached/options/context.h>
-#include <libmemcached/options/build.h>
 #include <libmemcached/options/string.h>
 #include <libmemcached/options/symbol.h>
 #include <libmemcached/visibility.h>
 
 int conf_lex(YYSTYPE* lvalp, void* scanner);
 
-#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0) 
+#define parser_abort(A, B) do { (A)->abort((B)); YYABORT; } while (0) 
 
 inline void config_error(Context *context, yyscan_t *scanner, const char *error)
 {
   if (not context->end())
-    parser::abort_func(context, error);
+    context->abort(error);
 }
 
 %}
@@ -133,17 +132,16 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error)
 %nonassoc ','
 %nonassoc '='
 
-%token <number> NUMBER
 %token <number> FLOAT
-%token <string> HOSTNAME
-%token <string> HOSTNAME_WITH_PORT
-%token <string> IPADDRESS
-%token <string> IPADDRESS_WITH_PORT
+%token <number> NUMBER
+%token PORT
+%token WEIGHT_START
+%token <server> IPADDRESS
+%token <server> HOSTNAME
 %token <string> STRING
 %token <string> QUOTED_STRING
 %token <string> FILE_PATH
 
-%type <server> server
 %type <string> string
 %type <distribution> distribution
 %type <hash> hash
@@ -193,15 +191,21 @@ statement:
 
 
 expression:
-          SERVER server
-          { 
-            if ((context->rc= memcached_server_add_parsed(context->memc, $2.c_str, $2.length, $2.port, 0)) != MEMCACHED_SUCCESS)
+          SERVER HOSTNAME optional_port optional_weight
+          {
+            if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS)
             {
               parser_abort(context, NULL);
             }
+            context->unset_server();
           }
-        | SERVERS_OPTION server_list
+        | SERVER IPADDRESS optional_port optional_weight
           {
+            if ((context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $2.port, $2.weight)) != MEMCACHED_SUCCESS)
+            {
+              parser_abort(context, NULL);
+            }
+            context->unset_server();
           }
         | CONFIGURE_FILE string
           {
@@ -330,10 +334,6 @@ behavior_boolean:
           {
             $$= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY;
           }
-        | KETAMA_WEIGHTED
-          {
-            $$= MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED;
-          }
         | NOREPLY
           {
             $$= MEMCACHED_BEHAVIOR_NOREPLY;
@@ -372,54 +372,16 @@ behavior_boolean:
           }
 
 
-server_list:
-           server
-          {
-            if ((context->rc= memcached_server_add_parsed(context->memc, $1.c_str, $1.length, $1.port, 0)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
-        | server_list ',' server
-          {
-            if ((context->rc= memcached_server_add_parsed(context->memc, $3.c_str, $3.length, $3.port, 0)) != MEMCACHED_SUCCESS)
-            {
-              parser_abort(context, NULL);;
-            }
-          }
+optional_port:
+          { }
+        | PORT
+          { };
         ;
 
-server:
-          HOSTNAME_WITH_PORT NUMBER
-          {
-            $$.c_str= $1.c_str;
-            $$.length= $1.length -1; // -1 to remove :
-            $$.port= $2;
-          }
-        | HOSTNAME
-          {
-            $$.c_str= $1.c_str;
-            $$.length= $1.length;
-            $$.port= MEMCACHED_DEFAULT_PORT;
-          }
-        | STRING /* a match can be against "localhost" which is just a string */
-          {
-            $$.c_str= $1.c_str;
-            $$.length= $1.length;
-            $$.port= MEMCACHED_DEFAULT_PORT;
-          }
-        | IPADDRESS_WITH_PORT NUMBER
-          {
-            $$.c_str= $1.c_str;
-            $$.length= $1.length -1; // -1 to remove :
-            $$.port= $2;
-          }
-        | IPADDRESS
-          {
-            $$.c_str= $1.c_str;
-            $$.length= $1.length;
-            $$.port= MEMCACHED_DEFAULT_PORT;
-          }
+optional_weight:
+          { }
+        | WEIGHT_START
+          { }
         ;
 
 hash: