X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcsl%2Fparser.yy;h=fd8d0c264aa0fab5ce458fd63f1b5c24ee6a0c4b;hb=0ae14bed70947882f5ee9423dfcb20eeda7acdd9;hp=c5eca73e963e9ec38eee9c01875b0a0c9f403339;hpb=f92f0f9bcb54167331067b6891ee33e5f27d691c;p=m6w6%2Flibmemcached diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index c5eca73e..fd8d0c26 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -35,27 +35,39 @@ %{ -#include +#include #include #include #include #include -#include - #pragma GCC diagnostic ignored "-Wold-style-cast" int conf_lex(YYSTYPE* lvalp, void* scanner); -#define parser_abort(A, B) do { (A)->abort((B)); YYABORT; } while (0) +#define select_yychar(__context) yychar == UNKNOWN ? ( (__context)->previous_token == END ? UNKNOWN : (__context)->previous_token ) : yychar + +#define stryytname(__yytokentype) ((__yytokentype) < YYNTOKENS ) ? yytname[(__yytokentype)] : "" + +#define parser_abort(__context, __error_message) do { (__context)->abort((__error_message), yytokentype(select_yychar(__context)), stryytname(YYTRANSLATE(select_yychar(__context)))); YYABORT; } while (0) -inline void config_error(Context *context, yyscan_t *scanner, const char *error) +// This is bison calling error. +inline void __config_error(Context *context, yyscan_t *scanner, const char *error, int last_token, const char *last_token_str) { if (not context->end()) - context->abort(error); + { + context->error(error, yytokentype(last_token), last_token_str); + } + else + { + context->error(error, yytokentype(last_token), last_token_str); + } } +#define config_error(__context, __scanner, __error_msg) do { __config_error((__context), (__scanner), (__error_msg), select_yychar(__context), stryytname(YYTRANSLATE(select_yychar(__context)))); } while (0) + + %} %token COMMENT