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).
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::ShadowParserthat implements the parser
Perl::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.