]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/doc/spec.tex
Added some rules in the Left Drop section
[helm.git] / helm / DEVEL / mathml_editor / doc / spec.tex
1 \documentclass[10pt]{article}
2
3 \usepackage{a4wide}
4 \usepackage{palatino}
5 \usepackage{euler}
6 \usepackage{amssymb}
7 \usepackage{stmaryrd}
8
9 \title{A MathML Editor Based on \TeX{} Syntax\\Formal Specification}
10 \author{Paolo Marinelli\\Luca Padovani\\\small\{{\tt pmarinel},{\tt lpadovan}\}{\tt @cs.unibo.it}\\\small Department of Computer Science\\\small University of Bologna}
11 \date{}
12
13 \newcommand{\tmap}[1]{\llbracket#1\rrbracket}
14 \newcommand{\tadvance}{\vartriangle}
15 \newcommand{\tnext}{\rhd}
16 \newcommand{\G}{\texttt{g}}
17 \newcommand{\PNODE}{\texttt{p}}
18 \newcommand{\SNODE}{\texttt{s}}
19 \newcommand{\INODE}{\texttt{i}}
20 \newcommand{\NNODE}{\texttt{n}}
21 \newcommand{\ONODE}{\texttt{o}}
22 \newcommand{\CNODE}{\texttt{c}}
23 \newcommand{\TABLE}{\texttt{table}}
24 \newcommand{\SP}{\texttt{sp}}
25 \newcommand{\SB}{\texttt{sb}}
26 \newcommand{\CELL}{\texttt{cell}}
27 \newcommand{\ROW}{\texttt{row}}
28 \newcommand{\SLDROP}{\blacktriangleleft}
29 \newcommand{\NLDROP}{\vartriangleleft}
30
31 \begin{document}
32
33 \maketitle
34
35 \section{Tokens}
36
37 The following tokens are defined:
38
39 \begin{tabular}{lllp{0.5\textwidth}}
40   \textbf{\TeX{}} & \textbf{Notation} & \textbf{Node} & \textbf{Description} \\
41 \hline
42   \verb+{+ & $\mathrm{begin}$ & \texttt{g} & Beginning of a group \\
43   \verb+}+ & $\mathrm{end}$ & & End of a group \\
44   \verb+$+ & $\$$ & \texttt{math} & Math shift \\ %$ \\
45   & &  & End-of-line \\
46   \verb+#+$i$ & $p(i)$ & \texttt{p} & Parameter \\
47   \verb+^+ & $\uparrow$ & \texttt{sp} & Superscript \\
48   \verb+_+ & $\downarrow$ & \texttt{sb} & Subscript \\
49   & $\square$ & & Space-like character that can be ignored \\
50   & $s$ & \texttt{s} & Space-like character that may be significant \\
51   letter & $i(v)$ & \texttt{i} & Identifier $v$ \\
52   digit & $n(v)$ & \texttt{n} & Number $v$ \\
53   other & $o(v)$ & \texttt{o} & Other character or operator $v$ \\
54   \verb+~+ & $\sim$ & & Active character \\
55   \verb+%+ & $\%$ & & Comment \\
56   control & $c(v)\langle\alpha_1,\dots,\alpha_n\rangle$ & \texttt{c} & 
57     Control sequence $v$ that expects the $\alpha_1,\dots,\alpha_n$ sequence of tokens. \\
58   backspace & $\vartriangleleft$ & & \\
59   backspace & $\blacktriangleleft$ & & \\
60 \end{tabular}
61
62 %% Some tokens are mapped directly into nodes of the TML tree. The following functions shows
63 %% the mapping:
64
65 \begin{tabular}{r@{\quad$=$\quad}l}
66   $\tmap{\{}$ & \verb+g+ \\
67   $\tmap{p(i)}$ & \verb+p[@index=+$i$\verb+]+ \\
68   $\tmap{p_l(i)}$ & \verb+p[@index=+$i$\verb+][@left-open='1']+ \\
69   $\tmap{p_r(i)}$ & \verb+p[@index=+$i$\verb+][@right-open='1']+ \\
70   $\tmap{s}$ & \verb+s+ \\
71   $\tmap{\uparrow}$ & \verb+sp+ \\
72   $\tmap{\downarrow}$ & \verb+sb+ \\
73   $\tmap{i(v)}$ & \verb+i[@value=+$v$\verb+]+ \\
74   $\tmap{n(v)}$ & \verb+n[@value=+$v$\verb+]+ \\
75   $\tmap{o(v)}$ & \verb+o[@value=+$v$\verb+]+ \\
76   $\tmap{c(v)\langle\alpha_1,\dots,\alpha_n\rangle}$ & \verb+c[@name=+$v$\verb+][^+$\tmap{\alpha_1}\cdots\tmap{\alpha_n}$\verb+$]+\\
77 \end{tabular}
78 %$
79
80 %% \section{Description and Semantics of the Pattern Language}
81
82 %% \begin{eqnarray*}
83 %%   \mathit{NodeTest} & ::= & \mathtt{*} \\
84 %%   & | & \mathit{ElementType} \\
85 %%   & | & \mathtt{<}~\mathit{ElementTypePattern}~\mathtt{>} \\[1ex]
86 %%   \mathit{ElementTypePattern} & ::= & \mathtt{*} \\
87 %%   & | & \mathit{ElementType}~(\mathtt{|}~\mathit{ElementType})^* \\
88 %%   & | & \mathtt{!}\mathit{ElementType}~(\mathtt{|}~\mathit{ElementType})^*\\[1ex]
89 %%   \mathit{NodePattern} & ::= & \mathit{NodeTest}~\mathit{AttributeQualifier}^*\\[1ex]
90 %%   \mathit{AttributeQualifier} & ::= & \mathtt{[@}\mathit{AttributeTest}\mathtt{]}\\
91 %%   & | & \mathtt{[!@}\mathit{AttributeTest}\mathtt{]}\\[1ex]
92 %%   \mathit{AttributeTest} & ::= & \mathit{AttributeName} \\
93 %%   & | & \mathit{AttributeName}\mathtt{='}\mathit{Text}\mathtt{'}
94 %% \end{eqnarray*}
95
96 \section{Insert Rules}
97
98 \paragraph{Begin Group:} $\{$
99
100 \begin{description}
101   \item{\verb+table/cursor+}\\
102    create a \texttt{row} node, create a \texttt{cell} node, create a \texttt{g} node,
103     append the cursor to the \texttt{g} node, append the \texttt{g} node to the \texttt{cell} node,
104     append the \texttt{cell} node to the \texttt{row} node, append the \texttt{row} node to the
105     \texttt{c} node 
106   \item{\verb+cursor+} \\ create a \texttt{g} node, replace the cursor with the new \texttt{g} node,
107     append the cursor to the new \texttt{g} node
108 \end{description}
109
110 % CASE: c/g[!@id]/cursor
111
112 % CASE: c/cursor
113
114 % ELSE:
115
116 % do_begin:
117 % CASE: c[@table='1']/cursor
118 % ELSE:
119 %   create a g node with id, replace the cursor with the fresh g and append
120 %   the cursor as only child of it
121
122 \paragraph{End Group:} $\}$
123
124 \begin{description}
125   \item{\verb+g[@id]/cursor+}\\
126   remove the cursor, put $\tadvance$ after the \texttt{g} node
127   \item{\verb+row/cell/g/cursor+}\\
128   remove the cursor, put $\tadvance$ after the \texttt{row} node
129   \item{\verb+math/g[!@id]/cursor+}\\
130   ?
131   \item{\verb+cursor+}\\
132   error ?
133 \end{description}
134
135 \paragraph{Math Shift:} $\$$
136
137 \begin{description}
138   \item{\verb+tex/cursor+}\\
139   create a \texttt{math} node, create a \texttt{g} node, append the \texttt{g} node
140     as child of the \texttt{math} node, append the cursor as child of the \texttt{g} node
141   \item{\verb+math[@display='1']/g[!@id][*#]/cursor+}\\
142   append the cursor as last child of the \texttt{math} node
143   \item{\verb+math/g[!@id][*#]/cursor+}\\
144   remove the cursor
145   \item{\verb+math[!display='1']/g[!@id]/cursor+}\\
146   set \verb+display='1'+ in the \texttt{math} node
147   \item{\verb+math/g[!@id]+}\\
148   append the cursor after the \texttt{math} node
149   \item{\verb+math/cursor+}\\
150   remove the cursor
151   \item{\verb+cursor+} \\
152   error ?
153 \end{description}
154
155 % do_shift:
156 % CASE: tex/cursor
157 %   create a math node. create a g node. append g as child of math.
158 %   append the cursor as child of g
159 % CASE: math[@display='1']/g[!@id][*#]/cursor
160 %   append the cursor as last child of math
161 % CASE: math/g[!@id][*#]/cursor
162 %   remove the cursor. Editing is done
163 % CASE: math[!display='1']/g[!@id]/cursor
164 %   set the display attribute to '1'
165 % CASE: math/g[!@id]
166 %   append the cursor after math (?)
167 % CASE: math/cursor
168 %   remove the cursor. Editing is done
169 % ELSE:
170 %   error
171
172 \paragraph{Align:} $\&$
173
174 \begin{description}
175   \item{\verb+g[@id]/cursor+}\\
176   create a \texttt{row} node, create a \texttt{cell} node, create a \texttt{g} node,
177     append the cursor to the new \texttt{g} node, append the \texttt{cell} node to the
178     the \texttt{row} node ?
179   \item{\verb+row/cell/g/cursor+}\\
180   create the \texttt{g} node, create the \texttt{cell} node, append the cursor
181     as child of the new \texttt{g} node, append the new \texttt{g} node to the new
182     \texttt{cell} node after the old \texttt{cell} node
183   \item{\verb+cursor+}\\
184   error
185 \end{description}
186
187 % do_align:
188 % CASE: g[@id]/cursor
189 %   create a row node. create a cell node. create a g node. append the
190 %   cursor to g, append the g to cell, append the cell to row, ???
191 % CASE: row/cell/g/cursor
192 %   create a g node. create a cell node. appent the cursor to g,
193 %   append the g to cell, insert the new cell after the existing cell
194 % ELSE:
195 %   error
196
197 \paragraph{End-of-line:}
198
199 % do_eol:
200 %   ignored
201
202 \paragraph{Parameter:} $p(i)$
203 % do_parameter:
204 %   ignored
205
206 \paragraph{Superscript:} $\uparrow$
207
208 \begin{description}
209   \item{\verb+<g|p>[^#]/cursor+}\\
210   create a \SP{} node, create a \G{} node, replace the cursor with the \SP{} node,
211     append the \G{} node as first child of the \SP{} node, append the cursor as last
212     child of the \SP{} node
213   \item{\verb+<g|p>[*#]/cursor+}\\
214   create a \SP{} node, replace \texttt{*} with the \SP{} node, append \texttt{*} to
215     the \SP{} node, append cursor to the \SP{} node
216   \item{\verb+sp[^*#$][!@over='1']/cursor+}\\ %$
217   set \verb+over='1'+ in the \SP{} node
218   \item{\verb+sp[^*#$][@over='1']/cursor+}\\ %$
219   error
220   \item{\verb+cursor+}\\
221   error ?
222 \end{description}
223 % do_superscript:
224 % CASE: g[^#]/cursor
225 %   create sp node. create g node, replace cursor with sp, append g to sp, append cursor to sp
226 % CASE: g[*#]/cursor
227 %   create sp node, replace * with sp, append * to sp, append cursor to sp
228 % CASE: sp[^*#$][!@over='1']/cursor
229 %   set over='1' in sp node
230 % CASE: sp[^*#$][@over='1']/cursor
231 %   error
232 % ELSE:
233 %   error ?
234
235 \paragraph{Subscript:} $\downarrow$
236
237 \begin{description}
238   \item{\verb+<g|p>[^#]/cursor+}\\
239   create a \SB{} node, create a \G{} node, replace the cursor with the \SB{} node,
240     append the \G{} node as first child of the \SB{} node, append the cursor as last
241     child of the \SB{} node
242   \item{\verb+<g|p>[*#]/cursor+}\\
243   create a \SB{} node, replace \texttt{*} with the \SB{} node, append \texttt{*} to
244     the \SB{} node, append cursor to the \SB{} node
245   \item{\verb+sb[^*#$][!@under='1']/cursor+}\\ %$
246   set \verb+under='1'+ in the \SB{} node
247   \item{\verb+sb[^*#$][@under='1']/cursor+}\\ %$
248   error
249   \item{\verb+cursor+}\\
250   error ?
251 \end{description}
252 % do_subscript:
253 % CASE: g[^#]/cursor
254 %   create sb node. create g node, replace cursor with sb, append g to sb, append cursor to sb
255 % CASE: g[*#]/cursor
256 %   create sb node, replace * with sb, append * to sb, append cursor to sb
257 % CASE: sb[^*#$][!@under='1']/cursor
258 %   set over='1' in sb node
259 % CASE: sb[^*#$][@under='1']/cursor
260 %   error
261 % ELSE:
262 %   error ?
263
264 \paragraph{Ignorable space:} $\square$
265
266 % do_ignorable_space:
267 %   do nothing?
268
269 \paragraph{Space:} $s$
270
271 \begin{description}
272   \item{\verb+cursor+}\\
273   create \SNODE{} node, replace cursor with the \SNODE{} node, append
274   $\tadvance$ after \SNODE{} node
275 \end{description}
276
277 % do_space
278 %   create s node, replace cursor with s, append \advance after s
279
280 \paragraph{Identifier:} $i(v)$
281
282 \begin{description}
283   \item{\verb+cursor+}\\
284   create an \INODE{}, set \verb+value=+$v$ in the \INODE{}, replace
285   cursor with \INODE{}, append $\tadvance$ after the \INODE{} node
286 \end{description}
287
288 % do_identifier
289 %   create i node, replace cursor with i, append \advance after i
290
291 \paragraph{Number:} $n(v)$
292
293 \begin{description}
294   \item{\verb+cursor+}\\
295   create an \NNODE{}, set \verb+value=+$v$ in the \NNODE{}, replace
296   cursor with \NNODE{}, append $\tadvance$ after the \NNODE{} node
297 \end{description}
298
299 % do_number
300 %   create n node, replace cursor with n, append \advance after n
301
302 \paragraph{Apostrophe:} $o({}')$
303
304 \begin{description}
305   \item{\verb+<g/p>[(sp[*#$]/g[o[@name='prime']$])#]/cursor+}\\
306   create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{},
307     append the \ONODE{} to the innermost \G{} node
308   \item{\verb+<g|p>[(sb[^sp[^*#$]/g[o[@name='prime']]$])#]/cursor+}\\
309   create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{},
310     append the \ONODE{} to the innermost \G{} node
311   \item{\verb+<g|p>[*#]/cursor+}\\
312   create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{},
313     create a \SP{} node, create a \G{} node, replace \texttt{*} with \SP{} node,
314     append the new \G{} node to the \SP{} node, append the \ONODE{}
315     node to the new \G{} node
316   \item{\verb+<g|p>[^#]/cursor+}\\
317   error?
318   \item{\verb+cursor+}\\
319   cursor is not in a group, error?
320 \end{description}
321
322 % do_apostrophe
323 % CASE: g[(sp[^*#$]/g[o[@name='prime']$])#]/cursor
324 %   append a new o[@name='prime'] node to the inner g node
325 % CASE: g[(sb[^sp[^*#$]/g[o[@name='prime']]$])#]/cursor
326 %   append a new o[@name='prime'] node to the inner g node
327 % CASE: g[*#]/cursor
328 %   create sp node, create g node, replace * with sp, append * to sp, append g to sp,
329 %   append a new o[@name='prime'[ node to the new g node
330 % CASE: g[^#]/cursor
331 %   error?
332 % ELSE:
333 %   cursor is not in a group, error?
334
335 \paragraph{Other:} $o(v)$
336
337 create an \ONODE{}, set \verb+value=+$v$ in the \ONODE{}, replace
338 cursor with \ONODE{}, append $\tadvance$ after the \ONODE{} node
339
340 % do_other
341 %   create o node, replace cursor with o, append \advance after o
342
343 \paragraph{Active:} $\sim$
344
345 % do_active:
346 %   ignored ???
347
348 \paragraph{Comment:} $\%$
349
350 % do_comment:
351 %   ignored ???
352
353 \paragraph{Begin Environment:} $c(\mathtt{begin})\langle\alpha_1,\dots,\alpha_n\rangle$
354
355 \paragraph{End Environment:} $c(\mathtt{end})\langle\rangle$
356
357 \paragraph{Left Delimiter:} $c(\mathtt{left})\langle\alpha\rangle$
358
359 \paragraph{Right Delimiter:} $c(\mathtt{right})\langle\alpha\rangle$
360
361 \paragraph{Carriage-Return:} $c(\mathtt{cr})\langle\rangle$
362
363 \begin{description}
364   \item{\verb+row/cell/g/cursor+}\\
365   create a \ROW{} node, create a \CELL{} node, create a \G{}
366     node, append the cursor to the new \G{} node, append the new \G{}
367     node to the new \CELL{} node, append the new \CELL{} node to the
368     new \ROW{} node, insert the new \ROW{} node after the old \ROW{} node
369   \item{\verb+cursor+}\\
370   ignored?
371 \end{description}
372
373 % do_cr:
374 % CASE: row/cell/g/cursor
375 %   create row node, create cell node, create g node,
376 %   append cursor to g, append g to cell, append cell to row,
377 %   insert new row after old row
378 % ELSE:
379 %   ignored ???
380
381 \paragraph{Macro:} $c(v)\langle\alpha_1,\dots,\alpha_n\rangle$
382
383 \begin{description}
384   \item{\verb+<p|g>/cursor+}\\
385   create a \CNODE{} node with the children corresponding to the pattern
386   $\tmap{\alpha_1}$,\dots,$\tmap{\alpha_n}$, replace the cursor with
387   the new \CNODE{} node. put $\tnext$ as the first child of the new
388   \CNODE{} node
389
390   \item{\verb+*/cursor+}\\
391   create a \CNODE{} node with the children corresponding to the pattern
392   $\tmap{\alpha_1}$,\dots,$\tmap{\alpha_n}$, replace the cursor with
393   the new \CNODE{} node, put $\tnext$ as the first child of the new
394   \CNODE{} node. If $n\ne0$ emit a warning (the macro has arguments but
395   but the context wouldn't normally allow them to be entered)
396 \end{description}
397
398 % do_macro:
399 % CASE: g/cursor
400 %   create a c node with children corresponding to the pattern of the macro
401 %   append \nextparam as first child of the macro
402
403 \section{Left Drop Rules}
404
405 \paragraph{Normal Left Drop:} $\NLDROP$
406
407 \begin{description}
408
409   %*******************************************************************************************************
410   %************** rules handling the case in which the cursor has a preceding node ***********************
411   %*******************************************************************************************************
412
413   %************************* the cursor's parent is a group or a parameter *******************************
414
415   %we consider an empty macro as a token. An empty macro is either undefined or simply empty.
416
417   %rule handling the case where the cursor has a preceding token and this is the first node of a group with id
418   \item{\verb+g[@id][^(i||n||o||s||c[^$])#]/cursor+}\\
419   remove the cursor and replace the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node with the $\NLDROP$.
420   \item{\verb+<g|p>[(i||n||o||s||c[^$])#]/cursor+}\\
421   remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
422   %it corresponds to the drop_prev_group(false).
423   \item{\verb+<g|p>[g#]/cursor+}\\
424   remove the cursor and append the $\NLDROP$ to the \G{} node.
425   %corresponds to the drop_prev_script(false).
426   \item{\verb+<g|p>[(<sp|sb>)#]/cursor+}\\
427   remove the cursor and append the $\NLDROP$ to the \SP{} or \SB{} node.
428   %rules handling the right open macros preceding the cursor.
429   \item{\verb+<g|p>[(c[^p[@right-open='1']$])#]/cursor+}\\
430   remove the cursor and append the $\NLDROP$ to the \PNODE{} node.
431   %we don't have a macro of this kind, but we don't know the future...
432   \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/cursor+}\\
433   remove the cursor and replace the \CNODE node with the $\NLDROP$.
434   \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1']$])#]/cursor+}\\
435   replace the \CNODE{} node with the content of the \PNODE node and replace the cursor with the $\NLDROP$.
436   %rules handling macro with parameter(s) and preceding the cursor.
437   \item{\verb+<g|p>[c#]/cursor+}\\
438   remove the cursor and append the $\NLDROP$ to the \CNODE{} node.
439   %rule handling table with rows preceding the cursor.
440   \item{\verb+<g|p>[(table[row[cell[^g$]$]$])#]/cursor+}\\
441   remove the cursor and append the $\NLDROP$ to the \G{} node, which is child of the \CELL{} node.
442   %rule handling tables without rows preceding the cursor.
443   \item{\verb+<g|p>[table#]/cursor+}\\
444   remove the cursor and append the $\NLDROP$ to the \TABLE{} node
445
446   %********************************* the cursor's parent is a script ******************************
447
448   %rule handling the case where the script's base is an empty group with id.
449   \item{\verb+<sp|sb>[^(g[@id][^$])#$]/cursor+}\\
450   replace the \SP{} or \SB{} node with the $\NLDROP$.
451   %rule handling the case where the script's base is an empty group without id
452   \item{\verb+<sp|sb>[^(g[^$])#$]/cursor+}\\
453   replace the \SP{} or \SB{} node with the cursor.
454   %rule handling the case where the script's base is something else
455   \item{\verb+<sp|sb>[^*#$]/cursor+}\\
456   replace the \SP{} or \SB{} node with it's first child and insert the $\NLDROP$ after it.
457
458   %********************************* the cursor's parent is a macro ********************************
459
460   %rule handling the case where the preceding node is a parameter
461   \item{\verb+c[p#]/cursor+}\\
462   remove the cursor and append the $\NLDROP$ to the PNODE{} node.
463   %rule handling the case where the preceding node is a delimiter
464   \item{\verb+c[(<i|n|o|s|c>)#]/cursor+}\\
465   remove the cursor and insert the $\NLDROP$ before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
466
467   %*************************************************************************************************
468   %*********** rules handling the case in which the cursor has no preceding nodes ******************
469   %*************************************************************************************************
470
471   %rule handling the case where the cursor has something else after it
472   \item{\verb+<g|p>[#*]/cursor+}\\
473   nothing to drop.
474
475   %rules handling the case where the cursor's parent is a p node and the cursor has no nodes after it.
476
477   %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.
478   \item{\verb+c[^(p[@left-open='1'][^$])#$]/p[@right-open='1'][^#$]/cursor+}\\
479   replace the \CNODE{} with the $\NLDROP$.
480   %rule handling the case where the p node is a left and right open macro's child and the first p node has elements.
481   \item{\verb+c[^(p[@left-open='1']#$]/p[@right-open='1'][^#$]/cursor+}\\
482   replace the \CNODE{} with the content of the PNODE{} with attribute texttt{left-open='1'} and insert $\NLDROP$ after this.
483   %rule handling the case where the p node is right open macro's child.
484   \item{\verb+c[^#$]/p[@right-open='1'][^#$]/cursor+}\\
485   replace the \CNODE{} with the $\NLDROP$.
486   %rule handling the case where the p node is a macro's child and this macro has parameter.
487   \item{\verb+c/p[^#$]/cursor+}\\
488   remove the cursor and insert the $\NLDROP$ before the \PNODE{} node.
489   
490   %rule handling the case where the cursor has no nodes after it and its parent is a group with id
491   \item{\verb+g[@id][^#$]/cursor+}\\
492   replace the \G{} node with the $\NLDROP$.
493
494 \end{description}
495
496 \paragraph{Special Left Drop:} $\SLDROP$
497
498 \begin{description}
499
500   %*******************************************************************************************************
501   %************** rules handling the case in which the cursor has a preceding node ***********************
502   %*******************************************************************************************************
503
504   %************************* the cursor's parent is a group or a parameter *******************************
505
506   %this rule is more specific than the one below which handle the case of the cursor preceded by a c node
507   \item{\verb+<g|p>[(i||n||o||s||c[^$])#]/cursor+}\\
508   remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
509   %it corresponds to the drop_prev_group(true).
510   \item{\verb+<g|p>[g#]/cursor+}\\
511   remove the cursor and append the it to the \G{} node.
512   %corresponds to the drop_prev_script(true).
513   \item{\verb+<g|p>[(<sp|sb>)#]/cursor+}\\
514   remove the cursor and append the $\SLDROP$ to the \SP{} or \SB{} node.
515   %rules handling the right open macros preceding the cursor.
516   \item{\verb+<g|p>[(c[^p[@right-open='1']$])#]/cursor+}\\
517   remove the cursor and append the $\SLDROP$ to the \PNODE{} node.
518   %we don't have a macro of this kind, but we don't know the future...
519   \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/cursor+}\\
520   remove the cursor and replace the \CNODE node with the cursor.
521   \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1']$])#]/cursor+}\\
522   replace the \CNODE{} node with the content of the \PNODE node.
523   %rule handling macro with parameter(s) and preceding the cursor.
524   \item{\verb+<g|p>[c#]/cursor+}\\
525   remove the cursor and append the $\SLDROP$ to the \CNODE{} node.
526   %rule handling table with rows preceding the cursor.
527   \item{\verb+<g|p>[(table[row[cell[^g$]$]$])#]/cursor+}\\
528   remove the cursor and append the it to the \G{} node, which is child of the \CELL{} node.
529   %rule handling tables without rows preceding the cursor.
530   \item{\verb+<g|p>[table#]/cursor+}\\
531   remove the cursor and append the $\SLDROP$ to the \TABLE{} node
532
533   %********************************* the cursor's parent is a script ******************************
534
535   %rule handling the case where the script's base is an empty group with id.
536   \item{\verb+<sp|sb>[^(g[@id][^$])#$]/cursor+}\\
537   replace the \SP{} or \SB{} node with the \G{} node and insert the cursor after it.
538   %rule handling the case where the script's base is an empty group without id
539   \item{\verb+<sp|sb>[^(g[^$])#$]/cursor+}\\
540   replace the \SP{} or \SB{} node with the cursor.
541   %rule handling the case where the scrip's base is something else
542   \item{\verb+<sp|sb>[^*#$]/cursor+}\\
543   replace the \SP{} or \SB{} node with it's first child and insert the cursor after it.
544
545   %********************************* the cursor's parent is a macro ********************************
546
547   %rule handling the case where the preceding node is a parameter
548   \item{\verb+c[p#]/cursor+}\\
549   remove the cursor and append the $\SLDROP$ to the PNODE{} node.
550   %rule handling the case where the preceding node is a delimiter
551   \item{\verb+c[(<i|n|o|s|c>)#]/cursor+}\\
552   remove the cursor and insert the it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
553
554   %*************************************************************************************************
555   %*********** rules handling the case in which the cursor has no preceding nodes ******************
556   %*************************************************************************************************
557
558   %rule handling the case where the cursor has something else after it
559   \item{\verb+<g|p>[#*]/cursor+}\\
560   nothing to drop.
561
562   %rules handling the case where the cursor's parent is a p node and the cursor has no nodes after it.
563
564   %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.
565   \item{\verb+c[^(p[@left-open='1'][^$])#$]/p[@right-open='1'][^#$]/cursor+}\\
566   replace the \CNODE{} with the cursor.
567   %rule handling the case where the p node is a left and right open macro's child and the first p node has elements.
568   \item{\verb+c[^(p[@left-open='1']#$]/p[@right-open='1'][^#$]/cursor+}\\
569   replace the \CNODE{} with the content of the PNODE{} with attribute texttt{left-open='1'} and insert cursor after this.
570   %rule handling the case where the p node is right open macro's child.
571   \item{\verb+c[^#$]/p[@right-open='1'][^#$]/cursor+}\\
572   replace the \CNODE{} with the cursor.
573   %rule handling the case where the p node is a macro's child and this macro has parameter.
574   \item{\verb+c/p[^#$]/cursor+}\\
575   remove the cursor and insert the $\SLDROP$ before the \PNODE{} node.
576   
577   %rule handling the case where the cursor has no nodes after it and its parent is a group with id
578   \item{\verb+g[@id][^#$]/cursor+}\\
579   replace the \G{} node with the cursor.
580
581 \end{description}
582
583 \section{Right Drop Rules}
584
585 \section{$\varepsilon$-rules}
586
587 \paragraph{Nromal Left Drop}
588
589 \begin{description}
590
591
592   %********************************************* \NLDROP has a preceding node *********************************************
593
594   %rule handling the case where the preceding node is a token or an empty macro.
595   \item{\verb+*[(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
596   remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or the \CNODE{} node.
597   %rule handling the case where the preceding node is a group
598   \item{\verb+*[g#]/+$\NLDROP$}\\
599   remove the $\NLDROP$ append it to the \G{} node.
600   %rule handling the case where the preceding node is a script
601   \item{\verb+*[<sp|sb>#]/+$\NLDROP$}\\
602   remove the $\NLDROP$ append it to the \SP{} or \SB{} node.
603   %rule handling the case where the preceding node is an open-right macro
604   \item{\verb+*[(c[^p[@right-open='1']$])#]/+$\NLDROP$}\\
605   remove the $\NLDROP$ and append it to the \PNODE{} node.
606   %rule handling the case where the preceding node is a left-open macro (and not right-open), and the p node of this macro has no children
607   \item{\verb+*[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/+$\NLDROP$}\\
608   remove the \CNODE node.
609   %rule handling the case where the preceding node is a left-open macro (and not right-open), and the p node of this macro has children
610   \item{\verb+*[(c[^p[!(@right-open='1')][@left-open='1']$])#]/+$\NLDROP$}\\
611   replace the \CNODE{} node with the content of the \PNODE{} node.
612   %rule handling the case where the preceding node is a macro with parameter(s)
613   \item{\verb+*[c#]/+$\NLDROP$}\\
614   remove the $\NLDROP$ and append it to the \CNODE{} node.
615
616   %rule handling the deletion of primes in superscript
617
618   %there are more than one prime in the phantom group
619   \item{\verb+sp[!(@id)][*#$]/g[!(@id)][o#]/+$\NLDROP$}\\
620   remove the \ONODE node, remove the $\NLDROP$ and insert the cursor after the \SP{} node.
621   %there is one and only one prime in the phantom group
622   \item{\verb+sp[!(@id)][*#$]/g[!(@id)][^o#]/+$\NLDROP$}\\
623   replace the \SP{} node with it's first child and insert the cursor after it
624
625   %*** rules handling the case where the \NLDROP's parent is a macro (with parameter) ***
626
627   %the node preceding the \NLDROP is a delimiter
628   \item{\verb+c[(<i|n|o|s|c>)#]/+$\NLDROP$}\\
629   remove the $\NLDROP$ and insert it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
630   %the node preceding the \NLDROP is parameter
631   \item{\verb+c[p#]/+$\NLDROP$}\\
632   remove the $\NLDROP$ and append it to the \PNODE{} node.
633
634   %********************************************* the \NLDROP has no preceding nodes ****************************************************
635
636   %if the \NLDROP has no preceding nodes, but has following nodes...
637   \item{\verb+<g|p>[#*]/+$\NLDROP$}\\
638   replace the $\NLDROP$ with the cursor.
639   %rule handling the case where the $\NLDROP$ is the only child of a group with id.
640   \item{\verb+g[@id][^#$]/+$\NLDROP$}\\
641   replace the \G{} node with the $\NLDROP$.
642   %\NLDROP is the first child of a macro with no inserted parameter
643   \item{\verb+c[!(p[*])][^#]/+$\NLDROP$}\\
644   replace the \CNODE{} with the $\NLDROP$.
645   %\NLDROP is the first child of a macro with some inserted parameter
646   \item{\verb+c[p[*]][^#]/+$\NLDROP$}\\
647   put the cursor in the first \PNODE{} node.
648   
649
650   %**** rule handling the case where the \NLDROP has a preceding token or a preceding empty macro, which is either undefined or empty ****
651
652   %%the \NLDROP's parent is neither a macro nor a phantom group which in turn is a sp's child and the token is a prime
653   %\item{\verb+*[(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
654   %replace the \INODE{}, \NNODE{}, \SNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node with the cursor and remove the $\NLDROP$.
655   %%the \NLDROP's parent is a macro with argument
656   %\item{\verb+c[((!(p[@left-open='1']))&(!(p[@right-open+'1'])))][(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
657   %remove the $\NLDROP$ and insert it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
658   %%rule handling the case where the \NLDROP's parent is a phantom group, which in turn is a sp's child
659   %\item{\verb+sp[!(@id)][^*#$]/g[!(@id)][o#$]/+$\NLDROP$}\\
660   %remove the \ONODE{} node
661
662   %********************************* rules handling the case where the \NLDROP has a preceding group **************************************
663   \item{\verb+*[g#]/+$\NLDROP$}\\
664   remove the $\NLDROP$ and append it to the \G{} node.
665
666 \end{description}
667
668 \paragraph{Special Left Drop}
669
670 \begin{description}
671
672   \item{special left}\\
673
674 \end{description}
675
676 \paragraph{Advance}
677
678 \begin{description}
679   \item{\verb+g/+$\tadvance$}\\
680   replace $\tadvance$ with the cursor
681
682   \item{\verb+p[#$]/+$\tadvance$}\\ %$
683   put $\tadvance$ after the \PNODE{} node
684
685   \item{\verb+c[#p]/+$\tadvance$} \\
686   remove $\tadvance$, put the cursor as first child of the \PNODE{} node
687
688   \item{\verb+c[#*]/+$\tadvance$} \\ %$
689   replace $\tadvance$ with the cursor 
690
691   \item{\verb+c[#$]/+$\tadvance$} \\ %$
692   move $\tadvance$ after the \CNODE{} node
693 \end{description}
694
695 \paragraph{Next Parameter}
696
697 \paragraph{Next Token}
698
699 %% \begin{description}
700 %%   \item{\verb+c[#p]/+$\tnext$} \\
701 %% \end{description}
702
703 % g[@id]/(c[#$][@right-open]/g[!@id][#$]/)+cursor  }   let p = cursor.parent() in remove; advance(p)
704
705 % c/g[!@id]/cursor
706 % c/cursor 
707 % */cursor  {   let g = new group in replace
708
709 % g[@id][^#$]/cursor  <=   cursor.parent().replace(cursor)
710 % g[@id][^#$]/cursor  <-   cursor
711 % (!g[@id][^#$])[A#B]/(g[@id][^#$]/)+cursor  <-  (!g[@id][^#$])[A#B]/cursor  
712
713 \end{document}