OT: Ultimate Language Syntax Cleanness Comparison

Jeremy Fincher tweedgeezer at hotmail.com
Mon Feb 10 00:18:55 EST 2003


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.

Jeremy




More information about the Python-list mailing list