[antlr-interest] Grammar File: Get text from token

Jose Ventura jose.ventura.roda at gmail.com
Thu Nov 2 00:13:18 PST 2006


I think

    :    "class" i:IDENT{
            String txt = #i.getText();
            ts.setName(txt);
        }
Regards,

2006/11/1, luciano mantuaneli <mantu_lists at yahoo.com.br>:
>
> Greetings!
> I'm working with a java grammar and in some point, I want to retrieve the
> class name. The rule is like follows:
>
> // Definition of a Java class
> classDefinition![AST modifiers]{
>     boolean isInner = ts.getName() != null;
> }
>     :    "class" IDENT{
>             String txt = $getText;
>             ts.setName(txt);
>         }
>         // it _might_ have type paramaters
>         (tp:typeParameters)?
>         // it _might_ have a superclass...
>         sc:superClassClause
>         // it might implement some interfaces...
>         ic:implementsClause
>         // now parse the body of the class
>         cb:classBlock
>         {#classDefinition = #(#[CLASS_DEF,"CLASS_DEF"],
>                                 modifiers,IDENT,tp,sc,ic,cb);}
>     ;
>
> It doesn't work that way. The ANTLR Plugin says that "_begin cannot be
> resolved".
> How can I retrieve the name of the class being parsed?
> Thank you all!
>
>
>
> Luciano Mantuaneli
> Analist-Programmer
>
> ------------------------------
> Você quer respostas para suas perguntas? Ou você sabe muito e quer
> compartilhar seu conhecimento? Experimente o Yahoo! Respostas<http://us.rd.yahoo.com/mail/br/tagline/answers/*http://br.answers.yahoo.com/>!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20061102/46c18062/attachment.html 


More information about the antlr-interest mailing list