/* perly.y
*
* Copyright (c) 1991-2002, 2003, 2004, 2005, 2006 Larry Wall
/* perly.y
*
* Copyright (c) 1991-2002, 2003, 2004, 2005, 2006 Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
* This file holds the grammar for the Perl language. If edited, you need
* to run regen_perly.pl, which re-creates the files perly.h, perly.tab
* and perly.act which are derived from this.
* This file holds the grammar for the Perl language. If edited, you need
* to run regen_perly.pl, which re-creates the files perly.h, perly.tab
* and perly.act which are derived from this.
%token <i_tkval> FORMAT SUB ANONSUB PACKAGE USE
%token <i_tkval> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
%token <i_tkval> GIVEN WHEN DEFAULT
%token <i_tkval> FORMAT SUB ANONSUB PACKAGE USE
%token <i_tkval> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
%token <i_tkval> GIVEN WHEN DEFAULT
%token <i_tkval> FUNC0 FUNC1 FUNC UNIOP LSTOP
%token <i_tkval> RELOP EQOP MULOP ADDOP
%token <i_tkval> DOLSHARP DO HASHBRACK NOAMP
%token <i_tkval> LOCAL MY MYSUB REQUIRE
%token <i_tkval> COLONATTR
%token <i_tkval> FUNC0 FUNC1 FUNC UNIOP LSTOP
%token <i_tkval> RELOP EQOP MULOP ADDOP
%token <i_tkval> DOLSHARP DO HASHBRACK NOAMP
%token <i_tkval> LOCAL MY MYSUB REQUIRE
%token <i_tkval> COLONATTR
%type <ival> startsub startanonsub startformsub
/* FIXME for MAD - are these two ival? */
%type <ival> mydefsv mintro
%type <ival> startsub startanonsub startformsub
/* FIXME for MAD - are these two ival? */
%type <ival> mydefsv mintro
- | lineseq savescope line
- { LEAVE_SCOPE($2);
- $$ = append_list(OP_LINESEQ,
- (LISTOP*)$1, (LISTOP*)$3);
+ | lineseq line
+ { $$ = append_list(OP_LINESEQ,
+ (LISTOP*)$1, (LISTOP*)$2);
- { $$ = newFOROP(0, Nullch, (line_t)IVAL($2),
- Nullop, $3, $1, Nullop);
+ { $$ = newFOROP(0, NULL, (line_t)IVAL($2),
+ (OP*)NULL, $3, $1, (OP*)NULL);
- { PL_copline = (line_t)IVAL($1);
- $$ = newCONDOP(0, $3, scope($5), $6);
+ { PL_parser->copline = (line_t)IVAL($1);
+ $$ = newCONDOP(0, newSTATEOP(OPf_SPECIAL,NULL,$3), scope($5), $6);
$$ = block_end($3,
newCONDOP(0, $4, scope($6), $7));
TOKEN_GETMAD($1,$$,'I');
$$ = block_end($3,
newCONDOP(0, $4, scope($6), $7));
TOKEN_GETMAD($1,$$,'I');
$$ = block_end($3,
newCONDOP(0, $4, scope($6), $7));
TOKEN_GETMAD($1,$$,'I');
$$ = block_end($3,
newCONDOP(0, $4, scope($6), $7));
TOKEN_GETMAD($1,$$,'I');
/* Loops: while, until, for, and a bare block */
loop : label WHILE '(' remember texpr ')' mintro mblock cont
{ OP *innerop;
/* Loops: while, until, for, and a bare block */
loop : label WHILE '(' remember texpr ')' mintro mblock cont
{ OP *innerop;
- innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
+ innerop = newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
IVAL($2), $5, $8, $9, $7)));
TOKEN_GETMAD($1,innerop,'L');
TOKEN_GETMAD($2,innerop,'W');
IVAL($2), $5, $8, $9, $7)));
TOKEN_GETMAD($1,innerop,'L');
TOKEN_GETMAD($2,innerop,'W');
- innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
+ innerop = newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
IVAL($2), $5, $8, $9, $7)));
TOKEN_GETMAD($1,innerop,'L');
TOKEN_GETMAD($2,innerop,'W');
IVAL($2), $5, $8, $9, $7)));
TOKEN_GETMAD($1,innerop,'L');
TOKEN_GETMAD($2,innerop,'W');
{ OP *innerop;
$$ = block_end($4,
innerop = newFOROP(0, PVAL($1), (line_t)IVAL($2),
{ OP *innerop;
$$ = block_end($4,
innerop = newFOROP(0, PVAL($1), (line_t)IVAL($2),
TOKEN_GETMAD($1,((LISTOP*)innerop)->op_first,'L');
TOKEN_GETMAD($2,((LISTOP*)innerop)->op_first->op_sibling,'W');
TOKEN_GETMAD($3,((LISTOP*)innerop)->op_first->op_sibling,'(');
TOKEN_GETMAD($1,((LISTOP*)innerop)->op_first,'L');
TOKEN_GETMAD($2,((LISTOP*)innerop)->op_first->op_sibling,'W');
TOKEN_GETMAD($3,((LISTOP*)innerop)->op_first->op_sibling,'(');
- newWHILEOP(0, 1, (LOOP*)Nullop,
+ newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
IVAL($2), scalar($7),
$12, $10, $9));
#ifdef MAD
forop = newUNOP(OP_NULL, 0, append_elem(OP_LINESEQ,
newSTATEOP(0,
CopLABEL_alloc(($1)->tk_lval.pval),
IVAL($2), scalar($7),
$12, $10, $9));
#ifdef MAD
forop = newUNOP(OP_NULL, 0, append_elem(OP_LINESEQ,
newSTATEOP(0,
CopLABEL_alloc(($1)->tk_lval.pval),
$$ = block_end($4, forop); }
| label block cont /* a block is a loop that happens once */
{ $$ = newSTATEOP(0, PVAL($1),
$$ = block_end($4, forop); }
| label block cont /* a block is a loop that happens once */
{ $$ = newSTATEOP(0, PVAL($1),
- newWHILEOP(0, 1, (LOOP*)Nullop,
- NOLINE, Nullop, $2, $3, 0));
+ newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
+ NOLINE, (OP*)NULL, $2, $3, 0));
TOKEN_GETMAD($1,((LISTOP*)$$)->op_first,'L'); }
;
/* Switch blocks */
switch : label GIVEN '(' remember mydefsv mexpr ')' mblock
TOKEN_GETMAD($1,((LISTOP*)$$)->op_first,'L'); }
;
/* Switch blocks */
switch : label GIVEN '(' remember mydefsv mexpr ')' mblock
#ifdef MAD
$$ = newFORM($2, $3, $4);
prepend_madprops($1->tk_mad, $$, 'F');
#ifdef MAD
$$ = newFORM($2, $3, $4);
prepend_madprops($1->tk_mad, $$, 'F');
#ifdef MAD
$$ = newMYSUB($2, $3, $4, $5, $6);
token_getmad($1,$$,'d');
#else
newMYSUB($2, $3, $4, $5, $6);
#ifdef MAD
$$ = newMYSUB($2, $3, $4, $5, $6);
token_getmad($1,$$,'d');
#else
newMYSUB($2, $3, $4, $5, $6);
- OP* o = newSVOP(OP_ANONCODE, 0,
- (SV*)newATTRSUB($2, $3, $4, $5, $6));
- $$ = newOP(OP_NULL,0);
- op_getmad(o,$$,'&');
- op_getmad($3,$$,'n');
- op_getmad($4,$$,'s');
- op_getmad($5,$$,'a');
- token_getmad($1,$$,'d');
- append_madprops($6->op_madprop, $$, 0);
- $6->op_madprop = 0;
+ {
+ OP* o = newSVOP(OP_ANONCODE, 0,
+ (SV*)newATTRSUB($2, $3, $4, $5, $6));
+ $$ = newOP(OP_NULL,0);
+ op_getmad(o,$$,'&');
+ op_getmad($3,$$,'n');
+ op_getmad($4,$$,'s');
+ op_getmad($5,$$,'a');
+ token_getmad($1,$$,'d');
+ append_madprops($6->op_madprop, $$, 0);
+ $6->op_madprop = 0;
+ }
#else
newATTRSUB($2, $3, $4, $5, $6);
#else
newATTRSUB($2, $3, $4, $5, $6);
#ifdef MAD
$$ = utilize(IVAL($1), $2, $4, $5, $6);
token_getmad($1,$$,'o');
token_getmad($7,$$,';');
#ifdef MAD
$$ = utilize(IVAL($1), $2, $4, $5, $6);
token_getmad($1,$$,'o');
token_getmad($7,$$,';');
- if (PL_rsfp_filters && AvFILLp(PL_rsfp_filters) >= 0)
- append_madprops(newMADPROP('!', MAD_PV, "", 0), $$, 0);
+ if (PL_parser->rsfp_filters &&
+ AvFILLp(PL_parser->rsfp_filters) >= 0)
+ append_madprops(newMADPROP('!', MAD_NULL, NULL, 0), $$, 0);
#else
utilize(IVAL($1), $2, $4, $5, $6);
#else
utilize(IVAL($1), $2, $4, $5, $6);
- { SvREFCNT_inc(PL_compcv);
- $<opval>$ = newANONATTRSUB($2, 0, Nullop, $3); }
+ { SvREFCNT_inc_simple_void(PL_compcv);
+ $<opval>$ = newANONATTRSUB($2, 0, (OP*)NULL, $3); }
listexpr %prec LSTOP /* ... @bar */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
append_elem(OP_LIST,
listexpr %prec LSTOP /* ... @bar */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
append_elem(OP_LIST,
/* In this and all the hash accessors, ';' is
* provided by the tokeniser */
{ $$ = newBINOP(OP_GELEM, 0, $1, scalar($3));
/* In this and all the hash accessors, ';' is
* provided by the tokeniser */
{ $$ = newBINOP(OP_GELEM, 0, $1, scalar($3));
}
| scalar '{' expr ';' '}' /* $foo->{bar();} */
{ $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
}
| scalar '{' expr ';' '}' /* $foo->{bar();} */
{ $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
jmaybe($4));
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
jmaybe($4));
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
jmaybe($3));
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
jmaybe($3));
| term DOTDOT term /* $x..$y, $x...$y */
{
$$ = newRANGE(IVAL($2), scalar($1), scalar($3));
| term DOTDOT term /* $x..$y, $x...$y */
{
$$ = newRANGE(IVAL($2), scalar($1), scalar($3));
UNOP *op;
op = (UNOP*)$$;
op = (UNOP*)op->op_first; /* get to flop */
op = (UNOP*)op->op_first; /* get to flip */
op = (UNOP*)op->op_first; /* get to range */
token_getmad($2,(OP*)op,'o');
UNOP *op;
op = (UNOP*)$$;
op = (UNOP*)op->op_first; /* get to flop */
op = (UNOP*)op->op_first; /* get to flip */
op = (UNOP*)op->op_first; /* get to range */
token_getmad($2,(OP*)op,'o');
}
| term ANDAND term /* $x && $y */
{ $$ = newLOGOP(OP_AND, 0, $1, $3);
}
| term ANDAND term /* $x && $y */
{ $$ = newLOGOP(OP_AND, 0, $1, $3);
$$ = newANONATTRSUB($2, $3, $4, $5);
TOKEN_GETMAD($1,$$,'o');
OP_GETMAD($3,$$,'s');
$$ = newANONATTRSUB($2, $3, $4, $5);
TOKEN_GETMAD($1,$$,'o');
OP_GETMAD($3,$$,'s');
| DO scalar '(' ')' /* do $subref () */
{ $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
prepend_elem(OP_LIST,
| DO scalar '(' ')' /* do $subref () */
{ $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
prepend_elem(OP_LIST,
}
| '(' expr ')'
{ $$ = sawparens(IF_MAD(newUNOP(OP_NULL,0,$2), $2));
}
| '(' expr ')'
{ $$ = sawparens(IF_MAD(newUNOP(OP_NULL,0,$2), $2));
{
$$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
append_elem(OP_LIST, $3, scalar($1)));
{
$$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
append_elem(OP_LIST, $3, scalar($1)));
}
| NOAMP WORD listexpr /* foo(@args) */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
}
| NOAMP WORD listexpr /* foo(@args) */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
+ | YADAYADA
+ {
+ $$ = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),
+ newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")));
+ TOKEN_GETMAD($1,$$,'X');
+ }