Posted By:
Lance_Walton
Posted On:
Thursday, October 14, 2004 04:00 AM
Hi. I have a grammar, a small section of which is: class MyParser extends Parser; options { ... defaultErrorHandler=false; ... } ... screenCreation[ErrorHandler errorHandler]: { this.errorHandler = errorHandler; } (screen)+ EOF! ; exception catch [RecognitionException re] { handleException(re); } catch [TokenStreamRecognitionException tsre] { handleException(tsre.recog); } ... My intention is to handle errors during parsing with the error handler. My problem is that the generated Java method for screenCreation
More>>
Hi.
I have a grammar, a small section of which is:
class MyParser extends Parser;
options {
...
defaultErrorHandler=false;
...
}
...
screenCreation[ErrorHandler errorHandler]:
{ this.errorHandler = errorHandler; }
(screen)+
EOF!
; exception
catch [RecognitionException re] {
handleException(re);
}
catch [TokenStreamRecognitionException tsre] {
handleException(tsre.recog);
}
...
My intention is to handle errors during parsing with the error handler.
My problem is that the generated Java method for
screenCreation
looks like this:
public final void screenCreation(ErrorHandler errorHandler)throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
AST screenCreation_AST = null;
try { // for error handling
this.errorHandler = errorHandler;
....
}
catch (RecognitionException re) {
handleException(re);
}
catch (TokenStreamRecognitionException tsre) {
handleException(tsre.recog);
}
returnAST = screenCreation_AST;
}
My question is this: why does the method still declare that it throws
RecognitionException
when I have provided a handler for it in the grammar?
Regards,
Lance
<<Less