[Python-Dev] parsers and compilers for 2.0 (original) (raw)

Neil Schemenauer nascheme@enme.ucalgary.ca
Sat, 12 Aug 2000 18:03:57 -0400


With all the recent proposed and accepted language changes, we should be a careful to keep everything up to date. The parser module, Jeremy's compiler, and I suspect JPython have been left behind by the recent changes. In the past we have been blessed by a very stable core language. Times change. :)

I'm trying to keep Jeremy's compiler up to date. Modifying the parser module to understand list comprehensions seems to be none trivial however. Does anyone else have the time and expertise to make these changes? The compiler/transformer.py module will also have to be modified to understand the new parse tree nodes. That part should be somewhat easier.

On a related note, I think the SyntaxError messages generated by the compile() function and the parser module could be improved. This is annoying:

>>> compile("$x", "myfile.py", "eval")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 1
    $x
    ^
SyntaxError: invalid syntax

Is there any reason why the error message does not say "myfile.py" instead of ""? If not I can probably put together a patch to fix it.

As far as I can tell, the parser ParserError exceptions are almost useless. At least a line number could be given. I'm not sure how much work that is to fix though.

Neil