i use JavaCC for parsing my script... I have something like this in my *.jj
private Type parseType() throws MyScriptException:
{
Token token;
}
{ ( token = <INT>
| token = <FLOAT>
| token = <BOOL>
| token = <STRING>
)
{ return types.get(token.image); }
}
in types.get
I throw an exception from type MyScriptException
when anything goes wrong.
But I need in the output from which line the error was caused.
Can I integrate the line from error in MyScriptException
?
The Token
class has attributes that give the location of the token:
/** The line number of the first character of this Token. */
public int beginLine;
/** The column number of the first character of this Token. */
public int beginColumn;
/** The line number of the last character of this Token. */
public int endLine;
/** The column number of the last character of this Token. */
public int endColumn;