X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libmemcached%2Foptions%2Fparser.yy;h=e950076e1c519af86ec7084f0d954c4c3f04e8e2;hb=b01326b56e6207e84749fecd9883dfa1887299ac;hp=e61f69ca892e479f58f57a80636d9cb789b4ef24;hpb=1591feaed3f710d48f76a6fc8a3a52242ab34fd9;p=m6w6%2Flibmemcached diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy index e61f69ca..e950076e 100644 --- a/libmemcached/options/parser.yy +++ b/libmemcached/options/parser.yy @@ -133,17 +133,16 @@ inline void config_error(Context *context, yyscan_t *scanner, const char *error) %nonassoc ',' %nonassoc '=' -%token NUMBER %token FLOAT -%token HOSTNAME -%token HOSTNAME_WITH_PORT -%token IPADDRESS -%token IPADDRESS_WITH_PORT +%token NUMBER +%token PORT +%token WEIGHT_START +%token IPADDRESS +%token HOSTNAME %token STRING %token QUOTED_STRING %token FILE_PATH -%type server %type string %type distribution %type hash @@ -193,15 +192,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 +335,6 @@ behavior_boolean: { $$= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; } - | KETAMA_WEIGHTED - { - $$= MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED; - } | NOREPLY { $$= MEMCACHED_BEHAVIOR_NOREPLY; @@ -372,54 +373,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: