% 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+}\\
+ \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 ***********************
%*******************************************************************************************************