[antlr-interest] @members section in tree grammar

Shane srberry1 at gmail.com
Sun Jul 10 12:31:09 PDT 2011


I can put an @members section in a grammar without any problem, but when I
put one in a tree grammar, I get a bunch of exceptions.  It ignores
everything after the @members section.  BTW,  I'm trying to get access to
the error output, so I can show it to the user.

Exception:
unexpected token: tokens {


grammar Expr;

options {
    output=AST;
    ASTLabelType=CommonTree;
    backtrack=true;
}

@members {
    public String getTokenErrorDisplay(Token t) {
        return t.toString();
    }
}

tokens {
    DIV                     = '/'               ;
    EQUAL                   = '=='              ;
    GREATER_OR_EQUAL        = '>='              ;
    GREATER_THAN            = '>'               ;
...


Can tree grammars handle @members sections?  or am I doing something wrong?

Thanks,

srb


More information about the antlr-interest mailing list