Merge in code such that we are much closer to running the same test
[awesomized/libmemcached] / libmemcached / options / parser.yy
index e7fb84ed972b09c02299fa1e197cdab50b84142a..722ced5f9db6ffd41669cd9a96336f0624671ea7 100644 (file)
@@ -40,6 +40,8 @@
 #include <stdint.h>
 
 #include <libmemcached/common.h>
+#include <libmemcached/options.hpp>
+
 #include <libmemcached/options/context.h>
 #include <libmemcached/options/symbol.h>
 #include <libmemcached/options/scanner.h>
@@ -135,19 +137,21 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error)
 
 %token <number> FLOAT
 %token <number> NUMBER
-%token PORT
-%token WEIGHT_START
+%token <number> PORT
+%token <number> WEIGHT_START
 %token <server> IPADDRESS
 %token <server> HOSTNAME
 %token <string> STRING
 %token <string> QUOTED_STRING
 %token <string> FILE_PATH
 
-%type <string> string
-%type <distribution> distribution
-%type <hash> hash
 %type <behavior> behavior_boolean
 %type <behavior> behavior_number
+%type <distribution> distribution
+%type <hash> hash
+%type <number> optional_port
+%type <number> optional_weight
+%type <string> string
 
 %%
 
@@ -183,7 +187,7 @@ statement:
           }
         | INCLUDE ' ' string
           {
-            if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS)
+            if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS)
             {
               parser_abort(context, NULL);
             }
@@ -194,7 +198,7 @@ statement:
 expression:
           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)
+            if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4)))
             {
               parser_abort(context, NULL);
             }
@@ -202,7 +206,7 @@ expression:
           }
         | 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)
+            if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4)))
             {
               parser_abort(context, NULL);
             }
@@ -378,13 +382,13 @@ behavior_boolean:
 
 
 optional_port:
-          { }
+          { $$= MEMCACHED_DEFAULT_PORT;}
         | PORT
           { };
         ;
 
 optional_weight:
-          { }
+          { $$= 1; }
         | WEIGHT_START
           { }
         ;