[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ANNOUNCE: SableCC version 2.1
>Now that we've announced our new tools at JavaOne (and started the
>process of updating our web pages), here's the place where we simply
>must access children by ordinal:
>Metamata Browse is a source code browser which allows you to move
>around in your program based on the syntactic structure. So for
>example, you could move to "the Java construct to your left". To
>do this, the browser knows the current location it is in the tree
>and simply shifts position to (currentordinal - 1). Clearly this
>is not sensitive to changes in the grammar (or at least sensible
>Trust me, there are other examples too. But I do agree that in
>general it is a good idea to allow access by name - just that you
>should not go overboard and disallow access by ordinal.
Your tool seems quite interesting!
I see that there would be a need to access the children in a sequential &
unnamed manner. But, I would be more in favor a collection approach, instead
of a numbered approach. To get the predecessor of a node, you would query
the children collection of the parent of the node and ask for a predecessor.
In other words, the collection offers you (1) an iterator [without absolute
positions] and (2) a "Node getNext/Prev(Node node)" to get the previous and
Why go all the way to hide the absolute position number? To prevent new
programmers from using them;-)
Would that be sufficient?