[antlr-interest] Building an AST for Java

Dan Delorey antlr at deloreyfamily.org
Sat Apr 19 11:41:28 PDT 2008


I've been having quite a bit of trouble generating an AST for Java. I
started by trying to modify the Java.g posted by Ter. I have also tried
using the one posted by Dieter Habelitz. In both cases I'm having the same
problem, though.

That is, I can't seem to modify the grammar so that it doesn't require
backtracking. With backtracking, however, critical (for my purposes) parts
of the AST are missing. For example, the branches that should be generated
by the following code:

f.getName().length()

Is incomplete. I can get either the f.getName() function call in the tree or
the length() function call, but not both.

So far I have tried using rule scopes, global scopes, parameters, return
values, and standard rewrite rules. I'm really confused that this is so hard
for me. Could anyone give me some guidance?

Thanks,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080419/8a878e85/attachment.html 


More information about the antlr-interest mailing list