Ah, I got it.

I did not run "jython" jar as is, I don't quite understand why current jython outputs the error, because as I wrote in inital comment to the issue, that error is not recorded (errors container is empty in RecordingErrorHandler).

What if I just override BaseRecognizer's emitErrorMessage and make it do nothing? 

2012/3/26 Frank Wierzbicki <report@bugs.jython.org>

Frank Wierzbicki <fwierzbicki@users.sourceforge.net> added the comment:

So starting with a file with an error:

def a foo():
<end of file>

CPython gives:

 File "error.py", line 1
   def a foo():
           ^
SyntaxError: invalid syntax

Current Jython gives:


 File "error.py", line 1
   def a foo():
        ^
SyntaxError: mismatched input 'foo' expecting LPAREN

And Jython with your patch gives:

line 1:6 mismatched input 'foo' expecting LPAREN
 File "error.py", line 1
   def a foo():
        ^
SyntaxError: mismatched input 'foo' expecting LPAREN

The trouble with your patch is that it causes two error messages in the output - the first from ANTLR at the top

line 1:6 mismatched input 'foo' expecting LPAREN

and the python style at the bottom:

 File "error.py", line 1
   def a foo():
        ^
SyntaxError: mismatched input 'foo' expecting LPAREN

The bottom Python style is what we want, and so the top ANTLR error message is extraneous -- if you could rework the patch to avoid the extra output (basically you'd need to override ANTLR's reportError message and leave out the call to displayRecognitionError call then this  would be an acceptable patch. Thanks for working on this! I'd love to get others working in the parser -- it clearly needs more eyes :)

_______________________________________
Jython tracker <report@bugs.jython.org>
<http://bugs.jython.org/issue1866>
_______________________________________



--
Have fun,
   Roman Shuvaev.
  
   cell: +79119529883.