summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-06 20:32:58 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-06 22:18:55 -0800
commit8635e3c238f87f82dab918053e6f0b6a1a2525e6 (patch)
tree8b1e97bb9b986be7fcc83d38e6c96fb5e421ebaa /perly.y
parente13b6327463c1929bcd39bcdb74881e384ae113a (diff)
downloadperl-8635e3c238f87f82dab918053e6f0b6a1a2525e6.tar.gz
[perl #77452] Deparse BEGIN blocks in the right place
In the op tree, a statement consists of a nextstate/dbstate op (of class cop) followed by the contents of the statement. This cop is created after the statement has been parsed. So if you have nested statements, the outermost statement has the highest sequence number (cop_seq). Every sub (including BEGIN blocks) has a sequence number indicating where it occurs in its containing sub. So BEGIN { } #1 # seq 2 { # seq 1 ... } is indistinguishable from # seq 2 { BEGIN { } #1 # seq 1 ... } because the sequence number of the BEGIN block is 1 in both examples. By reserving a sequence number at the start of every block and using it once the block has finished parsing, we can do this: BEGIN { } #1 # seq 1 { # seq 2 ... } # seq 1 { BEGIN { } #2 # seq 2 ... } and now B::Deparse can tell where to put the blocks. PL_compiling.cop_seq was unused, so this is where I am stashing the pending sequence number.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y1
1 files changed, 1 insertions, 0 deletions
diff --git a/perly.y b/perly.y
index 90cf7315f0..839575d8c7 100644
--- a/perly.y
+++ b/perly.y
@@ -118,6 +118,7 @@ grammar : GRAMPROG
remember stmtseq
{
newPROG(block_end($3,$4));
+ PL_compiling.cop_seq = 0;
$$ = 0;
}
| GRAMEXPR