X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions%2Fparser.yy;h=81415226e82e002e49b947de5645abd11df9b3f9;hb=5febc397f702ce74f79f3e590432c85b025a32fc;hp=0f0aee65a459115f6da1f104b3198888bde67029;hpb=55cf7c68679083cdd7351db3b888c6f8ddcebe09;p=awesomized%2Flibmemcached diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy index 0f0aee65..81415226 100644 --- a/libmemcached/options/parser.yy +++ b/libmemcached/options/parser.yy @@ -29,24 +29,22 @@ %parse-param { Context *context } %parse-param { yyscan_t *scanner } %pure-parser -%require "2.2" +%require "2.4" %start begin %verbose %{ -#include - -#include +#include +#include #include -#include #include -#include -#include +#include + +#include #pragma GCC diagnostic ignored "-Wold-style-cast" -#include int conf_lex(YYSTYPE* lvalp, void* scanner); @@ -69,6 +67,7 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %token CONFIGURE_FILE %token EMPTY_LINE %token SERVER +%token SOCKET %token SERVERS %token SERVERS_OPTION %token UNKNOWN_OPTION @@ -108,6 +107,10 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) /* Callbacks */ %token NAMESPACE +/* Pool */ +%token POOL_MIN +%token POOL_MAX + /* Hash types */ %token MD5 %token CRC @@ -133,19 +136,21 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %token FLOAT %token NUMBER -%token PORT -%token WEIGHT_START +%token PORT +%token WEIGHT_START %token IPADDRESS %token HOSTNAME %token STRING %token QUOTED_STRING %token FILE_PATH -%type string -%type distribution -%type hash %type behavior_boolean %type behavior_number +%type distribution +%type hash +%type optional_port +%type optional_weight +%type string %% @@ -181,7 +186,7 @@ statement: } | INCLUDE ' ' string { - if ((context->rc= memcached_parse_configure_file(context->memc, $3.c_str, $3.length)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL); } @@ -192,7 +197,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); } @@ -200,15 +205,30 @@ 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); } context->unset_server(); } + | SOCKET string optional_weight + { + if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3))) + { + parser_abort(context, NULL); + } + } | CONFIGURE_FILE string { - memcached_set_configuration_file(context->memc, $2.c_str, $2.length); + memcached_set_configuration_file(context->memc, $2.c_str, $2.size); + } + | POOL_MIN NUMBER + { + context->memc->configure.initial_pool_size= $2; + } + | POOL_MAX NUMBER + { + context->memc->configure.max_pool_size= $2; } | behaviors ; @@ -216,7 +236,7 @@ expression: behaviors: NAMESPACE string { - if ((context->rc= memcached_set_prefix_key(context->memc, $2.c_str, $2.length)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) { parser_abort(context, NULL);; } @@ -368,13 +388,13 @@ behavior_boolean: optional_port: - { } + { $$= MEMCACHED_DEFAULT_PORT;} | PORT { }; ; optional_weight: - { } + { $$= 1; } | WEIGHT_START { } ; @@ -425,8 +445,11 @@ string: } | QUOTED_STRING { + $$= $1; + #if 0 $$.c_str= $1.c_str +1; // +1 to move use passed the initial quote - $$.length= $1.length -1; // -1 removes the end quote + $$.size= $1.size -2; // -2 removes the begin and end quote + #endif } ;