lexing nested parenthesis

Michael Hudson mwh at python.net
Tue Jul 30 08:35:57 EDT 2002


pinard at iro.umontreal.ca (François Pinard) writes:

> [Kristian Ovaska]
> 
> > The language category you're dealing with is called context-free grammars.
> > It's more expressive than regular languages, and it can parse any
> > programming language.
> 
> Any? :-)
>
> I would not go that far.  There are strange beasts out there.

I was once told that this doesn't even cover Python: the meaning of
"a=b" depends on whether you're in an argument list or not.

> Moreover, people usually throw good parts of the complexity in
> "semantic analysis" passes.

This is true of Python.  Hopefully life will be better in the
wonderful world of 2.3.

> In the caricatural case, your grammar may parse individual
> characters and leave it all to later compilation stages, so a
> fortiori, any kind of parser will do.  We are diving in the complex
> art of compromises! :-)

Even Python 2.2 doesn't go quite this far <wink>.

Cheers,
M.

-- 
  But since I'm not trying to impress  anybody in The Software Big
  Top, I'd rather walk the wire using a big pole, a safety harness,
  a net, and with the wire not more than 3 feet off the ground.
                                   -- Grant Griffin, comp.lang.python



More information about the Python-list mailing list