[antlr-interest] 2.7.5 bug report: catch for never-thrown exception in empty rule

Alexey Demakov demakov at ispras.ru
Fri Jul 29 03:18:41 PDT 2005


When empty rule is translated:

class MyParser extends Parser;

expression : ;

The following code is produced:

 public final void expression() throws RecognitionException, TokenStreamException {
  
  
  try {      // for error handling
  }
  catch (RecognitionException ex) {
   reportError(ex);
   recover(ex,_tokenSet_0);
  }
 }

That causes error reported by java 1.5 compiler:

MyParser.java:48: exception antlr.RecognitionException is never thrown in body o
f corresponding try statement
                catch (RecognitionException ex) {
                ^
1 error

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com




More information about the antlr-interest mailing list