OT: Ultimate Language Syntax Cleanness Comparison

holger krekel pyth at devel.trillke.net
Mon Feb 10 12:50:59 CET 2003

Jeremy Fincher wrote:
> holger krekel <pyth at devel.trillke.net> wrote in message news:<mailman.1044706941.23586.python-list at python.org>...
> > please show me the snippet how to parse a perl snippet without evaluating it. 
> > I am really interested and we even posted to the perl-porters list at
> > the time.   
> Check out the root level directory of an unpacked Perl 5.8.0
> distribution.  You'll find two files there, bytecode.pl and perly.y. 
> Perly.y is the yacc parser for Perl.  At the beginning you'll see the
> list of tokens it parses code into (those lines begin with %token.) 
> Then look at the end of bytecode.pl.  It's a perl script that details
> the bytecodes that Perl is compiled into; you'll note that the set of
> parser tokens is most definitely *not* the set of bytecodes.  Thus,
> there exists some transformation elsewhere in the Perl code that turns
> the abstract syntax tree created by perly.y into the bytecode later
> interpreted.  Thus, Perl is parsed separately from being evaluated.

Then it should be easy enough to come up with a mini-snippet
that gives me the parse tree, right?  I don't think that the
mentioned files help me much with it.  Sites like


or a thread on perl monks


suggests it's extremely difficult.  

If so can you send the snippet which parses *any* perl script? 
If your deduction above is true, then it should be easy.

As said before someone who is doing perl for ages (and hacking
at the core) looked for a *whole day* trying to come up with 
a *sane* way to parse perl scripts.   We could eventually parse
some files but often enough our perl-interpreter got seriously 
messed up.   

Has this changed with 5.8? 



More information about the Python-list mailing list