diff options
author | Zefram <zefram@fysh.org> | 2010-12-12 11:41:55 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2010-12-13 20:54:52 +0000 |
commit | 8e720305f65b4f201f4aef0d72433f29360b876f (patch) | |
tree | 2201d6bc359362feaa2bb8bffa4e70164e65ba9a /perly.y | |
parent | 3e4ddde58e18d81b358926bde131ebf3c037e8bc (diff) | |
download | perl-8e720305f65b4f201f4aef0d72433f29360b876f.tar.gz |
permit labels to be stacked
Liberalise label syntax a little more, by allowing multiple adjacent
labels with no intervening statements, as in "foo: bar: baz:".
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 44 |
1 files changed, 21 insertions, 23 deletions
@@ -94,14 +94,13 @@ /* FIXME for MAD - are these two ival? */ %type <ival> mydefsv mintro -%type <opval> stmtseq fullstmt barestmt block mblock else +%type <opval> stmtseq fullstmt labfullstmt barestmt block mblock else %type <opval> expr term subscripted scalar ary hsh arylen star amper sideff %type <opval> listexpr nexpr texpr iexpr mexpr mnexpr miexpr %type <opval> optlistexpr optexpr indirob listop method %type <opval> formname subname proto subbody cont my_scalar %type <opval> subattrlist myattrlist myattrterm myterm %type <opval> termbinop termunop anonymous termdo -%type <p_tkval> label %nonassoc <i_tkval> PREC_LOW %nonassoc LOOPEX @@ -246,17 +245,30 @@ stmtseq : /* NULL */ } ; -/* A statement in the program, including optional label */ -fullstmt: label barestmt +/* A statement in the program, including optional labels */ +fullstmt: barestmt { - if (PVAL($1) || $2) { - $$ = newSTATEOP(0, PVAL($1), $2); - TOKEN_GETMAD($1, - $2 ? cLISTOPx($$)->op_first : $$, 'L'); + if($1) { + $$ = newSTATEOP(0, NULL, $1); } else { - $$ = IF_MAD(newOP(OP_NULL, 0), $2); + $$ = IF_MAD(newOP(OP_NULL, 0), NULL); } } + | labfullstmt + { $$ = $1; } + ; + +labfullstmt: LABEL barestmt + { + $$ = newSTATEOP(0, PVAL($1), $2); + TOKEN_GETMAD($1, + $2 ? cLISTOPx($$)->op_first : $$, 'L'); + } + | LABEL labfullstmt + { + $$ = newSTATEOP(0, PVAL($1), $2); + TOKEN_GETMAD($1, cLISTOPx($$)->op_first, 'L'); + } ; /* A bare statement, lacking label and other aspects of state op */ @@ -592,20 +604,6 @@ miexpr : iexpr { $$ = $1; intro_my(); } ; -/* Optional "MAIN:"-style loop labels */ -label : /* empty */ - { -#ifdef MAD - YYSTYPE tmplval; - tmplval.pval = NULL; - $$ = newTOKEN(OP_NULL, tmplval, 0); -#else - $$ = NULL; -#endif - } - | LABEL - ; - formname: WORD { $$ = $1; } | /* NULL */ { $$ = (OP*)NULL; } ; |