diff options
author | Zefram <zefram@fysh.org> | 2010-10-19 21:16:11 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-25 12:29:46 -0700 |
commit | eae48c8938e50ebb341a72c2886c5ae8587092a5 (patch) | |
tree | a581082ad6e284de2600033f738b631b475e702e /op.c | |
parent | ff0c75af8a61dcd9e5fa0e07c8c01e142cadd899 (diff) | |
download | perl-eae48c8938e50ebb341a72c2886c5ae8587092a5.tar.gz |
refactor and regularise label/statement grammar
Refactoring of the grammar around statements. New production <barestmt>
encompasses a statement without label. It includes all statement types,
including declarations, with no unnecessary intermediate non-terminals.
It generates an op tree for the statement's content, with no leading
state op. The <fullstmt> production has just one rule, consisting of
optional label followed by <barestmt>. It puts a state op on the front
of the statement's content ops.
To support the regular statement op structure, the op sequence for for(;;)
loops no longer has a second state op between the initialisation and
the loop. Instead, the unstack op type is slightly adapted to achieve
the stack clearing without a state op.
The newFOROP() constructor function no longer generates a state op,
that now being the job of the <fullstmt> production. Consequently it
no longer takes a parameter stating what label is to go in the state op.
This brings it in line with the other op constructors.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -5429,7 +5429,7 @@ whileline, OP *expr, OP *block, OP *cont, I32 has_my) } /* -=for apidoc Am|OP *|newFOROP|I32 flags|char *label|line_t forline|OP *sv|OP *expr|OP *block|OP *cont +=for apidoc Am|OP *|newFOROP|I32 flags|line_t forline|OP *sv|OP *expr|OP *block|OP *cont Constructs, checks, and returns an op tree expressing a C<foreach> loop (iteration through a list of values). This is a heavyweight loop, @@ -5447,16 +5447,13 @@ I<flags> gives the eight bits of C<op_flags> for the C<leaveloop> op and, shifted up eight bits, the eight bits of C<op_private> for the C<leaveloop> op, except that (in both cases) some bits will be set automatically. I<forline> is the line number that should be attributed -to the loop's list expression. If I<label> is non-null, it supplies -the name of a label to attach to the state op at the start of the loop; -this function takes ownership of the memory pointed at by I<label>, -and will free it. +to the loop's list expression. =cut */ OP * -Perl_newFOROP(pTHX_ I32 flags, char *label, line_t forline, OP *sv, OP *expr, OP *block, OP *cont) +Perl_newFOROP(pTHX_ I32 flags, line_t forline, OP *sv, OP *expr, OP *block, OP *cont) { dVAR; LOOP *loop; @@ -5577,8 +5574,7 @@ Perl_newFOROP(pTHX_ I32 flags, char *label, line_t forline, OP *sv, OP *expr, OP wop = newWHILEOP(flags, 1, loop, forline, newOP(OP_ITER, 0), block, cont, 0); if (madsv) op_getmad(madsv, (OP*)loop, 'v'); - PL_parser->copline = forline; - return newSTATEOP(0, label, wop); + return wop; } /* |