%locations
%pure-parser
%require "2.2"
-%start statement
+%start begin
%verbose
%{
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)
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
%token MODULA
%token RANDOM
+/* Boolean values */
+%token <boolean> TRUE
+%token <boolean> FALSE
+
%nonassoc ','
%nonassoc '='
%%
+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);
+ }
+ }
;
parser_abort(context, NULL);
}
}
- | SERVERS '=' server_list
+ | SERVERS_OPTION '=' server_list
{
}
| CONFIGURE_FILE '=' string
}
"--SERVER" { yyextra->begin= yytext; return SERVER; }
-"--SERVERS" { yyextra->begin= yytext; return SERVERS; }
+"--SERVERS" { yyextra->begin= yytext; return SERVERS_OPTION; }
"--VERIFY_KEY" { yyextra->begin= yytext; return VERIFY_KEY; }
"--VERIFY-KEY" { yyextra->begin= yytext; return VERIFY_KEY; }
"--PREFIX-KEY" { yyextra->begin= yytext; return PREFIX_KEY; }
"--PREFIX_KEY" { yyextra->begin= yytext; return PREFIX_KEY; }
+INCLUDE { yyextra->begin= yytext; return INCLUDE; }
+RESET { yyextra->begin= yytext; return RESET; }
+DEBUG { yyextra->begin= yytext; return DEBUG; }
+SERVERS { yyextra->begin= yytext; return SERVERS; }
+END { yyextra->begin= yytext; return END; }
+
+TRUE { return TRUE; }
+FALSE { return FALSE; }
+
+
"--"[[:alnum:]]* {
yyextra->begin= yytext;
return UNKNOWN_OPTION;