[antlr-interest] ASTFrame usage?

Paul Johnson gt54-antlr at cyconix.com
Thu Jul 21 05:53:09 PDT 2005


I'd like to use ASTFrame with C++, if possible, but first I'm trying to 
get a Java example to work. However, I know almost exactly nothing about 
Java, and I've spent a couple of hours trying to get the example in the 
manual working:

> public static void main(String args[]) {
>   // Create the tree nodes
>   ASTFactory factory = new ASTFactory();
>   CommonAST r = (CommonAST)factory.create(0, "ROOT");
>   r.addChild((CommonAST)factory.create(0, "C1"));
>   r.addChild((CommonAST)factory.create(0, "C2"));
>   r.addChild((CommonAST)factory.create(0, "C3"));
>   ASTFrame frame = new ASTFrame("AST JTree Example", r);
>   frame.setVisible(true);
> }

Could someone please manage an idiot's guide to making this code do 
something? So far, I've turned it into:

----------------------------------
import antlr.ASTFactory;
import antlr.CommonAST;
import antlr.ASTFrame;

class main {
    public static void main(String args[]) {
// Create the tree nodes
       ASTFactory factory = new ASTFactory();
       CommonAST r = (CommonAST)factory.create(0, "ROOT");
       r.addChild((CommonAST)factory.create(0, "C1"));
       r.addChild((CommonAST)factory.create(0, "C2"));
       r.addChild((CommonAST)factory.create(0, "C3"));
       ASTFrame frame = new ASTFrame("AST JTree Example", r);
       frame.setVisible(true);
    }
}
----------------------------------

If I compile this as

javac main.java -classpath path-to-antlr/lib/antlr.jar

Then java 1.5 tells me that it can't import antlr.ASTFrame ("cannot find 
symbol"). I can't compile with 1.4 at all ("class file has wrong version 
49.0, should be 48.0").

Thanks -

Paul



More information about the antlr-interest mailing list