[antlr-interest] JavaEmitter update questions

Andy Tripp antlr at jazillian.com
Mon Apr 10 13:29:30 PDT 2006


Vaios,
I sent you an email response to this a while back, I guess you didn't 
get it.
The answer is just to look at the AST. Don't get caught up in trying to 
understand
the ANTLR grammar (unless you want to). Just use the ASTFrame class that
came with ANTLR or use some other simple way to print out the AST and go 
from there.

IIRC, there is no classOrInterfaceType in the ANTLR-generated 
JavaTokenTypes.java,
only LITERAL_class and LITERAL_interface.

Andy


Vaios Kalpias wrote:

> I have made some progress updating the JavaEmitter class for Java 1.5, 
> but I'd like to ask a few questions. First, I'd like to let you all 
> know that I'm using the grammar that can be found at the ANTLR files. 
> The first major difficulty I faced was implementing the 
> classOrInterfaceType. This rule is as follows:
>
> classOrInterfaceType
>   :    IDENT (typeArguments)?
>   |    #( DOT classOrInterfaceType )
>   ;
>
> typeArguments
>   :    #(TYPE_ARGUMENTS (typeArgument)+)
>   ;
>
> typeArgument
>   :    #(    TYPE_ARGUMENT
>           (    typeSpec
>           |    wildcardType
>           )
>       )
>   ;
>
> The problem is that I don't understand how am I going to put 
> classOrInterfaceType in the big switch statement since antlr does not 
> "setType" a #CLASSORINTERFACETYPE. I figured that in this case we 
> follow the rule until we find a # symbol, which is then inserted in 
> the switch statement. But in this case classOrInterfaceType ends up 
> using IDENT (typeArguments)? and IDENT is never a root node in the 
> AST. I hope I made u understand my question!! There are more things 
> I'm trying to figure out, but if I understand this I believe I'll 
> solve my other problems too.
>
> Regards,
> Vaios.
>



More information about the antlr-interest mailing list