[antlr-interest] Is catch a keyword in Antlr3

shmuel siegel antlr at shmuelhome.mine.nu
Wed Nov 8 00:59:43 PST 2006


Sorry if this is a multiple post. Previous reports are not showing up in 
the mailing list.

Consider this simple grammar.

tryStatement     :     'try' block
                    (
                            finallyclause
                        |
                             catch ( finallyclause )?
                    )
                    ;

catch     :     'catch' '(' identifier ')' block;
finallyclause     :     'finally' block;

block
    :    'b';
identifier
    :    'c';


antlrworks says that 'catch' in tryStatement is an unexpected token.
Changing the rule to catchx solves the problem. I don't see any mention
on the Antlr3 site that indicates that one should avoid this word as a
parser rule.

Shmuel





More information about the antlr-interest mailing list