[antlr-interest] Re: Heterogeneous AST - simple calculator pa rser

mzukowski at bco.com mzukowski at bco.com
Fri Feb 8 06:37:04 PST 2002


Your token types may be out of sync.  Look at the generated code and make
sure that UNARY_MINUS exists in both parser and tree walker, and that its
value is the same in both.  You may not be setting the tokenVocabulary
properly.  If they are both in the same file then maybe you forgot to
recompile your treewalker.

Monty

> -----Original Message-----
> From: koud0002 [mailto:robertkoudelka at power-solutions.com.au]
> Sent: Thursday, February 07, 2002 7:48 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: Heterogeneous AST - simple calculator
> parser
> 
> 
> Thanks for your reply.
> 
> The AST is now constructed correctly.
> However, I am now getting "unexpected end of subtree" 
> NoViableAltException from the treewalker.
> The treewalker still does not recognize UNARY_MINUS.
> 
> I would still like to use the custom AST. 
> What am I doing wrong? Thanks
> 
> Robert
> 
> --- In antlr-interest at y..., Sinan <sinan.karasu at b...> wrote:
> > koud0002 wrote:
> > > 
> > [...]
> > > 
> > > simpleExpression
> > >   : MINUS t:term!
> > 
> > change to
> > 
> > 	:m:MINUS^  term      {#m.setType(UNARY_MINUS);}
> > 
> > you don't need all that UnaryMinusNode stuff. The rest is done in 
> the
> > treewalker
> > 
> >  #(UNARY_MINUS expression ....
> > 
> > same for UNARY_PLUS...
> > 
> > Sinan
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 



 

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



More information about the antlr-interest mailing list