2
* itex2MML.y last modified 12/24/2006
12
#define YYSTYPE char *
13
#define YYPARSE_PARAM_TYPE char **
14
#define YYPARSE_PARAM ret_str
16
#define yytext itex2MML_yytext
22
static void itex2MML_default_error (const char * msg)
25
fprintf(stderr, "Line: %d Error: %s\n", itex2MML_lineno, msg);
28
void (*itex2MML_error) (const char * msg) = itex2MML_default_error;
30
static void yyerror (char * s)
32
char * msg = itex2MML_copy3 (s, " at token ", yytext);
34
(*itex2MML_error) (msg);
35
itex2MML_free_string (msg);
38
/* Note: If length is 0, then buffer is treated like a string; otherwise only length bytes are written.
40
static void itex2MML_default_write (const char * buffer, unsigned long length)
45
fwrite (buffer, 1, length, stdout);
47
fputs (buffer, stdout);
51
static void itex2MML_default_write_mathml (const char * mathml)
54
(*itex2MML_write) (mathml, 0);
57
#ifdef itex2MML_CAPTURE
58
static char * itex2MML_output_string = "" ;
60
const char * itex2MML_output ()
62
char * copy = (char *) malloc(strlen(itex2MML_output_string) +1);
65
if (itex2MML_output_string)
67
strcpy(copy, itex2MML_output_string);
68
if (itex2MML_output_string != "")
69
free(itex2MML_output_string);
74
itex2MML_output_string = "";
78
static void itex2MML_capture (const char * buffer, unsigned long length)
84
unsigned long first_length = itex2MML_output_string ? strlen(itex2MML_output_string) : 0;
85
char * copy = (char *) malloc(first_length + length + 1);
88
if (itex2MML_output_string)
90
strcpy(copy, itex2MML_output_string);
91
if (itex2MML_output_string != "")
92
free(itex2MML_output_string);
96
strncat(copy, buffer, length);
98
itex2MML_output_string = copy;
102
char * copy = itex2MML_copy2(itex2MML_output_string, buffer);
103
if (itex2MML_output_string != "")
104
free(itex2MML_output_string);
105
itex2MML_output_string = copy;
110
static void itex2MML_capture_mathml (const char * buffer)
112
char * temp = itex2MML_copy2(itex2MML_output_string, buffer);
113
if (itex2MML_output_string != "")
114
free(itex2MML_output_string);
115
itex2MML_output_string = temp;
117
void (*itex2MML_write) (const char * buffer, unsigned long length) = itex2MML_capture;
118
void (*itex2MML_write_mathml) (const char * mathml) = itex2MML_capture_mathml;
120
void (*itex2MML_write) (const char * buffer, unsigned long length) = itex2MML_default_write;
121
void (*itex2MML_write_mathml) (const char * mathml) = itex2MML_default_write_mathml;
124
char * itex2MML_empty_string = "";
126
/* Create a copy of a string, adding space for extra chars
128
char * itex2MML_copy_string_extra (const char * str, unsigned extra)
130
char * copy = (char *) malloc(extra + (str ? strlen (str) : 0) + 1);
138
return copy ? copy : itex2MML_empty_string;
141
/* Create a copy of a string, appending two strings
143
char * itex2MML_copy3 (const char * first, const char * second, const char * third)
145
int first_length = first ? strlen( first) : 0;
146
int second_length = second ? strlen(second) : 0;
147
int third_length = third ? strlen( third) : 0;
149
char * copy = (char *) malloc(first_length + second_length + third_length + 1);
158
if (second) strcat(copy, second);
159
if ( third) strcat(copy, third);
161
return copy ? copy : itex2MML_empty_string;
164
/* Create a copy of a string, appending a second string
166
char * itex2MML_copy2 (const char * first, const char * second)
168
return itex2MML_copy3(first, second, 0);
171
/* Create a copy of a string
173
char * itex2MML_copy_string (const char * str)
175
return itex2MML_copy3(str, 0, 0);
178
/* Create a copy of a string, escaping unsafe characters for XML
180
char * itex2MML_copy_escaped (const char * str)
182
unsigned long length = 0;
184
const char * ptr1 = str;
189
if ( str == 0) return itex2MML_empty_string;
190
if (*str == 0) return itex2MML_empty_string;
200
case '&': /* & */
203
case '\'': /* ' */
204
case '"': /* " */
205
case '-': /* - */
215
copy = (char *) malloc (length + 1);
227
strcpy (ptr2, "<");
231
strcpy (ptr2, ">");
234
case '&': /* & */
235
strcpy (ptr2, "&");
238
case '\'': /* ' */
239
strcpy (ptr2, "'");
242
case '"': /* " */
243
strcpy (ptr2, """);
246
case '-': /* - */
247
strcpy (ptr2, "-");
258
return copy ? copy : itex2MML_empty_string;
261
void itex2MML_free_string (char * str)
263
if (str && str != itex2MML_empty_string)
270
%token CHAR STARTMATH STARTDMATH ENDMATH MI MIB MN MO SUP SUB MROWOPEN MROWCLOSE LEFT RIGHT BIG BBIG BIGG BBIGG BIGL BBIGL BIGGL BBIGGL FRAC TFRAC MATHOP MOP MOL MOF PERIODDELIM OTHERDELIM LEFTDELIM RIGHTDELIM MOS MOB SQRT ROOT BINOM UNDER OVER OVERBRACE UNDERBRACE UNDEROVER TENSOR MULTI ARRAY COLSEP ROWSEP ARRAYOPTS COLLAYOUT COLALIGN ROWALIGN ALIGN EQROWS EQCOLS ROWLINES COLLINES FRAME PADDING ATTRLIST ITALICS BOLD RM BB ST END BBLOWERCHAR BBUPPERCHAR CALCHAR FRAKCHAR CAL FRAK ROWOPTS TEXTSIZE SCSIZE SCSCSIZE DISPLAY TEXTSTY TEXTBOX TEXTSTRING CELLOPTS ROWSPAN COLSPAN THINSPACE MEDSPACE THICKSPACE QUAD QQUAD NEGSPACE PHANTOM HREF UNKNOWNCHAR EMPTYMROW STATLINE TOGGLE FGHIGHLIGHT BGHIGHLIGHT SPACE INTONE INTTWO INTTHREE BAR WIDEBAR VEC WIDEVEC HAT WIDEHAT CHECK WIDECHECK TILDE WIDETILDE DOT DDOT UNARYMINUS UNARYPLUS BEGINENV ENDENV MATRIX PMATRIX BMATRIX BBMATRIX VMATRIX VVMATRIX SMALLMATRIX CASES ALIGNED SUBSTACK PMOD RMCHAR COLOR BGCOLOR
274
doc: xmlmmlTermList {/* all processing done in body*/};
277
{/* nothing - do nothing*/}
278
| char {/* proc done in body*/}
279
| expression {/* all proc. in body*/}
280
| xmlmmlTermList char {/* all proc. in body*/}
281
| xmlmmlTermList expression {/* all proc. in body*/};
283
char: CHAR {printf("%s", $1);};
285
expression: STARTMATH ENDMATH {/* empty math group - ignore*/}
286
| STARTDMATH ENDMATH {/* ditto */}
287
| STARTMATH compoundTermList ENDMATH {
288
char ** r = (char **) ret_str;
289
char * s = itex2MML_copy3("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'>", $2, "</math>");
290
itex2MML_free_string($2);
292
(*r) = (s == itex2MML_empty_string) ? 0 : s;
295
if (itex2MML_write_mathml)
296
(*itex2MML_write_mathml) (s);
297
itex2MML_free_string(s);
300
| STARTDMATH compoundTermList ENDMATH {
301
char ** r = (char **) ret_str;
302
char * s = itex2MML_copy3("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>", $2, "</math>");
303
itex2MML_free_string($2);
305
(*r) = (s == itex2MML_empty_string) ? 0 : s;
308
if (itex2MML_write_mathml)
309
(*itex2MML_write_mathml) (s);
310
itex2MML_free_string(s);
314
compoundTermList: compoundTerm {
315
$$ = itex2MML_copy_string($1);
316
itex2MML_free_string($1);
318
| compoundTermList compoundTerm {
319
$$ = itex2MML_copy2($1, $2);
320
itex2MML_free_string($1);
321
itex2MML_free_string($2);
324
compoundTerm: mob SUB closedTerm SUP closedTerm {
325
if (itex2MML_displaymode == 1) {
326
char * s1 = itex2MML_copy3("<munderover>", $1, " ");
327
char * s2 = itex2MML_copy3($3, " ", $5);
328
$$ = itex2MML_copy3(s1, s2, "</munderover>");
329
itex2MML_free_string(s1);
330
itex2MML_free_string(s2);
333
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
334
char * s2 = itex2MML_copy3($3, " ", $5);
335
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
336
itex2MML_free_string(s1);
337
itex2MML_free_string(s2);
339
itex2MML_free_string($1);
340
itex2MML_free_string($3);
341
itex2MML_free_string($5);
343
| mob SUB closedTerm {
344
if (itex2MML_displaymode == 1) {
345
char * s1 = itex2MML_copy3("<munder>", $1, " ");
346
$$ = itex2MML_copy3(s1, $3, "</munder>");
347
itex2MML_free_string(s1);
350
char * s1 = itex2MML_copy3("<msub>", $1, " ");
351
$$ = itex2MML_copy3(s1, $3, "</msub>");
352
itex2MML_free_string(s1);
354
itex2MML_free_string($1);
355
itex2MML_free_string($3);
357
| mob SUP closedTerm SUB closedTerm {
358
if (itex2MML_displaymode == 1) {
359
char * s1 = itex2MML_copy3("<munderover>", $1, " ");
360
char * s2 = itex2MML_copy3($5, " ", $3);
361
$$ = itex2MML_copy3(s1, s2, "</munderover>");
362
itex2MML_free_string(s1);
363
itex2MML_free_string(s2);
366
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
367
char * s2 = itex2MML_copy3($5, " ", $3);
368
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
369
itex2MML_free_string(s1);
370
itex2MML_free_string(s2);
372
itex2MML_free_string($1);
373
itex2MML_free_string($3);
374
itex2MML_free_string($5);
376
| mob SUP closedTerm {
377
if (itex2MML_displaymode == 1) {
378
char * s1 = itex2MML_copy3("<mover>", $1, " ");
379
$$ = itex2MML_copy3(s1, $3, "</mover>");
380
itex2MML_free_string(s1);
383
char * s1 = itex2MML_copy3("<msup>", $1, " ");
384
$$ = itex2MML_copy3(s1, $3, "</msup>");
385
itex2MML_free_string(s1);
387
itex2MML_free_string($1);
388
itex2MML_free_string($3);
390
|mib SUB closedTerm SUP closedTerm {
391
if (itex2MML_displaymode == 1) {
392
char * s1 = itex2MML_copy3("<munderover>", $1, " ");
393
char * s2 = itex2MML_copy3($3, " ", $5);
394
$$ = itex2MML_copy3(s1, s2, "</munderover>");
395
itex2MML_free_string(s1);
396
itex2MML_free_string(s2);
399
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
400
char * s2 = itex2MML_copy3($3, " ", $5);
401
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
402
itex2MML_free_string(s1);
403
itex2MML_free_string(s2);
405
itex2MML_free_string($1);
406
itex2MML_free_string($3);
407
itex2MML_free_string($5);
409
| mib SUB closedTerm {
410
if (itex2MML_displaymode == 1) {
411
char * s1 = itex2MML_copy3("<munder>", $1, " ");
412
$$ = itex2MML_copy3(s1, $3, "</munder>");
413
itex2MML_free_string(s1);
416
char * s1 = itex2MML_copy3("<msub>", $1, " ");
417
$$ = itex2MML_copy3(s1, $3, "</msub>");
418
itex2MML_free_string(s1);
420
itex2MML_free_string($1);
421
itex2MML_free_string($3);
423
| mib SUP closedTerm SUB closedTerm {
424
if (itex2MML_displaymode == 1) {
425
char * s1 = itex2MML_copy3("<munderover>", $1, " ");
426
char * s2 = itex2MML_copy3($5, " ", $3);
427
$$ = itex2MML_copy3(s1, s2, "</munderover>");
428
itex2MML_free_string(s1);
429
itex2MML_free_string(s2);
432
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
433
char * s2 = itex2MML_copy3($5, " ", $3);
434
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
435
itex2MML_free_string(s1);
436
itex2MML_free_string(s2);
438
itex2MML_free_string($1);
439
itex2MML_free_string($3);
440
itex2MML_free_string($5);
442
| mib SUP closedTerm {
443
if (itex2MML_displaymode == 1) {
444
char * s1 = itex2MML_copy3("<mover>", $1, " ");
445
$$ = itex2MML_copy3(s1, $3, "</mover>");
446
itex2MML_free_string(s1);
449
char * s1 = itex2MML_copy3("<msup>", $1, " ");
450
$$ = itex2MML_copy3(s1, $3, "</msup>");
451
itex2MML_free_string(s1);
453
itex2MML_free_string($1);
454
itex2MML_free_string($3);
456
| closedTerm SUB closedTerm SUP closedTerm {
457
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
458
char * s2 = itex2MML_copy3($3, " ", $5);
459
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
460
itex2MML_free_string(s1);
461
itex2MML_free_string(s2);
462
itex2MML_free_string($1);
463
itex2MML_free_string($3);
464
itex2MML_free_string($5);
466
| closedTerm SUP closedTerm SUB closedTerm {
467
char * s1 = itex2MML_copy3("<msubsup>", $1, " ");
468
char * s2 = itex2MML_copy3($5, " ", $3);
469
$$ = itex2MML_copy3(s1, s2, "</msubsup>");
470
itex2MML_free_string(s1);
471
itex2MML_free_string(s2);
472
itex2MML_free_string($1);
473
itex2MML_free_string($3);
474
itex2MML_free_string($5);
476
| closedTerm SUB closedTerm {
477
char * s1 = itex2MML_copy3("<msub>", $1, " ");
478
$$ = itex2MML_copy3(s1, $3, "</msub>");
479
itex2MML_free_string(s1);
480
itex2MML_free_string($1);
481
itex2MML_free_string($3);
483
| closedTerm SUP closedTerm {
484
char * s1 = itex2MML_copy3("<msup>", $1, " ");
485
$$ = itex2MML_copy3(s1, $3, "</msup>");
486
itex2MML_free_string(s1);
487
itex2MML_free_string($1);
488
itex2MML_free_string($3);
491
$$ = itex2MML_copy3("<msub><mo></mo>", $2, "</msub>");
492
itex2MML_free_string($2);
495
$$ = itex2MML_copy3("<msup><mo></mo>", $2, "</msup>");
496
itex2MML_free_string($2);
499
$$ = itex2MML_copy_string($1);
500
itex2MML_free_string($1);
508
$$ = itex2MML_copy3("<mi>", $1, "</mi>");
509
itex2MML_free_string($1);
512
$$ = itex2MML_copy3("<mn>", $1, "</mn>");
513
itex2MML_free_string($1);
563
| MROWOPEN closedTerm MROWCLOSE {
564
$$ = itex2MML_copy_string($2);
565
itex2MML_free_string($2);
567
| MROWOPEN compoundTermList MROWCLOSE {
568
$$ = itex2MML_copy3("<mrow>", $2, "</mrow>");
569
itex2MML_free_string($2);
571
| left compoundTermList right {
572
char * s1 = itex2MML_copy3("<mrow>", $1, $2);
573
$$ = itex2MML_copy3(s1, $3, "</mrow>");
574
itex2MML_free_string(s1);
575
itex2MML_free_string($1);
576
itex2MML_free_string($2);
577
itex2MML_free_string($3);
584
left: LEFT LEFTDELIM {
585
itex2MML_rowposn = 2;
586
$$ = itex2MML_copy3("<mo>", $2, "</mo>");
587
itex2MML_free_string($2);
590
itex2MML_rowposn = 2;
591
$$ = itex2MML_copy3("<mo>", $2, "</mo>");
592
itex2MML_free_string($2);
595
itex2MML_rowposn = 2;
596
$$ = itex2MML_copy_string("");
597
itex2MML_free_string($2);
600
right: RIGHT RIGHTDELIM {
601
$$ = itex2MML_copy3("<mo>", $2, "</mo>");
602
itex2MML_free_string($2);
605
$$ = itex2MML_copy3("<mo>", $2, "</mo>");
606
itex2MML_free_string($2);
608
| RIGHT PERIODDELIM {
609
$$ = itex2MML_copy_string("");
610
itex2MML_free_string($2);
613
bigdelim: BIG LEFTDELIM {
614
itex2MML_rowposn = 2;
615
$$ = itex2MML_copy3("<mo maxsize=\"1.2em\" minsize=\"1.2em\">", $2, "</mo>");
616
itex2MML_free_string($2);
619
$$ = itex2MML_copy3("<mo maxsize=\"1.2em\" minsize=\"1.2em\">", $2, "</mo>");
620
itex2MML_free_string($2);
623
$$ = itex2MML_copy3("<mo maxsize=\"1.2em\" minsize=\"1.2em\">", $2, "</mo>");
624
itex2MML_free_string($2);
627
itex2MML_rowposn = 2;
628
$$ = itex2MML_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
629
itex2MML_free_string($2);
632
$$ = itex2MML_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
633
itex2MML_free_string($2);
636
$$ = itex2MML_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
637
itex2MML_free_string($2);
640
itex2MML_rowposn = 2;
641
$$ = itex2MML_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
642
itex2MML_free_string($2);
645
$$ = itex2MML_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
646
itex2MML_free_string($2);
649
$$ = itex2MML_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
650
itex2MML_free_string($2);
653
itex2MML_rowposn = 2;
654
$$ = itex2MML_copy3("<mo maxsize=\"3em\" minsize=\"3em\">", $2, "</mo>");
655
itex2MML_free_string($2);
658
$$ = itex2MML_copy3("<mo maxsize=\"3em\" minsize=\"3em\">", $2, "</mo>");
659
itex2MML_free_string($2);
662
$$ = itex2MML_copy3("<mo maxsize=\"3em\" minsize=\"3em\">", $2, "</mo>");
663
itex2MML_free_string($2);
666
itex2MML_rowposn = 2;
667
$$ = itex2MML_copy3("<mo maxsize=\"1.2em\" minsize=\"1.2em\">", $2, "</mo>");
668
itex2MML_free_string($2);
671
itex2MML_rowposn = 2;
672
$$ = itex2MML_copy3("<mo maxsize=\"1.2em\" minsize=\"1.2em\">", $2, "</mo>");
673
itex2MML_free_string($2);
676
itex2MML_rowposn = 2;
677
$$ = itex2MML_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
678
itex2MML_free_string($2);
681
itex2MML_rowposn = 2;
682
$$ = itex2MML_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
683
itex2MML_free_string($2);
686
itex2MML_rowposn = 2;
687
$$ = itex2MML_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
688
itex2MML_free_string($2);
691
itex2MML_rowposn = 2;
692
$$ = itex2MML_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
693
itex2MML_free_string($2);
696
itex2MML_rowposn = 2;
697
$$ = itex2MML_copy3("<mo maxsize=\"3em\" minsize=\"3em\">", $2, "</mo>");
698
itex2MML_free_string($2);
700
| BBIGGL OTHERDELIM {
701
itex2MML_rowposn = 2;
702
$$ = itex2MML_copy3("<mo maxsize=\"3em\" minsize=\"3em\">", $2, "</mo>");
703
itex2MML_free_string($2);
706
unrecognized: UNKNOWNCHAR {
707
$$ = itex2MML_copy_string("<merror><mtext>Unknown character</mtext></merror>");
710
unaryminus: UNARYMINUS {
711
$$ = itex2MML_copy_string("<mo lspace=\"verythinmathspace\" rspace=\"0em\">−</mo>");
714
unaryplus: UNARYPLUS {
715
$$ = itex2MML_copy_string("<mo lspace=\"verythinmathspace\" rspace=\"0em\">+</mo>");
722
$$ = itex2MML_copy3("<mi>", $1, "</mi>");
723
itex2MML_free_string($1);
729
itex2MML_rowposn = 2;
730
$$ = itex2MML_copy3("<mo lspace=\"thinmathspace\" rspace=\"thinmathspace\">", $1, "</mo>");
731
itex2MML_free_string($1);
737
itex2MML_rowposn = 2;
738
$$ = itex2MML_copy3("<mo>", $1, "</mo>");
739
itex2MML_free_string($1);
742
itex2MML_rowposn = 2;
743
$$ = itex2MML_copy3("<mo>", $1, "</mo>");
744
itex2MML_free_string($1);
747
$$ = itex2MML_copy3("<mo stretchy=\"false\">", $1, "</mo>");
748
itex2MML_free_string($1);
751
itex2MML_rowposn = 2;
752
$$ = itex2MML_copy3("<mo stretchy=\"false\">", $1, "</mo>");
753
itex2MML_free_string($1);
756
$$ = itex2MML_copy3("<mo stretchy=\"false\">", $1, "</mo>");
757
itex2MML_free_string($1);
760
$$ = itex2MML_copy3("<mo stretchy=\"false\">", $1, "</mo>");
761
itex2MML_free_string($1);
764
$$ = itex2MML_copy3("<mo>", $1, "</mo>");
765
itex2MML_free_string($1);
769
$$ = itex2MML_copy3("<mo lspace=\"mediummathspace\" rspace=\"mediummathspace\">", $1, "</mo>");
770
itex2MML_free_string($1);
773
itex2MML_rowposn = 2;
774
$$ = itex2MML_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $1, "</mo>");
775
itex2MML_free_string($1);
777
| MATHOP TEXTSTRING {
778
itex2MML_rowposn = 2;
779
$$ = itex2MML_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $2, "</mo>");
780
itex2MML_free_string($2);
783
emptymrow: EMPTYMROW {
784
$$ = itex2MML_copy_string("<mrow></mrow>");
787
space: SPACE ST INTONE END ST INTTWO END ST INTTHREE END {
788
char * s1 = itex2MML_copy3("<mspace height=\"", $3, "ex\" depth=\"");
789
char * s2 = itex2MML_copy3($6, "ex\" width=\"", $9);
790
$$ = itex2MML_copy3(s1, s2, "em\"></mspace>");
791
itex2MML_free_string(s1);
792
itex2MML_free_string(s2);
793
itex2MML_free_string($3);
794
itex2MML_free_string($6);
795
itex2MML_free_string($9);
798
statusline: STATLINE TEXTSTRING closedTerm {
799
char * s1 = itex2MML_copy3("<maction actiontype=\"statusline\">", $3, "<mtext>");
800
$$ = itex2MML_copy3(s1, $2, "</mtext></maction>");
801
itex2MML_free_string(s1);
802
itex2MML_free_string($2);
803
itex2MML_free_string($3);
806
toggle: TOGGLE closedTerm closedTerm {
807
char * s1 = itex2MML_copy3("<maction actiontype=\"toggle\" selection=\"2\">", $2, " ");
808
$$ = itex2MML_copy3(s1, $3, "</maction>");
809
itex2MML_free_string(s1);
810
itex2MML_free_string($2);
811
itex2MML_free_string($3);
814
fghighlight: FGHIGHLIGHT ATTRLIST closedTerm {
815
char * s1 = itex2MML_copy3("<maction actiontype=\"highlight\" other='color=", $2, "'>");
816
$$ = itex2MML_copy3(s1, $3, "</maction>");
817
itex2MML_free_string(s1);
818
itex2MML_free_string($2);
819
itex2MML_free_string($3);
822
bghighlight: BGHIGHLIGHT ATTRLIST closedTerm {
823
char * s1 = itex2MML_copy3("<maction actiontype=\"highlight\" other='background=", $2, "'>");
824
$$ = itex2MML_copy3(s1, $3, "</maction>");
825
itex2MML_free_string(s1);
826
itex2MML_free_string($2);
827
itex2MML_free_string($3);
830
color: COLOR ATTRLIST compoundTermList {
831
char * s1 = itex2MML_copy3("<mstyle mathcolor=", $2, ">");
832
$$ = itex2MML_copy3(s1, $3, "</mstyle>");
833
itex2MML_free_string(s1);
834
itex2MML_free_string($2);
835
itex2MML_free_string($3);
837
| BGCOLOR ATTRLIST compoundTermList {
838
char * s1 = itex2MML_copy3("<mstyle mathbackground=", $2, ">");
839
$$ = itex2MML_copy3(s1, $3, "</mstyle>");
840
itex2MML_free_string(s1);
841
itex2MML_free_string($2);
842
itex2MML_free_string($3);
845
textstring: TEXTBOX TEXTSTRING {
846
$$ = itex2MML_copy3("<mtext>", $2, "</mtext>");
847
itex2MML_free_string($2);
850
displaystyle: DISPLAY closedTerm {
851
$$ = itex2MML_copy3("<mstyle displaystyle=\"true\">", $2, "</mstyle>");
852
itex2MML_free_string($2);
855
textstyle: TEXTSTY closedTerm {
856
$$ = itex2MML_copy3("<mstyle displaystyle=\"false\">", $2, "</mstyle>");
857
itex2MML_free_string($2);
860
textsize: TEXTSIZE closedTerm {
861
$$ = itex2MML_copy3("<mstyle scriptlevel=\"0\">", $2, "</mstyle>");
862
itex2MML_free_string($2);
865
scriptsize: SCSIZE closedTerm {
866
$$ = itex2MML_copy3("<mstyle scriptlevel=\"1\">", $2, "</mstyle>");
867
itex2MML_free_string($2);
870
scriptscriptsize: SCSCSIZE closedTerm {
871
$$ = itex2MML_copy3("<mstyle scriptlevel=\"2\">", $2, "</mstyle>");
872
itex2MML_free_string($2);
875
italics: ITALICS closedTerm {
876
$$ = itex2MML_copy3("<mstyle mathvariant=\"italic\">", $2, "</mstyle>");
877
itex2MML_free_string($2);
880
bold: BOLD closedTerm {
881
$$ = itex2MML_copy3("<mstyle mathvariant=\"bold\">", $2, "</mstyle>");
882
itex2MML_free_string($2);
885
roman: RM ST rmchars END {
886
$$ = itex2MML_copy3("<mi mathvariant=\"normal\">", $3, "</mi>");
887
itex2MML_free_string($3);
891
$$ = itex2MML_copy_string($1);
892
itex2MML_free_string($1);
895
$$ = itex2MML_copy2($1, $2);
896
itex2MML_free_string($1);
897
itex2MML_free_string($2);
900
bbold: BB ST bbletters END {
901
$$ = itex2MML_copy3("<mi>", $3, "</mi>");
902
itex2MML_free_string($3);
905
bbletters: bbletter {
906
$$ = itex2MML_copy_string($1);
907
itex2MML_free_string($1);
909
| bbletters bbletter {
910
$$ = itex2MML_copy2($1, $2);
911
itex2MML_free_string($1);
912
itex2MML_free_string($2);
915
bbletter: BBLOWERCHAR {
916
$$ = itex2MML_copy_string($1);
917
itex2MML_free_string($1);
920
$$ = itex2MML_copy3("&", $1, "opf;");
921
itex2MML_free_string($1);
924
frak: FRAK ST frakletters END {
925
$$ = itex2MML_copy3("<mi>", $3, "</mi>");
926
itex2MML_free_string($3);
929
frakletters: frakletter {
930
$$ = itex2MML_copy_string($1);
931
itex2MML_free_string($1);
933
| frakletters frakletter {
934
$$ = itex2MML_copy2($1, $2);
935
itex2MML_free_string($1);
936
itex2MML_free_string($2);
939
frakletter: FRAKCHAR {
940
$$ = itex2MML_copy3("&", $1, "fr;");
941
itex2MML_free_string($1);
944
cal: CAL ST calletters END {
945
$$ = itex2MML_copy3("<mi>", $3, "</mi>");
946
itex2MML_free_string($3);
949
calletters: calletter {
950
$$ = itex2MML_copy_string($1);
951
itex2MML_free_string($1);
953
| calletters calletter {
954
$$ = itex2MML_copy2($1, $2);
955
itex2MML_free_string($1);
956
itex2MML_free_string($2);
960
$$ = itex2MML_copy3("&", $1, "scr;");
961
itex2MML_free_string($1);
964
thinspace: THINSPACE {
965
$$ = itex2MML_copy_string("<mspace width=\"thinmathspace\"></mspace>");
969
$$ = itex2MML_copy_string("<mspace width=\"mediummathspace\"></mspace>");
972
thickspace: THICKSPACE {
973
$$ = itex2MML_copy_string("<mspace width=\"thickmathspace\"></mspace>");
977
$$ = itex2MML_copy_string("<mspace width=\"1em\"></mspace>");
981
$$ = itex2MML_copy_string("<mspace width=\"2em\"></mspace>");
985
$$ = itex2MML_copy_string("<mspace width=\"-0.1667 em\"></mspace>");
988
phantom: PHANTOM closedTerm {
989
$$ = itex2MML_copy3("<mphantom>", $2, "</mphantom>");
990
itex2MML_free_string($2);
993
href: HREF TEXTSTRING closedTerm {
994
char * s1 = itex2MML_copy3("<mrow xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:type=\"simple\" xlink:href=\"", $2, "\">");
995
$$ = itex2MML_copy3(s1, $3, "</mrow>");
996
itex2MML_free_string(s1);
997
itex2MML_free_string($2);
998
itex2MML_free_string($3);
1001
tensor: TENSOR closedTerm MROWOPEN subsupList MROWCLOSE {
1002
char * s1 = itex2MML_copy3("<mmultiscripts>", $2, $4);
1003
$$ = itex2MML_copy2(s1, "</mmultiscripts>");
1004
itex2MML_free_string(s1);
1005
itex2MML_free_string($2);
1006
itex2MML_free_string($4);
1008
| TENSOR closedTerm subsupList {
1009
char * s1 = itex2MML_copy3("<mmultiscripts>", $2, $3);
1010
$$ = itex2MML_copy2(s1, "</mmultiscripts>");
1011
itex2MML_free_string(s1);
1012
itex2MML_free_string($2);
1013
itex2MML_free_string($3);
1016
multi: MULTI MROWOPEN subsupList MROWCLOSE closedTerm MROWOPEN subsupList MROWCLOSE {
1017
char * s1 = itex2MML_copy3("<mmultiscripts>", $5, $7);
1018
char * s2 = itex2MML_copy3("<mprescripts></mprescripts>", $3, "</mmultiscripts>");
1019
$$ = itex2MML_copy2(s1, s2);
1020
itex2MML_free_string(s1);
1021
itex2MML_free_string(s2);
1022
itex2MML_free_string($3);
1023
itex2MML_free_string($5);
1024
itex2MML_free_string($7);
1026
| MULTI MROWOPEN subsupList MROWCLOSE closedTerm EMPTYMROW {
1027
char * s1 = itex2MML_copy2("<mmultiscripts>", $5);
1028
char * s2 = itex2MML_copy3("<mprescripts></mprescripts>", $3, "</mmultiscripts>");
1029
$$ = itex2MML_copy2(s1, s2);
1030
itex2MML_free_string(s1);
1031
itex2MML_free_string(s2);
1032
itex2MML_free_string($3);
1033
itex2MML_free_string($5);
1035
| MULTI EMPTYMROW closedTerm MROWOPEN subsupList MROWCLOSE {
1036
char * s1 = itex2MML_copy3("<mmultiscripts>", $3, $5);
1037
$$ = itex2MML_copy2(s1, "</mmultiscripts>");
1038
itex2MML_free_string(s1);
1039
itex2MML_free_string($3);
1040
itex2MML_free_string($5);
1043
subsupList: subsupTerm {
1044
$$ = itex2MML_copy_string($1);
1045
itex2MML_free_string($1);
1047
| subsupList subsupTerm {
1048
$$ = itex2MML_copy3($1, " ", $2);
1049
itex2MML_free_string($1);
1050
itex2MML_free_string($2);
1053
subsupTerm: SUB closedTerm SUP closedTerm {
1054
$$ = itex2MML_copy3($2, " ", $4);
1055
itex2MML_free_string($2);
1056
itex2MML_free_string($4);
1059
$$ = itex2MML_copy2($2, " <none></none>");
1060
itex2MML_free_string($2);
1063
$$ = itex2MML_copy2("<none></none> ", $2);
1064
itex2MML_free_string($2);
1066
| SUB SUP closedTerm {
1067
$$ = itex2MML_copy2("<none></none> ", $3);
1068
itex2MML_free_string($3);
1071
mfrac: FRAC closedTerm closedTerm {
1072
char * s1 = itex2MML_copy3("<mfrac>", $2, $3);
1073
$$ = itex2MML_copy2(s1, "</mfrac>");
1074
itex2MML_free_string(s1);
1075
itex2MML_free_string($2);
1076
itex2MML_free_string($3);
1078
| TFRAC closedTerm closedTerm {
1079
char * s1 = itex2MML_copy3("<mstyle displaystyle=\"false\"><mfrac>", $2, $3);
1080
$$ = itex2MML_copy2(s1, "</mfrac></mstyle>");
1081
itex2MML_free_string(s1);
1082
itex2MML_free_string($2);
1083
itex2MML_free_string($3);
1086
pmod: PMOD closedTerm {
1087
$$ = itex2MML_copy3( "<mo lspace=\"mediummathspace\">(</mo><mo rspace=\"thinmathspace\">mod</mo>", $2, "<mo rspace=\"mediummathspace\">)</mo>");
1088
itex2MML_free_string($2);
1091
texover: MROWOPEN compoundTermList TEXOVER compoundTermList MROWCLOSE {
1092
char * s1 = itex2MML_copy3("<mfrac><mrow>", $2, "</mrow><mrow>");
1093
$$ = itex2MML_copy3(s1, $4, "</mrow></mfrac>");
1094
itex2MML_free_string(s1);
1095
itex2MML_free_string($2);
1096
itex2MML_free_string($4);
1098
| left compoundTermList TEXOVER compoundTermList right {
1099
char * s1 = itex2MML_copy3("<mrow>", $1, "<mfrac><mrow>");
1100
char * s2 = itex2MML_copy3($2, "</mrow><mrow>", $4);
1101
char * s3 = itex2MML_copy3("</mrow></mfrac>", $5, "</mrow>");
1102
$$ = itex2MML_copy3(s1, s2, s3);
1103
itex2MML_free_string(s1);
1104
itex2MML_free_string(s2);
1105
itex2MML_free_string(s3);
1106
itex2MML_free_string($1);
1107
itex2MML_free_string($2);
1108
itex2MML_free_string($4);
1109
itex2MML_free_string($5);
1112
binom: BINOM closedTerm closedTerm {
1113
char * s1 = itex2MML_copy3("<mfrac linethickness=\"0\">", $2, $3);
1114
$$ = itex2MML_copy2(s1, "</mfrac>");
1115
itex2MML_free_string(s1);
1116
itex2MML_free_string($2);
1117
itex2MML_free_string($3);
1120
munderbrace: UNDERBRACE closedTerm {
1121
$$ = itex2MML_copy3("<munder>", $2, "<mo>⏟</mo></munder>");
1122
itex2MML_free_string($2);
1125
moverbrace: OVERBRACE closedTerm {
1126
$$ = itex2MML_copy3("<mover>", $2, "<mo>⏞</mo></mover>");
1127
itex2MML_free_string($2);
1130
bar: BAR closedTerm {
1131
$$ = itex2MML_copy3("<mover>", $2, "<mo stretchy=\"false\">‾</mo></mover>");
1132
itex2MML_free_string($2);
1134
| WIDEBAR closedTerm {
1135
$$ = itex2MML_copy3("<mover>", $2, "<mo>‾</mo></mover>");
1136
itex2MML_free_string($2);
1139
vec: VEC closedTerm {
1140
$$ = itex2MML_copy3("<mover>", $2, "<mo stretchy=\"false\">⇀</mo></mover>");
1141
itex2MML_free_string($2);
1143
| WIDEVEC closedTerm {
1144
$$ = itex2MML_copy3("<mover>", $2, "<mo>⇀</mo></mover>");
1145
itex2MML_free_string($2);
1148
dot: DOT closedTerm {
1149
$$ = itex2MML_copy3("<mover>", $2, "<mo>˙</mo></mover>");
1150
itex2MML_free_string($2);
1153
ddot: DDOT closedTerm {
1154
$$ = itex2MML_copy3("<mover>", $2, "<mo>¨</mo></mover>");
1155
itex2MML_free_string($2);
1158
tilde: TILDE closedTerm {
1159
$$ = itex2MML_copy3("<mover>", $2, "<mo stretchy=\"false\">˜</mo></mover>");
1160
itex2MML_free_string($2);
1162
| WIDETILDE closedTerm {
1163
$$ = itex2MML_copy3("<mover>", $2, "<mo>˜</mo></mover>");
1164
itex2MML_free_string($2);
1167
check: CHECK closedTerm {
1168
$$ = itex2MML_copy3("<mover>", $2, "<mo stretchy=\"false\">¯</mo></mover>");
1169
itex2MML_free_string($2);
1171
| WIDECHECK closedTerm {
1172
$$ = itex2MML_copy3("<mover>", $2, "<mo>¯</mo></mover>");
1173
itex2MML_free_string($2);
1176
hat: HAT closedTerm {
1177
$$ = itex2MML_copy3("<mover>", $2, "<mo stretchy=\"false\">̂</mo></mover>");
1178
itex2MML_free_string($2);
1180
| WIDEHAT closedTerm {
1181
$$ = itex2MML_copy3("<mover>", $2, "<mo>̂</mo></mover>");
1182
itex2MML_free_string($2);
1185
msqrt: SQRT closedTerm {
1186
$$ = itex2MML_copy3("<msqrt>", $2, "</msqrt>");
1187
itex2MML_free_string($2);
1190
mroot: ROOT closedTerm closedTerm {
1191
char * s1 = itex2MML_copy3("<mroot>", $3, $2);
1192
$$ = itex2MML_copy2(s1, "</mroot>");
1193
itex2MML_free_string(s1);
1194
itex2MML_free_string($2);
1195
itex2MML_free_string($3);
1198
munder: UNDER closedTerm closedTerm {
1199
char * s1 = itex2MML_copy3("<munder>", $3, $2);
1200
$$ = itex2MML_copy2(s1, "</munder>");
1201
itex2MML_free_string(s1);
1202
itex2MML_free_string($2);
1203
itex2MML_free_string($3);
1206
mover: OVER closedTerm closedTerm {
1207
char * s1 = itex2MML_copy3("<mover>", $3, $2);
1208
$$ = itex2MML_copy2(s1, "</mover>");
1209
itex2MML_free_string(s1);
1210
itex2MML_free_string($2);
1211
itex2MML_free_string($3);
1214
munderover: UNDEROVER closedTerm closedTerm closedTerm {
1215
char * s1 = itex2MML_copy3("<munderover>", $4, $2);
1216
$$ = itex2MML_copy3(s1, $3, "</munderover>");
1217
itex2MML_free_string(s1);
1218
itex2MML_free_string($2);
1219
itex2MML_free_string($3);
1220
itex2MML_free_string($4);
1223
mathenv: BEGINENV MATRIX tableRowList ENDENV MATRIX {
1224
$$ = itex2MML_copy3("<mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow>");
1225
itex2MML_free_string($3);
1227
| BEGINENV PMATRIX tableRowList ENDENV PMATRIX {
1228
$$ = itex2MML_copy3("<mrow><mo>(</mo><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow><mo>)</mo></mrow>");
1229
itex2MML_free_string($3);
1231
| BEGINENV BMATRIX tableRowList ENDENV BMATRIX {
1232
$$ = itex2MML_copy3("<mrow><mo>[</mo><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow><mo>]</mo></mrow>");
1233
itex2MML_free_string($3);
1235
| BEGINENV VMATRIX tableRowList ENDENV VMATRIX {
1236
$$ = itex2MML_copy3("<mrow><mo>∣</mo><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow><mo>∣</mo></mrow>");
1237
itex2MML_free_string($3);
1239
| BEGINENV BBMATRIX tableRowList ENDENV BBMATRIX {
1240
$$ = itex2MML_copy3("<mrow><mo>{</mo><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow><mo>}</mo></mrow>");
1241
itex2MML_free_string($3);
1243
| BEGINENV VVMATRIX tableRowList ENDENV VVMATRIX {
1244
$$ = itex2MML_copy3("<mrow><mo>∥</mo><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow><mo>∥</mo></mrow>");
1245
itex2MML_free_string($3);
1247
| BEGINENV SMALLMATRIX tableRowList ENDENV SMALLMATRIX {
1248
$$ = itex2MML_copy3("<mstyle scriptlevel=\"2\"><mrow><mtable rowspacing=\"0.5ex\">", $3, "</mtable></mrow></mstyle>");
1249
itex2MML_free_string($3);
1251
| BEGINENV CASES tableRowList ENDENV CASES {
1252
$$ = itex2MML_copy3("<mrow><mo>{</mo><mrow><mtable columnalign=\"left left\">", $3, "</mtable></mrow></mrow>");
1253
itex2MML_free_string($3);
1255
| BEGINENV ALIGNED tableRowList ENDENV ALIGNED {
1256
$$ = itex2MML_copy3("<mrow><mtable columnalign=\"right left\">", $3, "</mtable></mrow>");
1257
itex2MML_free_string($3);
1260
substack: SUBSTACK MROWOPEN tableRowList MROWCLOSE {
1261
$$ = itex2MML_copy3("<mrow><mtable columnalign=\"center\" rowspacing=\"0.5ex\">", $3, "</mtable></mrow>");
1262
itex2MML_free_string($3);
1265
array: ARRAY MROWOPEN tableRowList MROWCLOSE {
1266
$$ = itex2MML_copy3("<mrow><mtable>", $3, "</mtable></mrow>");
1267
itex2MML_free_string($3);
1269
| ARRAY MROWOPEN ARRAYOPTS MROWOPEN arrayopts MROWCLOSE tableRowList MROWCLOSE {
1270
char * s1 = itex2MML_copy3("<mrow><mtable ", $5, ">");
1271
$$ = itex2MML_copy3(s1, $7, "</mtable></mrow>");
1272
itex2MML_free_string(s1);
1273
itex2MML_free_string($5);
1274
itex2MML_free_string($7);
1277
arrayopts: anarrayopt {
1278
$$ = itex2MML_copy_string($1);
1279
itex2MML_free_string($1);
1281
| arrayopts anarrayopt {
1282
$$ = itex2MML_copy3($1, " ", $2);
1283
itex2MML_free_string($1);
1284
itex2MML_free_string($2);
1287
anarrayopt: collayout {
1288
$$ = itex2MML_copy_string($1);
1289
itex2MML_free_string($1);
1292
$$ = itex2MML_copy_string($1);
1293
itex2MML_free_string($1);
1296
$$ = itex2MML_copy_string($1);
1297
itex2MML_free_string($1);
1300
$$ = itex2MML_copy_string($1);
1301
itex2MML_free_string($1);
1304
$$ = itex2MML_copy_string($1);
1305
itex2MML_free_string($1);
1308
$$ = itex2MML_copy_string($1);
1309
itex2MML_free_string($1);
1312
$$ = itex2MML_copy_string($1);
1313
itex2MML_free_string($1);
1316
$$ = itex2MML_copy_string($1);
1317
itex2MML_free_string($1);
1320
$$ = itex2MML_copy_string($1);
1321
itex2MML_free_string($1);
1324
$$ = itex2MML_copy_string($1);
1325
itex2MML_free_string($1);
1328
collayout: COLLAYOUT ATTRLIST {
1329
$$ = itex2MML_copy2("columnalign=", $2);
1330
itex2MML_free_string($2);
1333
colalign: COLALIGN ATTRLIST {
1334
$$ = itex2MML_copy2("columnalign=", $2);
1335
itex2MML_free_string($2);
1338
rowalign: ROWALIGN ATTRLIST {
1339
$$ = itex2MML_copy2("rowalign=", $2);
1340
itex2MML_free_string($2);
1343
align: ALIGN ATTRLIST {
1344
$$ = itex2MML_copy2("align=", $2);
1345
itex2MML_free_string($2);
1348
eqrows: EQROWS ATTRLIST {
1349
$$ = itex2MML_copy2("equalrows=", $2);
1350
itex2MML_free_string($2);
1353
eqcols: EQCOLS ATTRLIST {
1354
$$ = itex2MML_copy2("equalcolumns=", $2);
1355
itex2MML_free_string($2);
1358
rowlines: ROWLINES ATTRLIST {
1359
$$ = itex2MML_copy2("rowlines=", $2);
1360
itex2MML_free_string($2);
1363
collines: COLLINES ATTRLIST {
1364
$$ = itex2MML_copy2("columnlines=", $2);
1365
itex2MML_free_string($2);
1368
frame: FRAME ATTRLIST {
1369
$$ = itex2MML_copy2("frame=", $2);
1370
itex2MML_free_string($2);
1373
padding: PADDING ATTRLIST {
1374
char * s1 = itex2MML_copy3("rowspacing=", $2, " columnspacing=");
1375
$$ = itex2MML_copy2(s1, $2);
1376
itex2MML_free_string(s1);
1377
itex2MML_free_string($2);
1380
tableRowList: tableRow {
1381
$$ = itex2MML_copy_string($1);
1382
itex2MML_free_string($1);
1384
| tableRowList ROWSEP tableRow {
1385
$$ = itex2MML_copy3($1, " ", $3);
1386
itex2MML_free_string($1);
1387
itex2MML_free_string($3);
1390
tableRow: simpleTableRow {
1391
$$ = itex2MML_copy3("<mtr>", $1, "</mtr>");
1392
itex2MML_free_string($1);
1395
$$ = itex2MML_copy_string($1);
1396
itex2MML_free_string($1);
1399
simpleTableRow: tableCell {
1400
$$ = itex2MML_copy_string($1);
1401
itex2MML_free_string($1);
1403
| simpleTableRow COLSEP tableCell {
1404
$$ = itex2MML_copy3($1, " ", $3);
1405
itex2MML_free_string($1);
1406
itex2MML_free_string($3);
1409
optsTableRow: ROWOPTS MROWOPEN rowopts MROWCLOSE simpleTableRow {
1410
char * s1 = itex2MML_copy3("<mtr ", $3, ">");
1411
$$ = itex2MML_copy3(s1, $5, "</mtr>");
1412
itex2MML_free_string(s1);
1413
itex2MML_free_string($3);
1414
itex2MML_free_string($5);
1418
$$ = itex2MML_copy_string($1);
1419
itex2MML_free_string($1);
1422
$$ = itex2MML_copy3($1, " ", $2);
1423
itex2MML_free_string($1);
1424
itex2MML_free_string($2);
1428
$$ = itex2MML_copy_string($1);
1429
itex2MML_free_string($1);
1432
$$ = itex2MML_copy_string($1);
1433
itex2MML_free_string($1);
1437
$$ = itex2MML_copy_string("<mtd></mtd>");
1439
| compoundTermList {
1440
$$ = itex2MML_copy3("<mtd>", $1, "</mtd>");
1441
itex2MML_free_string($1);
1443
| CELLOPTS MROWOPEN cellopts MROWCLOSE compoundTermList {
1444
char * s1 = itex2MML_copy3("<mtd ", $3, ">");
1445
$$ = itex2MML_copy3(s1, $5, "</mtd>");
1446
itex2MML_free_string(s1);
1447
itex2MML_free_string($3);
1448
itex2MML_free_string($5);
1451
cellopts: acellopt {
1452
$$ = itex2MML_copy_string($1);
1453
itex2MML_free_string($1);
1455
| cellopts acellopt {
1456
$$ = itex2MML_copy3($1, " ", $2);
1457
itex2MML_free_string($1);
1458
itex2MML_free_string($2);
1461
acellopt: colalign {
1462
$$ = itex2MML_copy_string($1);
1463
itex2MML_free_string($1);
1466
$$ = itex2MML_copy_string($1);
1467
itex2MML_free_string($1);
1470
$$ = itex2MML_copy_string($1);
1471
itex2MML_free_string($1);
1474
$$ = itex2MML_copy_string($1);
1475
itex2MML_free_string($1);
1478
rowspan: ROWSPAN ATTRLIST {
1479
$$ = itex2MML_copy2("rowspan=", $2);
1480
itex2MML_free_string($2);
1483
colspan: COLSPAN ATTRLIST {
1484
$$ = itex2MML_copy2("colspan=", $2);
1485
itex2MML_free_string($2);
1490
char * itex2MML_parse (const char * buffer, unsigned long length)
1496
itex2MML_setup (buffer, length);
1497
itex2MML_restart ();
1499
result = itex2MML_yyparse (&mathml);
1501
if (result && mathml) /* shouldn't happen? */
1503
itex2MML_free_string (mathml);
1509
int itex2MML_filter (const char * buffer, unsigned long length)
1511
itex2MML_setup (buffer, length);
1512
itex2MML_restart ();
1514
return itex2MML_yyparse (0);
1517
#define ITEX_DELIMITER_DOLLAR 0
1518
#define ITEX_DELIMITER_DOUBLE 1
1519
#define ITEX_DELIMITER_SQUARE 2
1521
static char * itex2MML_last_error = 0;
1523
static void itex2MML_keep_error (const char * msg)
1525
if (itex2MML_last_error)
1527
itex2MML_free_string (itex2MML_last_error);
1528
itex2MML_last_error = 0;
1530
itex2MML_last_error = itex2MML_copy_escaped (msg);
1533
int itex2MML_html_filter (const char * buffer, unsigned long length)
1541
const char * ptr1 = buffer;
1542
const char * ptr2 = 0;
1544
const char * end = buffer + length;
1548
void (*save_error_fn) (const char * msg) = itex2MML_error;
1550
itex2MML_error = itex2MML_keep_error;
1557
if (*ptr2 == '$') break;
1558
if ((*ptr2 == '\\') && (ptr2 + 1 < end))
1560
if (*(ptr2+1) == '[') break;
1565
(*itex2MML_write) (ptr1, ptr2 - ptr1);
1567
if (ptr2 == end) goto _finish;
1574
if ((*ptr2 == '\\') && (*(ptr2+1) == '['))
1576
type = ITEX_DELIMITER_SQUARE;
1579
else if ((*ptr2 == '$') && (*(ptr2+1) == '$'))
1581
type = ITEX_DELIMITER_DOUBLE;
1586
type = ITEX_DELIMITER_DOLLAR;
1607
if (*(ptr2 + 1) == '[')
1611
else if (*(ptr2 + 1) == ']')
1613
if (type == ITEX_DELIMITER_SQUARE)
1627
if (type == ITEX_DELIMITER_SQUARE)
1631
else if (ptr2 + 1 < end)
1633
if (*(ptr2 + 1) == '$')
1635
if (type == ITEX_DELIMITER_DOLLAR)
1648
if (type == ITEX_DELIMITER_DOLLAR)
1661
if (type == ITEX_DELIMITER_DOLLAR)
1676
if (skip || match) break;
1682
if (type == ITEX_DELIMITER_DOLLAR)
1685
(*itex2MML_write) (ptr1, 1);
1691
(*itex2MML_write) (ptr1, 2);
1698
mathml = itex2MML_parse (ptr1, ptr2 - ptr1);
1702
if (itex2MML_write_mathml)
1703
(*itex2MML_write_mathml) (mathml);
1704
itex2MML_free_string (mathml);
1712
if (type == ITEX_DELIMITER_DOLLAR)
1713
(*itex2MML_write) ("<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><merror><mtext>", 0);
1715
(*itex2MML_write) ("<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><merror><mtext>", 0);
1717
(*itex2MML_write) (itex2MML_last_error, 0);
1718
(*itex2MML_write) ("</mtext></merror></math>", 0);
1726
(*itex2MML_write) (ptr1, ptr2 - ptr1);
1729
if (itex2MML_last_error)
1731
itex2MML_free_string (itex2MML_last_error);
1732
itex2MML_last_error = 0;
1734
itex2MML_error = save_error_fn;