aboutsummaryrefslogtreecommitdiff
path: root/awkgram.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-07-28 20:09:24 +0300
committerArnold D. Robbins <arnold@skeeve.com>2019-07-28 20:09:24 +0300
commitc95b96020f9185e64a80fadc9cd770a5d8684aa5 (patch)
tree8b7e283a3232d41c477c57e134a52b34097f5fc3 /awkgram.y
parent795a06b58cdea7f8bb1858e7c383582c660fdf85 (diff)
downloadone-true-awk-c95b96020f9185e64a80fadc9cd770a5d8684aa5.tar.gz
Grammar optimization from NetBSD: Two adjacent string constants are merged.
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y8
1 files changed, 7 insertions, 1 deletions
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 <i> do st
%type <i> pst opt_pst lbrace rbrace rparen comma nl opt_nl and bor
%type <i> subop print
+%type <cp> 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 ')'