}
// if reader != null, reset it
public static PyException fixParseError(ReaderCharStream reader, Throwable t, String filename) {
if (t instanceof ParseException) {
ParseException e = (ParseException) t;
Token tok = e.currentToken;
int col = 0;
int line = 0;
if (tok != null && tok.next != null) {
col = tok.next.beginColumn;
line = tok.next.beginLine;
}
String text = getLine(reader, line);
return new PySyntaxError(e.getMessage(), line, col, text, filename);
}
if (t instanceof TokenMgrError) {
TokenMgrError e = (TokenMgrError) t;
boolean eofSeen = e.EOFSeen;
int col = e.errorColumn;
int line = e.errorLine;
//System.err.println("eof seen: "+eofSeen+", "+e.curChar+", "+col+
// ", "+line);
String text = getLine(reader, line);
if (eofSeen)
col -= 1;
return new PySyntaxError(e.getMessage(), line, col, text, filename);
} else
return Py.JavaError(t);
}