[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Node




Hi Yuntao,

This is similar to what I was talking about in a previous post to this 
mailing list:

http://www.sable.mcgill.ca/listarchives/sablecc-list/msg00792.html

Although, if you want to add the method to the Node class you might find 
it easier to just edit the generated file. Maybe you could write a shell 
script or Makefile to do it for you every time you run sablecc.

A last approach is to write an interface for the extended nodes which 
includes the method, and then make sure you extend each node [1] and 
have a copy of the method in each. I used the C preprocesser (#included 
the method in each node) to do this and it works quite well but the 
makefile is a bit of a pain 
(http://roger.ninthave.net/software/snippets/java/makefile.inc).

Good luck!

Rog

[1] you need to hack the sablecc source and remove the final keyword in 
order to extend generated classes (see link above).


Yuntao Cui wrote:
> Hi,
> 
>  
> 
> I would like to add a method for the node object, so that all extended 
> classes
> 
> can use it. What is the best way to do it?
> 
>  
> 
> I hesitate to directly change on the generated file.
> 
>  
> 
> Thanks.
> 
>  
> 
> Yuntao Cui
> 
>  
>