[antlr-interest] ANTLR C++ error?

Ric Klaren klaren at cs.utwente.nl
Wed Feb 27 01:51:23 PST 2002


Hi,

On Wed, Feb 27, 2002 at 05:56:50AM -0000, marc_schellens wrote:
> I have the following tree parser:
> 
> label!
>   : #(i:IDENTIFIER COLON)
> 	{ 
> 	  #label=#[LABEL,i->getText()];
> 	  comp.Label(#label); 
> 	}	
>   ;
> 
> ANTLR generates:
> 	
> label_AST=astFactory.create(LABEL,i->getText());
> comp.Label(label_AST); 
> 
> ok.		
> But for the following:
> 
> var!
>   : #(VAR i:IDENTIFIER)
> 	{ 
> 	  #var=#[VAR,i->getText()];
> 	  comp.Var(#var);	
> 	}
>   ;
> 
> ANTLR generates:
> 		 
> var_AST=astFactory.create(static_cast<antlr::RefAST>(static_cast<antlr::RefAST>(tmp58_AST),i->getText()));
> 		  comp.Var(var_AST);	
> 
> What is the reason? For me both examples look
> pretty much the same.

Why do you suspect this is an error? Is there weird behaviour? As far as I
can tell you have a treeparser with buildast on.

In the first case antlr cannot copy the incoming AST so it generates a new
one. In the second case the incoming ast (_t) can be copied (via tmp58) to
the output tree whilst overriding the text. The code may be inefficient but
it works.

I see no problem here.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Time what is time - I wish I knew how to tell You why - It hurts to know -
          Aren't we machines - Time what is time - Unlock the door
               - And see the truth - Then time is time again
                From: 'Time what is Time' by Blind Guardian


 

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



More information about the antlr-interest mailing list