[Python-ideas] Proposal for Ruby-style anonymous block functions (that don't kill the indention)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Nov 15 00:54:10 CET 2008

Jan Kanis wrote:
> if we follow
> this train of thought to it's ultimate conclusion everything is LL1,
> just parse the file as a sequence of characters and sort out whether
> they make sense later on :) .

You're right that this is a possible implementation strategy,
but it doesn't mean that "everything is LL(1)".

Being LL(1) or not is a property of the grammar, and it concerns
the language that the *parser* accepts. The Python language
itself is actually not LL(1). CPython gets away with using
an LL(1) parser because the parser accepts a slightly
different language that's a superset of Python, and *that*
language is LL(1) (meaning that you can write down an LL(1)
grammar for it).

This is the strategy used by almost all practical language
implementations, and usually the division of labour is
arranged so that the parser does most of the hard work of
weeding out invalid programs.

In the case you suggest, you've gone to the extreme of making
the parser do almost none of the work, and although the
language the parser accepts is LL(1), it's a wildly different
one from the language the system as a whole accepts.

So when we talk somewhat loosely about a language such as
Python being LL(1), what we mean is that there is a superset,
which isn't *too* much bigger, that's LL(1), and we make
our parser recognize that superset.


More information about the Python-ideas mailing list