summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorBranislav ZahradnĂ­k <barney@cpan.org>2021-12-23 23:25:49 +0100
committerKarl Williamson <khw@cpan.org>2022-02-05 20:54:09 -0700
commit6e9eef6684fc76adb123d29c872346b287f47aad (patch)
treece9bf13902e162d0bbae7543ad7b2f57e22b1dd7 /perly.y
parent148f5aafd05807ac681803b169497485643e1ec6 (diff)
downloadperl-6e9eef6684fc76adb123d29c872346b287f47aad.tar.gz
Unify optional rules
- start with `opt` (renamed `siglistornull`) - employ bison's default rule whenever possible
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y28
1 files changed, 14 insertions, 14 deletions
diff --git a/perly.y b/perly.y
index 8aea09b00f..3f63387952 100644
--- a/perly.y
+++ b/perly.y
@@ -98,7 +98,7 @@
%type <opval> termrelop relopchain termeqop eqopchain
%type <ival> sigslurpsigil
%type <opval> sigvarname sigdefault sigscalarelem sigslurpelem
-%type <opval> sigelem siglist siglistornull subsigguts subsignature optsubsignature
+%type <opval> sigelem siglist optsiglist subsigguts subsignature optsubsignature
%type <opval> subbody optsubbody sigsubbody optsigsubbody
%type <opval> formstmtseq formline formarg
@@ -816,16 +816,16 @@ siglist:
;
/* () or (....) */
-siglistornull
+optsiglist
: empty
| siglist
- { $$ = $siglist; }
+ ;
/* optional subroutine signature */
optsubsignature
: empty
| subsignature
- { $$ = $subsignature; }
+ ;
/* Subroutine signature */
subsignature: PERLY_PAREN_OPEN subsigguts PERLY_PAREN_CLOSE
@@ -842,9 +842,9 @@ subsigguts:
parser->sig_slurpy = 0;
parser->in_my = KEY_sigvar;
}
- siglistornull
+ optsiglist
{
- OP *sigops = $siglistornull;
+ OP *sigops = $optsiglist;
struct op_argcheck_aux *aux;
OP *check;
@@ -902,7 +902,8 @@ subsigguts:
;
/* Optional subroutine body (for named subroutine declaration) */
-optsubbody: subbody { $$ = $subbody; }
+optsubbody
+ : subbody
| PERLY_SEMICOLON { $$ = NULL; }
;
@@ -919,8 +920,10 @@ subbody: remember PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
/* optional [ Subroutine body with optional signature ] (for named
* subroutine declaration) */
-optsigsubbody: sigsubbody { $$ = $sigsubbody; }
+optsigsubbody
+ : sigsubbody
| PERLY_SEMICOLON { $$ = NULL; }
+ ;
/* Subroutine body with optional signature */
sigsubbody: remember optsubsignature PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
@@ -1376,21 +1379,18 @@ myterm : PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE
/* Basic list expressions */
optlistexpr
- : empty %prec PREC_LOW
- | listexpr %prec PREC_LOW
- { $$ = $listexpr; }
+ : empty %prec PREC_LOW
+ | listexpr %prec PREC_LOW
;
optexpr
: empty
| expr
- { $$ = $expr; }
;
optrepl
: empty
- | PERLY_SLASH expr
- { $$ = $expr; }
+ | PERLY_SLASH expr { $$ = $expr; }
;
/* A little bit of trickery to make "for my $foo (@bar)" actually be