[antlr-interest] ANTLR & equals()/Equals() [Re: A way to find all subtrees of a particular type?]
micheal_jor
open.zone at virgin.net
Wed May 21 16:18:53 PDT 2003
> There is a quick fix. Redefine "equals" in your base AST class so
> that some text string--say ""--matches anything.
<SNIP>
Sorry for hijacking this thread but this reminded of one of the items
on my ANTLR to-do list (no, seriously):
"Moan about ANTLR's use of equals() in Java/C++ (and Equals() in C#)."
We recently had a situation where we wished to consider Tokens/AST-
Nodes equal only if they had the same type, text and came from the
same file. Simply re-defining equals/Equals for our Token/AST
subclass would have been the natural approach however, that broke
many other little bits since ANTLR generated code sometimes depends
on it's (re-)definition of equality.
Can we move ANTLR's notion of equality to some other method - perhaps
hasSameTypeAndText()/HasSameTypeAndText()- so that equals()/Equals()
can once again assume their intended meanings please?
Cheers,
Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list