- %********* rules that try to express situations completely specified (there is an effective deletion) ******
-
- % in the rules below, a token is either an i node, an n node, an o node, an s node or an empty c node.
- % an empty c node is either an undefined macro or an empty macro. These c node are handled as they actually were
- % tokens (i, n, o, s).
- % An important observation is: a sequence of groups with id, in which every group has one and only one child and where
- % the last group contains the cursor, is equivalent to the cursor (Is it clear?). For example:
- % <g id="id1"><g id="id2">...<g id="idn"><cursor/></g>...</g></g> is equivalent to:
- % <cursor/>
-
- % there is an optional sequence of groups with id, all of which having one and only one child. The last
- % child of this sequence (or the root, if the sequence is empty) is a group with id, has as first element a
- % token and has as second and last element an eventually empty sequence of groups with id, all of which having
- %one and only one child. The last element of this sequence has the cursor as its child.
- \item{\verb+(g[@id][^#$]/++\verb+)?g[@id][^(i|n|o|s|c[ ])#$]/(g[@id][^#$]/++\verb+)?cursor+}\\
- replace the whole fragment with the cursor.
-
- % the cursor is a macro's child. There is an eventually empty sequence of delimiters, which precedes the
- % cursor. Before this sequence, there is a p node. This p node has as its last child a token
- \item{\verb+c[p[(i|n|o|s|c[ ])$]((i|n|o|s|c[ ])*)#]/cursor+}\\
- remove the cursor and replace the token with the cursor.
-
- % there is a token, which precedes the cursor. The cursor is child of either a group or a parameter.
- % the case where the cursor is child of a group with id, there are no nodes after the cusror and there
- % are no nodes preceding the token, is handled by the first rule.
- % This rule is duplicated below, but that one could have a wrong syntax. This one has been tested.
- \item{\verb+<g|p>[(i|n|o|c[ ])#]/cursor+}\\
- remove the cursor and replace the token with the cursor.
-
- % cursor's parent is a script (the cursor is not the base). The script's base is an empty group with id.
- % The script is preceded by a token.The script's parent is group or a parameter.
- % The case where the script's parent is a group with id and the token is the first child, while
- % the script is the last one, is handled some rules later.
- \item{\verb+<g|p>[(i|n|o|s|c[ ])#]/<sp|sb>[^(g[@id][ ])#$]/cursor+}\\
- remove the script and replace the token with the cursor.
-
- % As above, but: we don't care who precedes the script (we do not have to remove it); the script's base
- % is still an empty group, but it has no id.
- % Ad above, we have to precise that the situation where the script is the only child of a group with id
- % is handled some rules later.
- \item{\verb+<g|p>/<sp|sb>[^(g[!@id][ ])#$]/curosr+}\\
- replace the script with the cursor.
-
- % The cursor is the last child of a script. The script's base is token.
- \item{\verb+<g|p>/<sp|sb>[^(i|n|o|s|c[ ])#$]/cursor+}\\
- repalce the script with the cursor.
-
-
- %*******************************************************************************************************
- %************** rules handling the case in which the cursor has a preceding node ***********************
- %*******************************************************************************************************
-
- %************************* the cursor's parent is a group or a parameter *******************************
-
- %we consider an empty macro as a token. An empty macro is either undefined or simply empty.
-
- %rule handling the case where the cursor has a preceding token and this is the first node of a group with id
- \item{\verb+g[@id][^(i||n||o||s||c[^$])#]/cursor+}\\
- remove the cursor and replace the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node with the $\NLDROP$.
- \item{\verb+<g|p>[(i||n||o||s||c[^$])#]/cursor+}\\
- remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
- %it corresponds to the drop_prev_group(false).
- \item{\verb+<g|p>[g#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \G{} node.
- %corresponds to the drop_prev_script(false).
- \item{\verb+<g|p>[(<sp|sb>)#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \SP{} or \SB{} node.
- %rules handling the right open macros preceding the cursor.
- \item{\verb+<g|p>[(c[^p[@right-open='1']$])#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \PNODE{} node.
- %we don't have a macro of this kind, but we don't know the future...
- \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/cursor+}\\
- remove the cursor and replace the \CNODE node with the $\NLDROP$.
- \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1']$])#]/cursor+}\\
- replace the \CNODE{} node with the content of the \PNODE node and replace the cursor with the $\NLDROP$.
- %rules handling macro with parameter(s) and preceding the cursor.
- \item{\verb+<g|p>[c#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \CNODE{} node.
- %rule handling table with rows preceding the cursor.
- \item{\verb+<g|p>[(table[row[cell[^g$]$]$])#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \G{} node, which is child of the \CELL{} node.
- %rule handling tables without rows preceding the cursor.
- \item{\verb+<g|p>[table#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the \TABLE{} node
-
- %********************************* the cursor's parent is a script ******************************
-
- %rule handling the case where the script's base is an empty group with id.
- \item{\verb+<sp|sb>[^(g[@id][^$])#$]/cursor+}\\
- replace the \SP{} or \SB{} node with the $\NLDROP$.
- %rule handling the case where the script's base is an empty group without id
- \item{\verb+<sp|sb>[^(g[^$])#$]/cursor+}\\
- replace the \SP{} or \SB{} node with the cursor.
- %rule handling the case where the script's base is something else
- \item{\verb+<sp|sb>[^*#$]/cursor+}\\
- replace the \SP{} or \SB{} node with it's first child and insert the $\NLDROP$ after it.
-
- %********************************* the cursor's parent is a macro ********************************
-
- %rule handling the case where the preceding node is a parameter
- \item{\verb+c[p#]/cursor+}\\
- remove the cursor and append the $\NLDROP$ to the PNODE{} node.
- %rule handling the case where the preceding node is a delimiter
- \item{\verb+c[(<i|n|o|s|c>)#]/cursor+}\\
- remove the cursor and insert the $\NLDROP$ before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
-
- %*************************************************************************************************
- %*********** rules handling the case in which the cursor has no preceding nodes ******************
- %*************************************************************************************************
-
- %rule handling the case where the cursor has something else after it
- \item{\verb+<g|p>[#*]/cursor+}\\
- nothing to drop.
-
- %rules handling the case where the cursor's parent is a p node and the cursor has no nodes after it.
-
- %rule handling the case where the p node is a left and right open macro's child and the first p node has no elements.
- \item{\verb+c[^(p[@left-open='1'][^$])#$]/p[@right-open='1'][^#$]/cursor+}\\
- replace the \CNODE{} with the $\NLDROP$.
- %rule handling the case where the p node is a left and right open macro's child and the first p node has elements.
- \item{\verb+c[^(p[@left-open='1']#$]/p[@right-open='1'][^#$]/cursor+}\\
- replace the \CNODE{} with the content of the PNODE{} with attribute texttt{left-open='1'} and insert $\NLDROP$ after this.
- %rule handling the case where the p node is right open macro's child.
- \item{\verb+c[^#$]/p[@right-open='1'][^#$]/cursor+}\\
- replace the \CNODE{} with the $\NLDROP$.
- %rule handling the case where the p node is a macro's child and this macro has parameter.
- \item{\verb+c/p[^#$]/cursor+}\\
- remove the cursor and insert the $\NLDROP$ before the \PNODE{} node.
-
- %rule handling the case where the cursor has no nodes after it and its parent is a group with id
- \item{\verb+g[@id][^#$]/cursor+}\\
- replace the \G{} node with the $\NLDROP$.