On Jun 22, 11:34 am, "Edward K. Ream" <[email protected]> wrote:

> 4.  The tricky part is handling sentinels like @-others and @-<<.

Actually, I think the code is straightforward.  Here are my present
design notes:

The new scheme involves two stacks: at.thinNodeStack (the **node
stack*) and
at.endSentinelStack (the**sentinel stack**).  We push entries on the
node stack
when seeing +node sentinels, and push entries on the sentinel stack
when seeing
+others or +<< sentinels.

In the new scheme, the node stack contains entries (p,indent) for the
current
node at each level. The sentinel stack contains (kind,n) where kind is
@+others
or @+<< and n is the level after -others or -<< is seen.

Here is what must happen:

Case 1. -others and -<<

- Pop the sentinel stack into kind,n.
- Check that kind is +others or +<<.
- Cut back the node stack to level n. The top of the stack is
(p,indent).
  The present node becomes p, and indent becomes the present
indentation level.

Case 2. +node.

This terminates the previous node, if it hasn't already been
terminated.

Unlike in the old scheme, the nesting level of nodes is indicated by
the **level
stars** in the +node sentinel.Let N be the indentation of the new
+node, and M
be the previous indentation. In a well-formed file N <= M+1.

Case 2a: N == M + 1.  Create a new node as the first child of the
previous current node.

Case 2b: N == M.  Create a new node as the next sibling of the
previous current node.

Case 3c: N < M. Cut back the stack to level N. In a well-formed thin
file,
cutting back the stack can not terminate any section reference or
@others range. Check this
by ensuring that N is not less than the indent item for all entries in
the sentinel stack.

In other words, we can handle the two stacks independently of each
other, except for the checks indicated above.

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.

Reply via email to