1 \documentclass[10pt]{article}
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}
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}
37 The following tokens are defined:
39 \begin{tabular}{lllp{0.5\textwidth}}
40 \textbf{\TeX{}} & \textbf{Notation} & \textbf{Node} & \textbf{Description} \\
42 \verb+{+ & $\mathrm{begin}$ & \texttt{g} & Beginning of a group \\
43 \verb+}+ & $\mathrm{end}$ & & End of a group \\
44 \verb+$+ & $\$$ & \texttt{math} & Math shift \\ %$ \\
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$ & & \\
62 %% Some tokens are mapped directly into nodes of the TML tree. The following functions shows
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+$]+\\
80 %% \section{Description and Semantics of the Pattern Language}
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{'}
96 \section{Insert Rules}
98 \paragraph{Begin Group:} $\{$
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
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
110 % CASE: c/g[!@id]/cursor
117 % CASE: c[@table='1']/cursor
119 % create a g node with id, replace the cursor with the fresh g and append
120 % the cursor as only child of it
122 \paragraph{End Group:} $\}$
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+}\\
131 \item{\verb+cursor+}\\
135 \paragraph{Math Shift:} $\$$
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+}\\
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+}\\
151 \item{\verb+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'
166 % append the cursor after math (?)
168 % remove the cursor. Editing is done
172 \paragraph{Align:} $\&$
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+}\\
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
197 \paragraph{End-of-line:}
202 \paragraph{Parameter:} $p(i)$
206 \paragraph{Superscript:} $\uparrow$
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+}\\ %$
220 \item{\verb+cursor+}\\
225 % create sp node. create g node, replace cursor with sp, append g to sp, append cursor to sp
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
235 \paragraph{Subscript:} $\downarrow$
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+}\\ %$
249 \item{\verb+cursor+}\\
254 % create sb node. create g node, replace cursor with sb, append g to sb, append cursor to sb
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
264 \paragraph{Ignorable space:} $\square$
266 % do_ignorable_space:
269 \paragraph{Space:} $s$
272 \item{\verb+cursor+}\\
273 create \SNODE{} node, replace cursor with the \SNODE{} node, append
274 $\tadvance$ after \SNODE{} node
278 % create s node, replace cursor with s, append \advance after s
280 \paragraph{Identifier:} $i(v)$
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
289 % create i node, replace cursor with i, append \advance after i
291 \paragraph{Number:} $n(v)$
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
300 % create n node, replace cursor with n, append \advance after n
302 \paragraph{Apostrophe:} $o({}')$
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+}\\
318 \item{\verb+cursor+}\\
319 cursor is not in a group, error?
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
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
333 % cursor is not in a group, error?
335 \paragraph{Other:} $o(v)$
337 create an \ONODE{}, set \verb+value=+$v$ in the \ONODE{}, replace
338 cursor with \ONODE{}, append $\tadvance$ after the \ONODE{} node
341 % create o node, replace cursor with o, append \advance after o
343 \paragraph{Active:} $\sim$
348 \paragraph{Comment:} $\%$
353 \paragraph{Begin Environment:} $c(\mathtt{begin})\langle\alpha_1,\dots,\alpha_n\rangle$
355 \paragraph{End Environment:} $c(\mathtt{end})\langle\rangle$
357 \paragraph{Left Delimiter:} $c(\mathtt{left})\langle\alpha\rangle$
359 \paragraph{Right Delimiter:} $c(\mathtt{right})\langle\alpha\rangle$
361 \paragraph{Carriage-Return:} $c(\mathtt{cr})\langle\rangle$
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+}\\
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
381 \paragraph{Macro:} $c(v)\langle\alpha_1,\dots,\alpha_n\rangle$
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
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)
400 % create a c node with children corresponding to the pattern of the macro
401 % append \nextparam as first child of the macro
403 \section{Left Drop Rules}
405 \paragraph{Normal Left Drop:} $\NLDROP$
409 %********* rules that try to express situations completely specified (there is an effective deletion) ******
411 % 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.
412 % an empty c node is either an undefined macro or an empty macro. These c node are handled as they actually were
413 % tokens (i, n, o, s).
415 % there is an optional sequence of groups with id, all of which having one and only one child. The last
416 % child of this sequence (or the root, if the sequence is empty) is a group with id, has as first element a
417 % token and has as second and last element an eventually empty sequence of groups with id, all of which having
418 %one and only one child. The last element of this sequence has the cursor as its child.
419 \item{\verb+(g[@id][^*$]/++\verb+)?g[@id][^(i|n|o|s|c[ ])#$]/(g[@id][^*$]/++\verb+)?cursor+}\\
420 replace the whole fragment with the cursor.
422 %*******************************************************************************************************
423 %************** rules handling the case in which the cursor has a preceding node ***********************
424 %*******************************************************************************************************
426 %************************* the cursor's parent is a group or a parameter *******************************
428 %we consider an empty macro as a token. An empty macro is either undefined or simply empty.
430 %rule handling the case where the cursor has a preceding token and this is the first node of a group with id
431 \item{\verb+g[@id][^(i||n||o||s||c[^$])#]/cursor+}\\
432 remove the cursor and replace the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node with the $\NLDROP$.
433 \item{\verb+<g|p>[(i||n||o||s||c[^$])#]/cursor+}\\
434 remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
435 %it corresponds to the drop_prev_group(false).
436 \item{\verb+<g|p>[g#]/cursor+}\\
437 remove the cursor and append the $\NLDROP$ to the \G{} node.
438 %corresponds to the drop_prev_script(false).
439 \item{\verb+<g|p>[(<sp|sb>)#]/cursor+}\\
440 remove the cursor and append the $\NLDROP$ to the \SP{} or \SB{} node.
441 %rules handling the right open macros preceding the cursor.
442 \item{\verb+<g|p>[(c[^p[@right-open='1']$])#]/cursor+}\\
443 remove the cursor and append the $\NLDROP$ to the \PNODE{} node.
444 %we don't have a macro of this kind, but we don't know the future...
445 \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/cursor+}\\
446 remove the cursor and replace the \CNODE node with the $\NLDROP$.
447 \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1']$])#]/cursor+}\\
448 replace the \CNODE{} node with the content of the \PNODE node and replace the cursor with the $\NLDROP$.
449 %rules handling macro with parameter(s) and preceding the cursor.
450 \item{\verb+<g|p>[c#]/cursor+}\\
451 remove the cursor and append the $\NLDROP$ to the \CNODE{} node.
452 %rule handling table with rows preceding the cursor.
453 \item{\verb+<g|p>[(table[row[cell[^g$]$]$])#]/cursor+}\\
454 remove the cursor and append the $\NLDROP$ to the \G{} node, which is child of the \CELL{} node.
455 %rule handling tables without rows preceding the cursor.
456 \item{\verb+<g|p>[table#]/cursor+}\\
457 remove the cursor and append the $\NLDROP$ to the \TABLE{} node
459 %********************************* the cursor's parent is a script ******************************
461 %rule handling the case where the script's base is an empty group with id.
462 \item{\verb+<sp|sb>[^(g[@id][^$])#$]/cursor+}\\
463 replace the \SP{} or \SB{} node with the $\NLDROP$.
464 %rule handling the case where the script's base is an empty group without id
465 \item{\verb+<sp|sb>[^(g[^$])#$]/cursor+}\\
466 replace the \SP{} or \SB{} node with the cursor.
467 %rule handling the case where the script's base is something else
468 \item{\verb+<sp|sb>[^*#$]/cursor+}\\
469 replace the \SP{} or \SB{} node with it's first child and insert the $\NLDROP$ after it.
471 %********************************* the cursor's parent is a macro ********************************
473 %rule handling the case where the preceding node is a parameter
474 \item{\verb+c[p#]/cursor+}\\
475 remove the cursor and append the $\NLDROP$ to the PNODE{} node.
476 %rule handling the case where the preceding node is a delimiter
477 \item{\verb+c[(<i|n|o|s|c>)#]/cursor+}\\
478 remove the cursor and insert the $\NLDROP$ before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
480 %*************************************************************************************************
481 %*********** rules handling the case in which the cursor has no preceding nodes ******************
482 %*************************************************************************************************
484 %rule handling the case where the cursor has something else after it
485 \item{\verb+<g|p>[#*]/cursor+}\\
488 %rules handling the case where the cursor's parent is a p node and the cursor has no nodes after it.
490 %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.
491 \item{\verb+c[^(p[@left-open='1'][^$])#$]/p[@right-open='1'][^#$]/cursor+}\\
492 replace the \CNODE{} with the $\NLDROP$.
493 %rule handling the case where the p node is a left and right open macro's child and the first p node has elements.
494 \item{\verb+c[^(p[@left-open='1']#$]/p[@right-open='1'][^#$]/cursor+}\\
495 replace the \CNODE{} with the content of the PNODE{} with attribute texttt{left-open='1'} and insert $\NLDROP$ after this.
496 %rule handling the case where the p node is right open macro's child.
497 \item{\verb+c[^#$]/p[@right-open='1'][^#$]/cursor+}\\
498 replace the \CNODE{} with the $\NLDROP$.
499 %rule handling the case where the p node is a macro's child and this macro has parameter.
500 \item{\verb+c/p[^#$]/cursor+}\\
501 remove the cursor and insert the $\NLDROP$ before the \PNODE{} node.
503 %rule handling the case where the cursor has no nodes after it and its parent is a group with id
504 \item{\verb+g[@id][^#$]/cursor+}\\
505 replace the \G{} node with the $\NLDROP$.
509 \paragraph{Special Left Drop:} $\SLDROP$
513 %*******************************************************************************************************
514 %************** rules handling the case in which the cursor has a preceding node ***********************
515 %*******************************************************************************************************
517 %************************* the cursor's parent is a group or a parameter *******************************
519 %this rule is more specific than the one below which handle the case of the cursor preceded by a c node
520 \item{\verb+<g|p>[(i||n||o||s||c[^$])#]/cursor+}\\
521 remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
522 %it corresponds to the drop_prev_group(true).
523 \item{\verb+<g|p>[g#]/cursor+}\\
524 remove the cursor and append the it to the \G{} node.
525 %corresponds to the drop_prev_script(true).
526 \item{\verb+<g|p>[(<sp|sb>)#]/cursor+}\\
527 remove the cursor and append the $\SLDROP$ to the \SP{} or \SB{} node.
528 %rules handling the right open macros preceding the cursor.
529 \item{\verb+<g|p>[(c[^p[@right-open='1']$])#]/cursor+}\\
530 remove the cursor and append the $\SLDROP$ to the \PNODE{} node.
531 %we don't have a macro of this kind, but we don't know the future...
532 \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/cursor+}\\
533 remove the cursor and replace the \CNODE node with the cursor.
534 \item{\verb+<g|p>[(c[^p[!(@right-open='1')][@left-open='1']$])#]/cursor+}\\
535 replace the \CNODE{} node with the content of the \PNODE node.
536 %rule handling macro with parameter(s) and preceding the cursor.
537 \item{\verb+<g|p>[c#]/cursor+}\\
538 remove the cursor and append the $\SLDROP$ to the \CNODE{} node.
539 %rule handling table with rows preceding the cursor.
540 \item{\verb+<g|p>[(table[row[cell[^g$]$]$])#]/cursor+}\\
541 remove the cursor and append the it to the \G{} node, which is child of the \CELL{} node.
542 %rule handling tables without rows preceding the cursor.
543 \item{\verb+<g|p>[table#]/cursor+}\\
544 remove the cursor and append the $\SLDROP$ to the \TABLE{} node
546 %********************************* the cursor's parent is a script ******************************
548 %rule handling the case where the script's base is an empty group with id.
549 \item{\verb+<sp|sb>[^(g[@id][^$])#$]/cursor+}\\
550 replace the \SP{} or \SB{} node with the \G{} node and insert the cursor after it.
551 %rule handling the case where the script's base is an empty group without id
552 \item{\verb+<sp|sb>[^(g[^$])#$]/cursor+}\\
553 replace the \SP{} or \SB{} node with the cursor.
554 %rule handling the case where the scrip's base is something else
555 \item{\verb+<sp|sb>[^*#$]/cursor+}\\
556 replace the \SP{} or \SB{} node with it's first child and insert the cursor after it.
558 %********************************* the cursor's parent is a macro ********************************
560 %rule handling the case where the preceding node is a parameter
561 \item{\verb+c[p#]/cursor+}\\
562 remove the cursor and append the $\SLDROP$ to the PNODE{} node.
563 %rule handling the case where the preceding node is a delimiter
564 \item{\verb+c[(<i|n|o|s|c>)#]/cursor+}\\
565 remove the cursor and insert the it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
567 %*************************************************************************************************
568 %*********** rules handling the case in which the cursor has no preceding nodes ******************
569 %*************************************************************************************************
571 %rule handling the case where the cursor has something else after it
572 \item{\verb+<g|p>[#*]/cursor+}\\
575 %rules handling the case where the cursor's parent is a p node and the cursor has no nodes after it.
577 %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.
578 \item{\verb+c[^(p[@left-open='1'][^$])#$]/p[@right-open='1'][^#$]/cursor+}\\
579 replace the \CNODE{} with the cursor.
580 %rule handling the case where the p node is a left and right open macro's child and the first p node has elements.
581 \item{\verb+c[^(p[@left-open='1']#$]/p[@right-open='1'][^#$]/cursor+}\\
582 replace the \CNODE{} with the content of the PNODE{} with attribute texttt{left-open='1'} and insert cursor after this.
583 %rule handling the case where the p node is right open macro's child.
584 \item{\verb+c[^#$]/p[@right-open='1'][^#$]/cursor+}\\
585 replace the \CNODE{} with the cursor.
586 %rule handling the case where the p node is a macro's child and this macro has parameter.
587 \item{\verb+c/p[^#$]/cursor+}\\
588 remove the cursor and insert the $\SLDROP$ before the \PNODE{} node.
590 %rule handling the case where the cursor has no nodes after it and its parent is a group with id
591 \item{\verb+g[@id][^#$]/cursor+}\\
592 replace the \G{} node with the cursor.
596 \section{Right Drop Rules}
598 \section{$\varepsilon$-rules}
600 \paragraph{Nromal Left Drop}
605 %********************************************* \NLDROP has a preceding node *********************************************
607 %rule handling the case where the preceding node is a token or an empty macro.
608 \item{\verb+*[(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
609 remove the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or the \CNODE{} node.
610 %rule handling the case where the preceding node is a group
611 \item{\verb+*[g#]/+$\NLDROP$}\\
612 remove the $\NLDROP$ append it to the \G{} node.
613 %rule handling the case where the preceding node is a script
614 \item{\verb+*[<sp|sb>#]/+$\NLDROP$}\\
615 remove the $\NLDROP$ append it to the \SP{} or \SB{} node.
616 %rule handling the case where the preceding node is an open-right macro
617 \item{\verb+*[(c[^p[@right-open='1']$])#]/+$\NLDROP$}\\
618 remove the $\NLDROP$ and append it to the \PNODE{} node.
619 %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
620 \item{\verb+*[(c[^p[!(@right-open='1')][@left-open='1'][^$]$])#]/+$\NLDROP$}\\
621 remove the \CNODE node.
622 %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
623 \item{\verb+*[(c[^p[!(@right-open='1')][@left-open='1']$])#]/+$\NLDROP$}\\
624 replace the \CNODE{} node with the content of the \PNODE{} node.
625 %rule handling the case where the preceding node is a macro with parameter(s)
626 \item{\verb+*[c#]/+$\NLDROP$}\\
627 remove the $\NLDROP$ and append it to the \CNODE{} node.
629 %rule handling the deletion of primes in superscript
631 %there are more than one prime in the phantom group
632 \item{\verb+sp[!(@id)][*#$]/g[!(@id)][o#]/+$\NLDROP$}\\
633 remove the \ONODE node, remove the $\NLDROP$ and insert the cursor after the \SP{} node.
634 %there is one and only one prime in the phantom group
635 \item{\verb+sp[!(@id)][*#$]/g[!(@id)][^o#]/+$\NLDROP$}\\
636 replace the \SP{} node with it's first child and insert the cursor after it
638 %*** rules handling the case where the \NLDROP's parent is a macro (with parameter) ***
640 %the node preceding the \NLDROP is a delimiter
641 \item{\verb+c[(<i|n|o|s|c>)#]/+$\NLDROP$}\\
642 remove the $\NLDROP$ and insert it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
643 %the node preceding the \NLDROP is parameter
644 \item{\verb+c[p#]/+$\NLDROP$}\\
645 remove the $\NLDROP$ and append it to the \PNODE{} node.
647 %********************************************* the \NLDROP has no preceding nodes ****************************************************
649 %if the \NLDROP has no preceding nodes, but has following nodes...
650 \item{\verb+<g|p>[#*]/+$\NLDROP$}\\
651 replace the $\NLDROP$ with the cursor.
652 %rule handling the case where the $\NLDROP$ is the only child of a group with id.
653 \item{\verb+g[@id][^#$]/+$\NLDROP$}\\
654 replace the \G{} node with the $\NLDROP$.
655 %\NLDROP is the first child of a macro with no inserted parameter
656 \item{\verb+c[!(p[*])][^#]/+$\NLDROP$}\\
657 replace the \CNODE{} with the $\NLDROP$.
658 %\NLDROP is the first child of a macro with some inserted parameter
659 \item{\verb+c[p[*]][^#]/+$\NLDROP$}\\
660 put the cursor in the first \PNODE{} node.
663 %**** rule handling the case where the \NLDROP has a preceding token or a preceding empty macro, which is either undefined or empty ****
665 %%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
666 %\item{\verb+*[(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
667 %replace the \INODE{}, \NNODE{}, \SNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node with the cursor and remove the $\NLDROP$.
668 %%the \NLDROP's parent is a macro with argument
669 %\item{\verb+c[((!(p[@left-open='1']))&(!(p[@right-open+'1'])))][(i||n||o||s||c[^$])#]/+$\NLDROP$}\\
670 %remove the $\NLDROP$ and insert it before the \INODE{}, \NNODE{}, \ONODE{}, \SNODE{} or \CNODE{} node.
671 %%rule handling the case where the \NLDROP's parent is a phantom group, which in turn is a sp's child
672 %\item{\verb+sp[!(@id)][^*#$]/g[!(@id)][o#$]/+$\NLDROP$}\\
673 %remove the \ONODE{} node
675 %********************************* rules handling the case where the \NLDROP has a preceding group **************************************
676 \item{\verb+*[g#]/+$\NLDROP$}\\
677 remove the $\NLDROP$ and append it to the \G{} node.
681 \paragraph{Special Left Drop}
685 \item{special left}\\
692 \item{\verb+g/+$\tadvance$}\\
693 replace $\tadvance$ with the cursor
695 \item{\verb+p[#$]/+$\tadvance$}\\ %$
696 put $\tadvance$ after the \PNODE{} node
698 \item{\verb+c[#p]/+$\tadvance$} \\
699 remove $\tadvance$, put the cursor as first child of the \PNODE{} node
701 \item{\verb+c[#*]/+$\tadvance$} \\ %$
702 replace $\tadvance$ with the cursor
704 \item{\verb+c[#$]/+$\tadvance$} \\ %$
705 move $\tadvance$ after the \CNODE{} node
708 \paragraph{Next Parameter}
710 \paragraph{Next Token}
712 %% \begin{description}
713 %% \item{\verb+c[#p]/+$\tnext$} \\
716 % g[@id]/(c[#$][@right-open]/g[!@id][#$]/)+cursor } let p = cursor.parent() in remove; advance(p)
720 % */cursor { let g = new group in replace
722 % g[@id][^#$]/cursor <= cursor.parent().replace(cursor)
723 % g[@id][^#$]/cursor <- cursor
724 % (!g[@id][^#$])[A#B]/(g[@id][^#$]/)+cursor <- (!g[@id][^#$])[A#B]/cursor