[antlr-interest] CommonAST derived class problem

Jose Ventura jose.ventura.roda at gmail.com
Wed Jul 26 03:59:08 PDT 2006


I've one problem whit a derived AST class. When I use the option 1 all run
ok, but when I trie to use the option 2 I have a problem.

  Option 1
  --------
  in parser/ext/parser.g
        ASTLabelType = "parser.Nodo"

  in parser/Nodo.java
        public class Nodo extends CommonAST{...}

  Option 2
  --------

  in parser/ext/parser.g
        ASTLabelType = "parser.ext.NodoA"

  in parser/ext/NodoA
        public class NodoA extends Nodo {...}

  in parser/Nodo.java
        public abstract class Nodo extends CommonAST{...}

  problem:
  -----------
        Can't create AST Node parser.ext.NodoA

        this occurs in the next method of ASTFactory.java
 protected AST create(Class c) {
        AST t = null;
        try {
*               t = (AST)c.newInstance(); // make a new one     <<====*
             }
        catch (Exception e) {
              error("Can't create AST Node " + c.getName());
              return null;
        }
        return t;
}



       Apparently, the class parser.ext.NodoA is founded because if I change
the class name to another, the message is "Can't find/access AST Node type
NodoB", then if NodoA is derived from Nodo and Nodo from CommonAST, what's
the problem?

       I was able to see where can be it.

       Any help will be appreciated

   Thank's in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060726/a07f65a9/attachment.html


More information about the antlr-interest mailing list