On Friday, January 3, 2014 11:22:03 AM UTC-6, Edward K. Ream wrote:
> It's now time...[to use] the information in @auto-view nodes when reading
@auto nodes. This should be straightforward:
Indeed it is. Recreating clone links is conceptually easier:
1. Create a dictionary d whose keys are gnx's and whose values are vnodes.
d will have an entry for every vnode in Leo that is not contained in an
@auto node--it is used to find representative vnodes, which never appear in
@auto nodes.
Aside: Leo's read logic for .leo files creates a similar dictionary. It
*might* be possible to reuse it, but I doubt it...
2. For each unl in the @clones node for the @auto file (a child of the
corresponding @auto-views node), find the node in the @auto tree
corresponding to the the unl and create the clone link.
Recreating organizer nodes should be even easier in practice, but it does
require a little theorem, as I will now explain.
The @organizers (plural) node for the @auto tree will contain a list of
@organizer (singular) nodes. Each @organizer node will start with a unl
lines describing the location of the organizer node itself, followed by a
list of unl lines describing the children of the organizer node.
At first glance, it's unclear how to find those children in the
newly-imported @auto tree, but the theorem removes all confusion and
guarantees that finding the children will be very fast. Here it the theorem:
The nodes that will become children of the newly-created organizer node
O
will have the same parent as O in the newly-imported @auto tree.
So "demoting" the proper nodes so they are children of O is trivial: just
search for those nodes in O's parent P.
This theorem has two, no three, important, unexpected, happy side effects:
1. We can preserve the sibling order simply by processing P's children in
order. This guarantees that inserting O will leave the resulting external
file unchanged.
2. If a node with a given unl is not found in P's children, the @auto-view
code should do nothing. Moving any *other* node so it is a child of P
would, in fact, rearrange code in the external file. This should probably
never be done automatically.
3. The "cleanup" phase, which was originally imagined as a separate post
pass, now becomes trivial. The cleanup phase was intended to move comments
appearing before defs or classes into organizer nodes. But now we can see
that the only node that could contain such comments must be O's first child.
It looks like the design of @auto-view is complete. Perhaps only an hour
or three remain to complete the project.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.