X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions%2Fparser.yy;h=bff5b28df69bb7eaea48033927040399f2547b76;hb=aa6d65c93cadc9869623af385919db1394116934;hp=b67052b34edef7dd15b1378c1ad49551b41f9aea;hpb=a4303fb9aa783e5f0575d6ba00d3fe286905d658;p=awesomized%2Flibmemcached diff --git a/libmemcached/options/parser.yy b/libmemcached/options/parser.yy index b67052b3..bff5b28d 100644 --- a/libmemcached/options/parser.yy +++ b/libmemcached/options/parser.yy @@ -31,7 +31,7 @@ %locations %pure-parser %require "2.2" -%start statement +%start begin %verbose %{ @@ -52,7 +52,9 @@ int libmemcached_lex(YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner); -inline void parser_abort(Context *context, const char *error) +#define parser_abort(A, B) do { parser_abort_func((A), (B)); YYABORT; } while (0) + +inline void parser_abort_func(Context *context, const char *error) { (void)error; if (context->rc == MEMCACHED_SUCCESS) @@ -69,16 +71,22 @@ inline void parser_abort(Context *context, const char *error) inline void libmemcached_error(YYLTYPE *locp, Context *context, yyscan_t *scanner, const char *error) { - parser_abort(context, error); + if (not context->end()) + parser_abort_func(context, error); } %} %token COMMENT +%token END +%token RESET +%token DEBUG +%token INCLUDE %token CONFIGURE_FILE %token EMPTY_LINE %token SERVER %token SERVERS +%token SERVERS_OPTION %token UNKNOWN_OPTION %token UNKNOWN @@ -136,6 +144,10 @@ inline void libmemcached_error(YYLTYPE *locp, Context *context, yyscan_t *scanne %token MODULA %token RANDOM +/* Boolean values */ +%token TRUE +%token FALSE + %nonassoc ',' %nonassoc '=' @@ -157,15 +169,50 @@ inline void libmemcached_error(YYLTYPE *locp, Context *context, yyscan_t *scanne %% +begin: + statement + | statement ' ' statement + ; + statement: expression { } - | statement ' ' expression - { } | COMMENT { } | EMPTY_LINE { } + | END + { + context->set_end(); + YYACCEPT; + } + | RESET + { + memcached_reset(context->memc); + } + | RESET SERVERS + { + memcached_servers_reset(context->memc); + } + | DEBUG + { + yydebug= 1; + } + | DEBUG TRUE + { + yydebug= 1; + } + | DEBUG FALSE + { + yydebug= 0; + } + | INCLUDE string + { + if ((context->rc= memcached_parse_configure_file(context->memc, $2.c_str, $2.length)) != MEMCACHED_SUCCESS) + { + parser_abort(context, NULL); + } + } ; @@ -177,7 +224,7 @@ expression: parser_abort(context, NULL); } } - | SERVERS '=' server_list + | SERVERS_OPTION '=' server_list { } | CONFIGURE_FILE '=' string