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

Re: AST serialization

Archie Cobbs wrote:
> Haven't thought much about this, but you might want to consider
> implementing Comparable and Cloneable as well, if not already.

I see some problems here:

(1) Comparable:  This one requires ordering of compared objects. How do
you "order" different AST nodes?  If you want to use, let say, the depth
first ordering, then comparing two nodes might get complicated, and O(N)
in the worst case, where N is the size of the AST.  Ugh!

(2) Cloneable:  Because a SableCC AST node cannot have to distinct
parents, this would mean that you want a "deep" cloning.  This is not
supported by the Comparable interface, which goal is to declare that
"shallow copying" is safe.  The alternative is to override clone(), but
is this really a needed feature?  Might be!?

Discussion is welcome!

PS: As of now, I do not have time other than for cosmetic (i.e.: light)
changes to SableCC.
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                 http://www.sable.mcgill.ca/sablecc/