Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Perl Cannot Be Parsed: A Formal Proof

by Anonymous Monk
on Jan 28, 2008 at 03:08 UTC ( #664611=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl Cannot Be Parsed: A Formal Proof
in thread Perl Cannot Be Parsed: A Formal Proof

There are many languages that have "eval" and yet have unambiguous parse trees for the actual code of the program (as opposed to the code evaluated at runtime).

If you run this Python program you'll see it prints out a complete parse tree of the program BEFORE it runs eval. Before you jump down my throat, I'm not saying that this makes Python a better language than Perl. It's just a fact that a language can be constructed so that "eval" is totally handled at runtime and does not affect the parsability of the program.

import sys import parser print parser.suite(open(__file__).read()).totuple() x = eval(sys.stdin.readline()) if x: print "yes", x else: print "no", x
To bring this back to the original post, the "parser" module is the Python equivalent of what Parse::Perl would be if Perl parsing were possible.


Comment on Re^3: Perl Cannot Be Parsed: A Formal Proof
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://664611]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-04-17 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls