From c0954b0bd41c10714a748cba671b09c231fed54d Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 3 Oct 2017 13:45:34 +0000 Subject: [PATCH] ap_expr: follow up to r1810605. Better token/type descriptors for better parsing error messages. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1811010 13f79535-47bb-0310-9956-ffa450edef68 --- server/util_expr_parse.c | 27 +++++++++++++-------------- server/util_expr_parse.y | 36 ++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/server/util_expr_parse.c b/server/util_expr_parse.c index 27b45dc336..003bf94c21 100644 --- a/server/util_expr_parse.c +++ b/server/util_expr_parse.c @@ -551,11 +551,12 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "\"true\"", "\"false\"", "\"boolean expression\"", "\"string expression\"", "\"error token\"", - "\"number\"", "\"identifier\"", "\"string\"", "\"match regex\"", - "\"substitution regex\"", "\"match pattern of the regex\"", - "\"substitution pattern of the regex\"", "\"flags of the regex\"", - "\"regex back reference\"", "\"unary operator\"", "\"binary operator\"", - "\"start of string\"", "\"end of string\"", "\"start of variable name\"", + "\"number\"", "\"identifier\"", "\"string literal\"", + "\"matching regex\"", "\"substitution regex\"", + "\"pattern of the regex\"", "\"replacement of the regex\"", + "\"pattern flags of the regex\"", "\"capture reference in the regex\"", + "\"unary operator\"", "\"binary operator\"", "\"start of string\"", + "\"end of string\"", "\"start of variable name\"", "\"end of variable name\"", "\"start of variable expression\"", "\"end of variable expression\"", "\"integer equal\"", "\"integer not equal\"", "\"integer less than\"", @@ -567,14 +568,12 @@ static const char *const yytname[] = "\"string concatenation\"", "\"split operator\"", "\"join operator\"", "\"logical or\"", "\"logical and\"", "\"logical not\"", "\"condition\"", "\"comparison\"", "\"string function\"", "\"list function\"", - "\"list of words\"", "\"tuple of words\"", "\"word expression\"", - "\"any string expression\"", "\"variable expression\"", - "\"regular expression match\"", "\"regular expression substitution\"", - "\"regular expression split\"", "\"any regular expression\"", - "\"regular expression back reference\"", "'('", "')'", "'{'", "'}'", - "','", "':'", "$accept", "root", "cond", "comp", "wordlist", "words", - "string", "strany", "var", "word", "regex", "regsub", "regsplit", - "regany", "regref", "lstfunc", "strfunc", YY_NULL + "\"list of words\"", "\"tuple of words\"", "\"word\"", "\"string\"", + "\"substring\"", "\"variable\"", "\"regex substitution\"", + "\"regex split\"", "\"regex any\"", "\"regex capture reference\"", "'('", + "')'", "'{'", "'}'", "','", "':'", "$accept", "root", "cond", "comp", + "wordlist", "words", "string", "substr", "var", "word", "regex", + "regsub", "regsplit", "regany", "regref", "lstfunc", "strfunc", YY_NULL }; #endif @@ -2023,7 +2022,7 @@ yyreduce: /* Line 1787 of yacc.c */ -#line 2027 "util_expr_parse.c" +#line 2026 "util_expr_parse.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/server/util_expr_parse.y b/server/util_expr_parse.y index ce1d6188df..84eb054e6f 100644 --- a/server/util_expr_parse.y +++ b/server/util_expr_parse.y @@ -48,14 +48,14 @@ %token T_DIGIT "number" %token T_ID "identifier" -%token T_STRING "string" +%token T_STRING "string literal" -%token T_REGEX "match regex" +%token T_REGEX "matching regex" %token T_REGSUB "substitution regex" -%token T_REG_MATCH "match pattern of the regex" -%token T_REG_SUBST "substitution pattern of the regex" -%token T_REG_FLAGS "flags of the regex" -%token T_REG_REF "regex back reference" +%token T_REG_MATCH "pattern of the regex" +%token T_REG_SUBST "replacement of the regex" +%token T_REG_FLAGS "pattern flags of the regex" +%token T_REG_REF "capture reference in the regex" %token T_OP_UNARY "unary operator" %token T_OP_BINARY "binary operator" @@ -103,15 +103,15 @@ %type lstfunc "list function" %type wordlist "list of words" %type words "tuple of words" -%type word "word expression" -%type string "string expression" -%type strany "any string expression" -%type var "variable expression" -%type regex "regular expression match" -%type regsub "regular expression substitution" -%type regsplit "regular expression split" -%type regany "any regular expression" -%type regref "regular expression back reference" +%type word "word" +%type string "string" +%type substr "substring" +%type var "variable" +%type regex "regex match" +%type regsub "regex substitution" +%type regsplit "regex split" +%type regany "regex any" +%type regref "regex capture reference" %{ #include "util_expr_private.h" @@ -168,12 +168,12 @@ words : word { $$ = ap_expr_make(op_ListElement, $1, | word ',' words { $$ = ap_expr_make(op_ListElement, $1, $3, ctx); } ; -string : strany { $$ = $1; } - | string strany { $$ = ap_expr_concat_make($1, $2, ctx); } +string : substr { $$ = $1; } + | string substr { $$ = ap_expr_concat_make($1, $2, ctx); } | T_ERROR { YYABORT; } ; -strany : T_STRING { $$ = ap_expr_make(op_String, $1, NULL, ctx); } +substr : T_STRING { $$ = ap_expr_make(op_String, $1, NULL, ctx); } | var { $$ = $1; } | regref { $$ = $1; } ; -- 2.40.0