/* perly.y
*
- * Copyright (c) 1991-1994, Larry Wall
+ * Copyright (c) 1991-1997, 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.
/*
* 'I see,' laughed Strider. 'I look foul and feel fair. Is that it?
- * All that is gold does not glitter, not all those that wander are lost.'
+ * All that is gold does not glitter, not all those who wander are lost.'
*/
%{
%token <ival> DOLSHARP DO HASHBRACK NOAMP
%token LOCAL MY
-%type <ival> prog decl local format startsub startanonsub
+%type <ival> prog decl local format startsub startanonsub startformsub
%type <ival> remember mremember '&'
%type <opval> block mblock lineseq line loop cond else
%type <opval> expr term scalar ary hsh arylen star amper sideff
%type <opval> argexpr nexpr texpr iexpr mexpr mnexpr mtexpr miexpr
-%type <opval> listexpr listexprcom indirob
-%type <opval> listop method subname proto subbody cont my_scalar
+%type <opval> listexpr listexprcom indirob listop method
+%type <opval> formname subname proto subbody cont my_scalar
%type <pval> label
%left <ival> OROP
/* basically fake up an initialize-while lineseq */
{ copline = $2;
$$ = block_end($4,
- append_elem(OP_LINESEQ, scalar($5),
- newSTATEOP(0, $1,
+ newSTATEOP(0, $1,
+ append_elem(OP_LINESEQ, scalar($5),
newWHILEOP(0, 1, (LOOP*)Nullop,
scalar($7),
$11, scalar($9))))); }
{ $$ = 0; }
;
-format : FORMAT startsub WORD block
+format : FORMAT startformsub formname block
{ newFORM($2, $3, $4); }
- | FORMAT startsub block
- { newFORM($2, Nullop, $3); }
+ ;
+
+formname: WORD { $$ = $1; }
+ | /* NULL */ { $$ = Nullop; }
;
subrout : SUB startsub subname proto subbody
{ newSUB($2, $3, $4, $5); }
;
-startsub: /* NULL */ /* start a subroutine scope */
- { $$ = start_subparse(); }
+startsub: /* NULL */ /* start a regular subroutine scope */
+ { $$ = start_subparse(FALSE, 0); }
;
startanonsub: /* NULL */ /* start an anonymous subroutine scope */
- { $$ = start_subparse();
- CvANON_on(compcv); }
+ { $$ = start_subparse(FALSE, CVf_ANON); }
+ ;
+
+startformsub: /* NULL */ /* start a format subroutine scope */
+ { $$ = start_subparse(TRUE, 0); }
;
subname : WORD { char *name = SvPVx(((SVOP*)$1)->op_sv, na);