Python needs better error reporting

James J. Besemer jb at cascade-sys.com
Sun Jun 30 03:11:14 EDT 2002


I rather think Dave has a good point.

A better parser could give a more informative diagnostic in this case and I
suspect others.

Tim Peters wrote:

> Well, "xor" isn't legit there, but other tokens that are OK after
>
>     if s == ' '
>
> include
>
>    [a ong list]

The question is NOT be what all may follow the string literal.  Rather it should
be what tokens are legal between the string literal and end of line?  Very
different questions.

If I'm not mistaken, only ":" or "\" are legal in that narrow context.  While
additional tokens may be legal in terms of following the string literal, they
still result in an error, so there's no point in listing them.  Line
continuation is a special case all its own.  Either it's illegal for some
reason, in which that situation constitutes a diagnostic all its own.  Otherwise
it can be completely ignored, as any errors/diagnostics would involve the next
following token, not the line continuation itself.

So it would be perfectly reasonable for the parser to say "semicolon missing" or
"semicolon expected" in this case.

Whether or not it's worth the effort to implement is, as always, debatable and
furthermore, I suppose, moot unless somebody is offering to do the work.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com







More information about the Python-list mailing list