[antlr-interest] Inheritance of BaseAST class

FC tangfc2001 at yahoo.com
Fri Mar 18 15:40:37 PST 2005


Hi,

I tried to use setASTNodeClass method to specify the
node type of AST to my defined class JavaAST under
package MyPkg. while there is run-time error agian: 
Can't find/access AST node type MyPkg.JavaAST.

My code is as follows:

JavaLexer lexer = new JavaLexer(r);
lexer.setFilename(f);
// Create a parser that reads from the scanner
JavaRecognizer parser = new JavaRecognizer(lexer);
parser.setFilename(f);
parser.setASTNodeClass("MyPkg.JavaAST");
		
// start parsing at the compilationUnit rule
parser.compilationUnit();

JavaAST t = (JavaAST)parser.getAST();

thanks 

Ted


--- "John D. Mitchell" <johnm-antlr at non.net> wrote:
> >>>>> "FC" == FC  <tangfc2001 at yahoo.com> writes:
> [...]
> 
> > But there is run-time error: parser exception:
> > java.lang.ClassCastException at line of "JavaAST t
> =
> > (JavaAST)parser.getAST();", that is, the AST
> object can not be casted to
> > my subclass JavaAST. How can I solve this problem?
> 
> Check out the setASTNodeClass() method of the
> parser.
> 
> Go wild,
> 	John
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list