Re:Perl Cannot Be Parsed: A Formal Proof (2008)
by overgard on Sunday May 26, 2013 @07:11PM
(#5772763)
> it proves that Perl can't be parsed unambiguously.
That's what can't be parsed means. They're pretty clear about what they mean by something being "parsable", you're muddying that definition to extend it to: "parsable: things that can be vaguely processed most of the time"
Re:Perl Cannot Be Parsed: A Formal Proof (2008)
by Vivtek on Sunday May 26, 2013 @08:31AM
(#5770933)
This perfectly encapsulates my feelings about the Perl parsing question!
An ambiguous parse is still a parse, and yeah, the 'whatever' example is pathologically unmaintainable code. As you say, if a static parser finds it ambiguous, you should probably fix it.
The example given is:
This can be parsed into two variants without running any code or knowing the arity of whatever.The case where whatever takes no arguments:
The case where whatever takes a single argument: What does this mean practically? If you want to rename "whatever" to something else, you can do that, since the name of the function is captured no matter how many arguments it takes. If you want to lint all your regular expressions, you can do that with the chance that you'll be wrong if you guessed the prototype wrong.The only thing you can't do is figure out exactly how the code will run at runtime. But if you could do that, you wouldn't have a computer program, you'd just have a lookup table.
Another thing to keep in mind: if a static analysis tool can't understand your code, perhaps the future maintainer can't either. In that case, why not rewrite the code to not be ambiguous?