Python needs to explain parsing? was Re: Python needs better error reporting

John Roth johnroth at ameritech.net
Sun Jun 30 20:05:23 EDT 2002


"Antaeus Feldspar" <feldspar at ix.netcom.com> wrote in message
news:3D1F8843.8080602 at ix.netcom.com...
> After reading the thread spun out of all of this, this brings up an
idea
> that I've had for quite some time:  can the Python interpreter be made
> to report more information about *how* it is parsing the syntax it
finds?
>
> For instance, given the valid line "if s == ' ':" it might return
> something like the following (or at least this might be what is
> displayed to the user based on information the parser displays):
>
> if <condition>: ---- [next 8 lines of code]
> |
> ==
>        / \
>       /   \
>      s    ' '
>
> thus confirming that what was meant to be a condition is being parsed
as
> a condition.  Clearly if the user sees that the parser is putting the
> block of code to be conditionally executed in where the condition
should
> be, that's a very visual sign of trouble...
>
> It's not quite the solution David seems to be looking for, but I think
> it would address the same problem; is it possible?

Frankly, "expecting <foorap> found <bletch>" for reasonably
intuitive values of <foorap> and <bletch> can tell a moderately
experienced programmer a great deal.

It does very little for novices, however. Except that with a little
experience, most people discover that they make the same mistake,
over and over again. Then the same error message is helpful, even
if it means little to anyone else.

John Roth





More information about the Python-list mailing list