[antlr-interest] Parser Exception-Handlers with Labels
Terence Parr
parrt at cs.usfca.edu
Wed Jun 14 09:45:27 PDT 2006
On Jun 14, 2006, at 9:37 AM, Carleton Coffrin wrote:
> I am using the Java ANTLR compiler 2.7.5 and am having some difficulty
> using labeled Exception-Handlers. When I use a label to refer to a
> grammar rule the code for that exception is not generated. For
> example,
>
> identifier returns [ASTIdentifier n = null] : x:ID { n = new
> ASTIdentifier(tok(x)); }
> ;
> exception catch [RecognitionException ex] {reportError(ex,
> "identifier message");}
> exception[x] catch [TokenStreamException ex] {reportError(ex, "ID
> token Mmssage");} //This works great!
>
>
> autoDef {ASTIdentifier n;}
> : auto:"auto" n=identifier
> ;
> exception catch [RecognitionException ex] {reportError(ex,
> "autoDef message");}
> exception[n] catch [This does] {not(get,"identifier rule
> message");} //<-------------- This never makes it to the generated
> code
Perhaps there is a bug that only token labels work...
Ter
More information about the antlr-interest
mailing list