[antlr-interest] Java AST Grammar

John Ridgway john at jacelridge.com
Tue Feb 19 16:53:57 PST 2008


Yes, you need 3.0b7 won't work, but, actually, neither will 3.0.1.   
There is a bug in 3.0.1 (fixed in current beta releases of 3.1) that  
causes certain things not to work (they're marked with something like  
<---- trouble here in the grammar).  Get the latest release of 3.1beta  
and you'll be much happier.  (With 3.0.1 it will compile, it will just  
fail at runtime or give you a bad AST.)

I have to say that I was very impressed; when I pointed the bug out to  
Terence he got a new version with the fix out in a few (maybe one) days.

Peace
- John


On Feb 19, 2008, at 5:12 PM, Adam Cooney wrote:

> Hi John, I've been having some trouble running your grammar. I keep  
> getting the following error:
>
> C:\antlr-3.0b7\lib\Java\eg\ast>java org.antlr.Tool JavaAST.g
> ANTLR Parser Generator  Version 3.0b7 (April 12, 2007)  1989-2007
> error(100): JavaAST.g:709:53: syntax error: antlr: JavaAST.g:709:53:  
> unexpected
> token: ?
> error(100): JavaAST.g:710:61: syntax error: antlr: JavaAST.g:710:61:  
> unexpected
> token: ?
> error(100): JavaAST.g:711:51: syntax error: antlr: JavaAST.g:711:51:  
> unexpected
> token: ?
> error(100): JavaAST.g:712:58: syntax error: antlr: JavaAST.g:712:58:  
> unexpected
> token: ?
> error(100): JavaAST.g:0:0: syntax error: assign.types: <AST>:0:0:  
> unexpected end
>  of subtree
> error(10):  internal error: JavaAST.g :  
> java.lang.ClassCastException: antlr.ASTN
> ULLType cannot be cast to org.antlr.tool.GrammarAST
> org 
> .antlr.tool.AssignTokenTypesWalker.block(AssignTokenTypesWalker.java: 
> 1215)
> org 
> .antlr.tool.AssignTokenTypesWalker.rule(AssignTokenTypesWalker.java: 
> 1030)
> org 
> .antlr.tool.AssignTokenTypesWalker.rules(AssignTokenTypesWalker.java: 
> 610)
> org 
> .antlr 
> .tool.AssignTokenTypesWalker.grammarSpec(AssignTokenTypesWalker.java: 
> 49
> 2)
> org 
> .antlr 
> .tool.AssignTokenTypesWalker.grammar(AssignTokenTypesWalker.java:363)
> org.antlr.tool.Grammar.setGrammarContent(Grammar.java:539)
> org.antlr.tool.Grammar.<init>(Grammar.java:448)
> org.antlr.Tool.getGrammar(Tool.java:331)
> org.antlr.Tool.process(Tool.java:267)
> org.antlr.Tool.main(Tool.java:70)
>
> Any idea what could be causing it? I'm pretty new to ANTLR, but the  
> stringtemplate and antlr JARs are in the classpath, and I ran the  
> example treeparsers fine. Could it be due to using antlr-3.0b7  
> rather than antlr-3.0.1? I was using 3.0.1 but after installing it  
> and resetting the classpaths for some reason i got a Java  
> classloader error even after restarting the computer, and so I just  
> reverted back to this one.
>
>
> CC: john at jacelridge.com; antlr-interest at antlr.org
> From: john at jacelridge.com
> To: ad_cooney at hotmail.com
> Subject: Re: [antlr-interest] Java AST Grammar
> Date: Tue, 12 Feb 2008 17:41:05 -0500
>
> I have been working on a Java grammar that produces an AST; and a  
> companion tree grammar that produces equivalent Java code from an  
> AST.  This is still a work-in-progress, but you're welcome to what I  
> have.
>
> Please let me know if you run into any problems with this, as I'm  
> trying to make it work nicely.
>
> Peace
> - John
>
>
> She said what? About who? Shameful celebrity quotes on Search Star!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080219/06dc3d9d/attachment-0001.html 


More information about the antlr-interest mailing list