[antlr-interest] Java AST Grammar

Adam Cooney ad_cooney at hotmail.com
Thu Feb 21 10:50:02 PST 2008


Sigh, nevermind. I should have paid more attention to the "ANTLRInputStream input = new ANTLRInputStream(System.in);". I did it quickly before I left and didnt have time to notice.
 
Sorry for wasting your time, works fine :) ty


From: ad_cooney at hotmail.comTo: antlr-interest at antlr.orgDate: Thu, 21 Feb 2008 18:28:08 +0000Subject: Re: [antlr-interest] Java AST Grammar


Thanks John. I'm having a slight problem running it on a Java file though (problem as in, it seems to take a LONG time compiling, and by along, the source file I've ran (frm the Java examples) hasn't finished compiling yet. heres my console:C:\antlr-3.0b7\lib\Java\eg\ast>java org.antlr.Tool JavaAST.gANTLR Parser Generator  Version 3.1b1 (??)  1989-2007C:\antlr-3.0b7\lib\Java\eg\ast>java org.antlr.Tool JavaPrinterTree.gANTLR Parser Generator  Version 3.1b1 (??)  1989-2007C:\antlr-3.0b7\lib\Java\eg\ast>javac *.javaNote: Some input files use unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.C:\antlr-3.0b7\lib\Java\eg\ast>java Test input (note: input is of type File). Could you please send me an example one (preferably that doesnt take long to compile:)) or correct me if im trying to do this wrong - i am basing it off how I have ran others via ANTLR. Sorry to be such a novice at this stuff.Thanks Adam 

CC: john at jacelridge.com; antlr-interest at antlr.orgFrom: john at jacelridge.comTo: ad_cooney at hotmail.comSubject: Re: [antlr-interest] Java AST GrammarDate: Tue, 19 Feb 2008 19:53:57 -0500Yes, 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.gANTLR Parser Generator  Version 3.0b7 (April 12, 2007)  1989-2007error(100): JavaAST.g:709:53: syntax error: antlr: JavaAST.g:709:53: unexpectedtoken: ?error(100): JavaAST.g:710:61: syntax error: antlr: JavaAST.g:710:61: unexpectedtoken: ?error(100): JavaAST.g:711:51: syntax error: antlr: JavaAST.g:711:51: unexpectedtoken: ?error(100): JavaAST.g:712:58: syntax error: antlr: JavaAST.g:712:58: unexpectedtoken: ?error(100): JavaAST.g:0:0: syntax error: assign.types: <AST>:0:0: unexpected end of subtreeerror(10):  internal error: JavaAST.g : java.lang.ClassCastException: antlr.ASTNULLType cannot be cast to org.antlr.tool.GrammarASTorg.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:492)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.orgFrom: john at jacelridge.comTo: ad_cooney at hotmail.comSubject: Re: [antlr-interest] Java AST GrammarDate: Tue, 12 Feb 2008 17:41:05 -0500I 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!

She said what? About who? Shameful celebrity quotes on Search Star! 
_________________________________________________________________
Free games, great prizes - get gaming at Gamesbox. 
http://www.searchgamesbox.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080221/c4edd8d1/attachment.html 


More information about the antlr-interest mailing list