Hi Shane, Inside a combined- or lexer- or parser grammar, the `tokens` should be placed before the `members` section(s):
(lexer | parser)? grammar ... options { ... } tokens { ... } @header { ... } (or: @parser::header { ... }, @lexer::header { ... }) @members { ... } (or: @parser::members { ... }, @lexer::members { ... }) But a tree grammar gets its tokens from the `tokenVocab` key: tree grammar ExprWalker; options { tokenVocab=Expr; ASTLabelType=CommonTree; } So no `tokens` section inside a tree grammar. Regards, Bart. On Sun, Jul 10, 2011 at 9:31 PM, Shane <srber...@gmail.com> wrote: > 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 > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.