[antlr-interest] unreachable catch block
Terence Parr
parrt at cs.usfca.edu
Thu May 14 15:00:11 PDT 2009
On May 14, 2009, at 2:21 PM, Warren Falk wrote:
> This has been asked on here before, but the answers no longer appear
> to be correct using the latest version (3.1.3).
>
> The output of the following combined grammar, TestParser.java, fails
> to compile with "Unreachable catch block" in the token rule (despite
> the empty @rulecatch which doesn't appear to have an effect). What am
> I missing? (The reason it's unreachable is because the '.' can't fail
> -- this is just an abbreviated grammar for illustration only).
that's why this one fails... oh and rulecatch works at global not
rule level i think.
T
>
>
> // -----------------------------
> grammar Test;
>
> options {
> language = Java;
> output = AST;
> }
>
> document
> : token+
> ;
>
> token
> @rulecatch { }
> : .
> ;
>
> WS : WSCHAR+ ;
>
> WORD : NONWSCHAR+ ;
>
> fragment
> NONWSCHAR : ~WSCHAR ;
>
> fragment
> WSCHAR : (' '|'\n'|'\r'|'\t') ;
> // -----------------------------
>
> Unreachable catch block for RecognitionException. This exception is
> never thrown from the try statement body TestParser.java
>
> Thanks in advance.
>
> P.S. this is my first time posting here and I'm a bit new to ANTLR, so
> I apologize in advance if this is a stupid request.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list