From c95b96020f9185e64a80fadc9cd770a5d8684aa5 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 28 Jul 2019 20:09:24 +0300 Subject: Grammar optimization from NetBSD: Two adjacent string constants are merged. --- awkgram.y | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'awkgram.y') diff --git a/awkgram.y b/awkgram.y index fd0f40e..c5356d7 100644 --- a/awkgram.y +++ b/awkgram.y @@ -71,6 +71,7 @@ Node *arglist = 0; /* list of args for current function */ %type do st %type pst opt_pst lbrace rbrace rparen comma nl opt_nl and bor %type subop print +%type string %right ASGNOP %right '?' @@ -348,6 +349,11 @@ subop: SUB | GSUB ; +string: + STRING + | string STRING { $$ = catstr($1, $2); } + ; + term: term '/' ASGNOP term { $$ = op2(DIVEQ, $1, $4); } | term '+' term { $$ = op2(ADD, $1, $3); } @@ -394,7 +400,7 @@ term: | SPLIT '(' pattern comma varname ')' { $$ = op4(SPLIT, $3, makearr($5), NIL, (Node*)STRING); } /* default */ | SPRINTF '(' patlist ')' { $$ = op1($1, $3); } - | STRING { $$ = celltonode($1, CCON); } + | string { $$ = celltonode($1, CCON); } | subop '(' reg_expr comma pattern ')' { $$ = op4($1, NIL, (Node*)makedfa($3, 1), $5, rectonode()); } | subop '(' pattern comma pattern ')' -- cgit v1.2.3