lexing nested parenthesis

François Pinard pinard at iro.umontreal.ca
Wed Jul 31 09:05:54 EDT 2002


[Kristian Ovaska]

> Perl must be hard to parse, [...]

It is a common statement that no one was ever able to wrote a Perl parser
recognising exactly the same language as Perl itself.  At most, people
can achieve good approximations.

> PLY has good error reporting, too.

I'm a bit ambivalent about PLY.

There are undoubtedly very good ideas in there, and this is a good and
useful tool.  But there are a few negative sides: 1) it looks like not
supported anymore, 2) it prohibits more than one grammar per module and
forces a specific presentation (because it needs to read back the Python
_source_ at run-time), 3) I had to fight it so it accepts a scanner of my
choice, yet I do not remember the details as I write.

In fact, what saddened me most is that PLY was written after SPARK and was
admittedly inspired by SPARK, but failed to recognise and offer some of the
most elegant aspects of SPARK.  There was no (or at least, I did not see
the) real advantage of dropping them.  PLY was written to teach parsing,
and I guess it wanted to force an overly precise setup on every student.
But being outside the class, I do not really want the rigid setup on me.

On the other hand, the good error reporting and the ability to generate
speedy parsers for complex grammars are overwhelmingly appealing, so I am
sometimes happy to use PLY, despite these few things I do not like in it.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list