3 ms·
Regarding the "perl5 not in parrot" citation, i found some pretty good hints at this problem: From the Perl Wikipedia page: It is often said that "Only perl c
by buster 15y ago
Regarding the "perl5 not in parrot" citation, i found some pretty good hints at this problem:
From the Perl Wikipedia page:
It is often said that "Only perl can parse Perl",[49] meaning that only the Perl interpreter (perl) can parse the Perl language (Perl), but even this is not, in general, true. Because the Perl interpreter can simulate a Turing machine during its compile phase, it would need to decide the Halting Problem in order to complete parsing in every case. It's a long-standing result that the Halting Problem is undecidable, and therefore not even perl can always parse Perl. Perl makes the unusual choice of giving the user access to its full programming power in its own compile phase. The cost in terms of theoretical purity is high, but practical inconvenience seems to be rare.
Other programs that undertake to parse Perl, such as source-code analyzers and auto-indenters, have to contend not only with ambiguous syntactic constructs but also with the undecidability of Perl parsing in the general case. Adam Kennedy's PPI project focused on parsing Perl code as a document (retaining its integrity as a document), instead of parsing Perl as executable code (which not even Perl itself can always do). It was Kennedy who first conjectured that "parsing Perl suffers from the 'Halting Problem'",[50] which was later proved.[51]
Also interesting is the proof that Perl cannot be parsed:
http://www.jeffreykegler.com/Home/perl-and-undecidability http://www.jeffreykegler.com/Home/perl-and-undecidability
In general the saying "only perl can parse perl" has to have some root... http://www.google.de/search?q=%E2%80%9COnly+Perl+can+parse+Perl http://www.google.de/search?q=%E2%80%9COnly+Perl+can+parse+P...
- Mithaldu 15y agoOh yes. I am perfectly aware of the impossibility of static analysis of Perl. You do have to execute Perl in order to be able to say definitely what any Perl construct will mean. I'm just confused how this precludes inclusion of Perl5 in Perl6.
- chromatic 15y agoThat's not completely true though; most of those analyses take the conclusion way past the point where it's accurate. You cannot definitively produce a single canonical parse tree for every valid Perl 5 program without executing code in some cases, but you can produce a coherent and accurate parse tree without executing code if you allow nodes in the parse tree which express the two types of ambiguity (undeclared bareword interpretation and unknown arity). Most of the time this doesn't come up.