Re: Looking for Perl Grammar
- From: Joe Smith <joe@xxxxxxxxx>
- Date: Sat, 30 Apr 2005 03:35:28 -0700
Khamis Abuelkomboz wrote:
I'm writing a Perl parser and I'm looking for a pure perl grammar.
You won't find it.
My favorite example is this:
#!/usr/bin/perl -l
print time / 2 ; #/; die 'This die() is not executed';
print cos / 2 ; #/; warn 'But this warn() is!';
To resolve the ambiguity of / as numerator/denominator versus m//
requires knowledge of which functions require arguments and which
do not. And if the program has 'use Module;', to determine which
user-defined functions take arguments and which do not requires
actually parsing the Module. You can't do that with pure grammar.
-Joe
.