On May 19, 6:43 am, "Edward K. Ream" <[email protected]> wrote: > I've been putting off this topic, hoping that the code would guide me. > However, several hours of work yesterday shows that there are some > tricky issues involved, so it's time to get as clear as possible about > what must be done.
I'm bringing myself back up to speed on the design. A few observations: 1. Most lines of the thin file being read add a line to the **current node**. @+node sentinels, @-others and @-<< sentinels change the current node. 2. The *current indentation** is the indentation level in effect for the current node. Determining the indentation level of a node is easier when using new sentinels: it is simply N, where N+1 is the number of '*' characters in the @+node sentinel of the current node. 3. Conceptually, a single stack suffices to keep track of the current node. This stack has entries of the form (p,indent) where p is the last node at the level and indent is the indentation level of node p. Suppose we see an @+node sentinel with N+1 stars. This sentinel creates a node at level N. Suppose the previous node p is at level M. If M == N, we create the new node as the following sibling of p. If N < M, we cut back the node stack to level N, and create the new node as the following sibling of the node at the top of the stack. If N == M + 1, we create the new node as the first child of p. If N > M +1, there is an error in the thin file. 4. The tricky part is handling sentinels like @-others and @-<<. My first thought is that simply pop the stack, but this may not be correct. Perhaps we do need a second stack containing entries for @ +others and @+<<, that tells how to cut back the stack when @-others and @-<< are seen. Or perhaps we can consider the @others directive and section references to create "virtual nodes" that can be handled by the node stack. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
