[antlr-interest] Re: AST typecasting problem?

Steve stevegianvecchio at hotmail.com
Wed Nov 10 15:16:23 PST 2004



I made the necessary changes and the code is working properly. Thanks 
to both of you (John and Loring) for your help.

Steve

--- In antlr-interest at yahoogroups.com, "lgcraymer" <lgc at m...> wrote:
> 
> The most likely cause is (from
> http://www.antlr.org/doc/trees.html#_bb3 in the ANTLR manual):
> 
> "If you are only interested in specifying the AST node type at
> runtime, use the
> 
> setASTNodeType(String className)
> 
> method on the parser or factory.  By default, trees are constructed 
of
> nodes of type antlr.CommonAST. (You must use the fully-qualified 
class
> name)."
> 
> Do that in the parser and you should be okay:  my guess is that your
> parser is generating CommonAST nodes (the default).
> 
> --Loring
> 
> --- In antlr-interest at yahoogroups.com, "Steve" 
<stevegianvecchio at h...>
> wrote:
> > 
> > 
> > I created this file:
> > 
> > public class BeliefAST extends antlr.CommonAST {
> >     List beliefList;
> > }
> > 
> > Then in a separated file:
> > 
> > ...
> > AST t1 = parser.getAST();
> > BeliefAST t2 = (BeliefAST)t1;
> > System.out.println("I don't get here.");
> > 
> > At the second line, where the typecast takes place, my program 
exits 
> > immediately without any errors.  The following code works fine:
> > 
> > ...
> > AST t1 = parser.getAST();
> > CommonAST t2 = (CommonAST)t1;
> > System.out.println("I don't get here.");
> > 
> > I can't think of what I'm doing wrong.  I tried replacing my 
> > BeliefAST file with CommonAST and just changing the 
text "CommonAST" 
> > to "BeliefAST" and got the same result.  I can't seem to figure 
out 
> > what is causing this, anyone have any ideas?





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list