develooper Front page | perl.perl5.porters | Postings from November 2014

B::Concise omits regexp blocks

From:
Father Chrysostomos
Date:
November 30, 2014 04:38
Subject:
B::Concise omits regexp blocks
Message ID:
20141130043814.7527.qmail@lists-nntp.develooper.com
Regexps containing code blocks carry along with them their own little
op tree as of 5.18.  There doesn't seem to be any easy way to inspect
it.  It would be nice if B::Concise could show it, but, since it is
not part of the regular op tree, but a separate tree unto itself off
to the side, it is not clear how it should be shown.

We already have precedent for dumping something that is not strictly
part of the op tree; namely, the substitution part of s///e:

6     </> subst( replstart->7) vK ->9
5        <|> regcomp(other->6) sKS ->6
-           <1> ex-list sK ->5
3              <0> pushmark s ->4
-              <1> ex-rv2sv sK/1 ->-
4                 <#> gvsv[*a] s ->5
8        <|> substcont(other->6) sK/1 ->(end)
-           <1> null sK*/1 ->8
-              <@> scope sK ->-
7                 <0> stub s ->8
-e syntax OK

The substcont op is actually subst->op_pmreplrootu.op_pmreplroot, not
subst->op_last.

So the question is: where do I put the code blocks?  Before the
pmreplroot?  I tried that, and the output is like this:

$ ./perl -Ilib -MO=Concise -e 's/$a(?{$b})//e'
a  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 3 -e:1) v:{ ->3
7     </> subst( replstart->8) vK ->a
6        <|> regcomp(other->7) sKS ->7
-           <1> ex-list sK ->6
3              <0> pushmark s ->4
-              <1> ex-rv2sv sK/1 ->5
4                 <#> gvsv[*a] s ->5
-              <1> null sK*/1 ->-
-                 <1> ex-scope sK ->(end)
-                    <;> ex-nextstate(main 2 -e:1) v ->-
-                    <1> ex-rv2sv sK/1 ->-
-                       <#> gvsv[*b] s ->(end)
5              <$> const[PV "(?{$b})"] s ->6
-        <1> ex-list sK ->6
3           <0> pushmark s ->4
-           <1> ex-rv2sv sK/1 ->5
4              <#> gvsv[*a] s ->5
-           <1> null sK*/1 ->-
-              <1> ex-scope sK ->(end)
-                 <;> ex-nextstate(main 2 -e:1) v ->-
-                 <1> ex-rv2sv sK/1 ->-
-                    <#> gvsv[*b] s ->(end)
5           <$> const[PV "(?{$b})"] s ->6
9        <|> substcont(other->7) sK/1 ->(end)
-           <1> null sK*/1 ->9
-              <@> scope sK ->-
8                 <0> stub s ->9
-e syntax OK

For ops with run-time compilation, the code_list is also
op->op_first->op_first.  So an extra dump is redundant (and possibly
confusing).  So maybe what I should do is dump it only for precom-
piled regexps:

$ ./perl -Ilib -MO=Concise -e 's/(?{$b})//e'
6  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 3 -e:1) v:{ ->3
3     </> subst(/"(?{$b})"/ replstart->4) v ->6
-        <@> list K ->-
-           <0> pushmark s ->-
-           <1> null sK*/1 ->-
-              <1> ex-scope sK ->(end)
-                 <;> ex-nextstate(main 2 -e:1) v ->-
-                 <1> ex-rv2sv sK/1 ->-
-                    <#> gvsv[*b] s ->(end)
-           <$> const(PV "(?{$b})") s ->-
5        <|> substcont(other->3) sK/1 ->(end)
-           <1> null sK*/1 ->5
-              <@> scope sK ->-
4                 <0> stub s ->5
-e syntax OK

If nobody objects, I plan soon to commit something that does just
the latter.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About