summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-10-26 20:47:51 +0100
committerFather Chrysostomos <sprout@cpan.org>2010-11-07 12:46:54 -0800
commit727a8fe57e1987d0161772d4c35cc278f2ec6be8 (patch)
tree480bb38bb526bf5e11d126e794e17670c933a1fb /perly.y
parent7d3a730ee869d89a6f40963c80aaa0e044b0c7d2 (diff)
downloadperl-727a8fe57e1987d0161772d4c35cc278f2ec6be8.tar.gz
refactor GRAMPROG grammar slightly
Shift the structure of the GRAMPROG production (whole-file grammar) to more closely match that of the other top-level productions.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y26
1 files changed, 10 insertions, 16 deletions
diff --git a/perly.y b/perly.y
index 7407b21749..b8de63b0c8 100644
--- a/perly.y
+++ b/perly.y
@@ -89,7 +89,7 @@
%type <i_tkval> lpar_or_qw
-%type <ival> grammar prog progstart remember mremember
+%type <ival> grammar remember mremember
%type <ival> startsub startanonsub startformsub
/* FIXME for MAD - are these two ival? */
%type <ival> mydefsv mintro
@@ -139,8 +139,15 @@
%% /* RULES */
/* Top-level choice of what kind of thing yyparse was called to parse */
-grammar : GRAMPROG prog
- { $$ = $2; }
+grammar : GRAMPROG
+ {
+ PL_parser->expect = XSTATE;
+ }
+ remember stmtseq
+ {
+ newPROG(block_end($3,$4));
+ $$ = 0;
+ }
| GRAMBLOCK
{
parser->expect = XBLOCK;
@@ -188,12 +195,6 @@ grammar : GRAMPROG prog
}
;
-/* The whole program */
-prog : progstart
- /*CONTINUED*/ stmtseq
- { $$ = $1; newPROG(block_end($1,$2)); }
- ;
-
/* An ordinary block */
block : '{' remember stmtseq '}'
{ if (PL_parser->copline > (line_t)IVAL($1))
@@ -212,13 +213,6 @@ mydefsv: /* NULL */ /* lexicalize $_ */
{ $$ = (I32) Perl_allocmy(aTHX_ STR_WITH_LEN("$_"), 0); }
;
-progstart:
- {
- PL_parser->expect = XSTATE; $$ = block_start(TRUE);
- }
- ;
-
-
mblock : '{' mremember stmtseq '}'
{ if (PL_parser->copline > (line_t)IVAL($1))
PL_parser->copline = (line_t)IVAL($1);