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

Antaeus Feldspar feldspar at ix.netcom.com
Sun Jun 30 18:37:55 EDT 2002


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?

David LeBlanc wrote:

> "Syntax Error: invalid syntax" isn't very informative, yet it's tossed out
> frequently. HOW is the syntax invalid? For example:
> if s == ' '
> 
> David LeBlanc
> Seattle, WA USA
> 
> 
> 
> 




More information about the Python-list mailing list