Of course, this is based on an Evil Hack. The Evil Hack is to parse the output of perl -c -DTp. (You'll need a perl compiled with -DDEBUGGING for this to work.) These debug flags make perl output traces for any tokenizer and parser actions.
So, based on the traces, I can reconstruct the functioning of an LALR(1) parser, that "shadows" perl's parser (you know, shifts, reduces, and reading a new token symbol).
Drawbacks :
-DDEBUGGING."abc$def".Now I have to design an API for it. Basically I can trigger any callback on shifts, reduces and reads. Those sets of callbacks are conveniently packaged as, well, packages. So I was thinking about something like
Perl::ShadowParser that implements the parserPerl::ShadowParser::* backend plugins that provides the callbacks
perlshadowparser -b backend1 -b backend2=option1,option2 perlscript
Lots of tests will be needed, too.
If you have any ideas of something cool to do with it (ideas for backends...), I'm listening.
Well the obvious one... (Score:1)
Not sure how well that would work yet, but cool none the less!
Re:Well the obvious one... (Score:2, Interesting)
There are many ways to implement a Perl 5 to Perl 6 translator. For example, a B module similar to B::Deparse could do a good job. But it won't work on all Perl 5 sources. (See the BUGS section in the B::Deparse manpage.) Another way is to build a completely standalone Perl 5 parser. Very difficult (it's a task for Damians). A third solution is to put a hook into Perl 5.10's parser. The fourth solution is my Evil Hack. Of course, those solutions are not mut