On Sat, Apr 05, 2008 at 04:46:46PM -0400, Etienne M. Gagnon wrote:
> The SableCC 2&3 model for lists is broken. The parent of a node, in a
> list, should be the list, not the parent of the list.
>
> As SableCC 4 is not Java-centric, anymore, it makes no sense to make
> SableCC generated code dependent of the Java API (such as the definition
> of clone()). On the other hand, it also means that ASTs should have
> their own List node type. For Java, it would allow us to enforce strict
> typing (even dynamically) for list elements, even though the Java
> compiler erases parametric types.
>
> In any case, SableCC 4 will need various such utility (usually hidden)
> classes for supporting the new, more flexible ASTs, such as:
>
> identifier_list = (identifier Separator comma)+;
>
> The above production matches: identifier [comma identifier [comma
> identifier [...]]] It requires some special node type (unaccessible to
> the programmer) so that AST walkers can visit the subtree.
I've just posted a message about the solution I've come up with for
the tree invariant and concurrent modification problems with the
lists, but I thought I'd keep the discussion on cloning them separate.
Whilst I was interested in node list behaviour in SableCC 4, as far as I
can tell, they are going to dissappear completely, leaving the tree
walkers as the only way of iterating though them. Is something like
the replaceBy() method going to be the only way of modifying these
lists? Please correct me if I'm mistaken.
On a last note, and I don't mean to rude, "replace by" is problematic
English. You would usually say "replace X with Y" when asking somebody
to replace something, and use "by" only in the past tense, "X was
replaced by Y". Unfortunately that's not the whole story. It is also
permissable to say "X was replaced with Y". I quite often find myself
using the nonexistsent replaceWith() method, and having to go back and
fix it later.
--
Jon Shapcott <
eden@...>
"This is the Space Age, and we are Here To Go" - William S. Burroughs
_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion