Subversion Repositories wimsdev

Rev

Rev 6185 | Rev 7219 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6185 Rev 7076
Line 15... Line 15...
15
#define YYPARSE_PARAM ret_str
15
#define YYPARSE_PARAM ret_str
16
 
16
 
17
#define yytext wims_mathml_yytext
17
#define yytext wims_mathml_yytext
18
 extern int yylex ();
18
 extern int yylex ();
19
 extern char * yytext;
19
 extern char * yytext;
20
  
-
 
21
 
20
 
22
 static void wims_mathml_default_error (const char * msg)
21
 static void wims_mathml_default_error (const char * msg)
23
   {
22
  {
24
//   if (msg){ fprintf(stderr, "Line: %d Error: %s\n", wims_mathml_lineno, msg);}
23
//   if (msg){ fprintf(stderr, "Line: %d Error: %s\n", wims_mathml_lineno, msg);}
25
   }
24
  }
26
 
25
 
27
 void (*wims_mathml_error) (const char * msg) = wims_mathml_default_error;
26
 void (*wims_mathml_error) (const char * msg) = wims_mathml_default_error;
28
 
27
 
29
 static void yyerror (char * s)
28
 static void yyerror (char * s)
30
   {
29
  {
31
//    char * msg = wims_mathml_copy3 (s, " at token ", yytext);
30
//    char * msg = wims_mathml_copy3 (s, " at token ", yytext);
32
     if (wims_mathml_error)
31
    if (wims_mathml_error)
33
       (*wims_mathml_error) ("ERROR");
32
      (*wims_mathml_error) ("ERROR");
34
//     wims_mathml_free_string (msg);
33
//     wims_mathml_free_string (msg);
35
   }
34
  }
36
 
35
 
37
 /* Note: If length is 0, then buffer is treated like a string; otherwise only length bytes are written.
36
 /* Note: If length is 0, then buffer is treated like a string; otherwise only length bytes are written.
38
  */
37
  */
39
 static void wims_mathml_default_write (const char * buffer, unsigned long length)
38
 static void wims_mathml_default_write (const char * buffer, unsigned long length)
40
   {
39
   {
41
     if (buffer)
40
     if (buffer)
42
       {
41
       {
43
	 if (length)
42
   if (length)
44
	   fwrite (buffer, 1, length, stdout);
43
     fwrite (buffer, 1, length, stdout);
45
	 else
44
   else
46
	   fputs (buffer, stdout);
45
     fputs (buffer, stdout);
47
       }
46
       }
48
   }
47
   }
49
 
48
 
50
 static void wims_mathml_default_write_mathml (const char * mathml)
49
 static void wims_mathml_default_write_mathml (const char * mathml)
51
   {
50
   {
Line 127... Line 126...
127
 char * wims_mathml_copy_string_extra (const char * str, unsigned extra)
126
 char * wims_mathml_copy_string_extra (const char * str, unsigned extra)
128
   {
127
   {
129
     char * copy = (char *) malloc(extra + (str ? strlen (str) : 0) + 1);
128
     char * copy = (char *) malloc(extra + (str ? strlen (str) : 0) + 1);
130
     if (copy)
129
     if (copy)
131
       {
130
       {
132
	 if (str)
131
   if (str)
133
	   strcpy(copy, str);
132
     strcpy(copy, str);
134
	 else
133
   else
135
	   copy[0] = 0;
134
     copy[0] = 0;
136
       }
135
       }
137
     return copy ? copy : wims_mathml_empty_string;
136
     return copy ? copy : wims_mathml_empty_string;
138
   }
137
   }
139
 
138
 
140
 /* Create a copy of a string, appending two strings
139
 /* Create a copy of a string, appending two strings
Line 147... Line 146...
147
 
146
 
148
     char * copy = (char *) malloc(first_length + second_length + third_length + 1);
147
     char * copy = (char *) malloc(first_length + second_length + third_length + 1);
149
 
148
 
150
     if (copy)
149
     if (copy)
151
       {
150
       {
152
	 if (first)
151
   if (first)
153
	   strcpy(copy, first);
152
     strcpy(copy, first);
154
	 else
153
   else
155
	   copy[0] = 0;
154
     copy[0] = 0;
156
 
155
 
157
	 if (second) strcat(copy, second);
156
   if (second) strcat(copy, second);
158
	 if ( third) strcat(copy,  third);
157
   if ( third) strcat(copy,  third);
159
       }
158
       }
160
     return copy ? copy : wims_mathml_empty_string;
159
     return copy ? copy : wims_mathml_empty_string;
161
   }
160
   }
162
/* wims */
161
/* wims */
163
 char * wims_mathml_copy5 (const char * first, const char * second, const char * third ,const char * forth,const char * fifth)
162
 char * wims_mathml_copy5 (const char * first, const char * second, const char * third ,const char * forth,const char * fifth)
Line 285... Line 284...
285
     if ( str == 0) return wims_mathml_empty_string;
284
     if ( str == 0) return wims_mathml_empty_string;
286
     if (*str == 0) return wims_mathml_empty_string;
285
     if (*str == 0) return wims_mathml_empty_string;
287
 
286
 
288
     while (*ptr1)
287
     while (*ptr1)
289
       {
288
       {
290
	 switch (*ptr1)
289
   switch (*ptr1)
291
	   {
290
     {
292
	   case '<':  /* &lt;   */
291
     case '<':  /* &lt;   */
293
	   case '>':  /* &gt;   */
292
     case '>':  /* &gt;   */
294
	     length += 4;
293
       length += 4;
295
	     break;
294
       break;
296
	   case '&':  /* &amp;  */
295
     case '&':  /* &amp;  */
297
	     length += 5;
296
       length += 5;
298
	     break;
297
       break;
299
	   case '\'': /* &apos; */
298
     case '\'': /* &apos; */
300
	   case '"':  /* &quot; */
299
     case '"':  /* &quot; */
301
	   case '-':  /* &#x2d; */
300
     case '-':  /* &#x2d; */
302
	     length += 6;
301
       length += 6;
303
	     break;
302
       break;
304
	   default:
303
     default:
305
	     length += 1;
304
       length += 1;
306
	     break;
305
       break;
307
	   }
306
     }
308
	 ++ptr1;
307
   ++ptr1;
309
       }
308
       }
310
 
309
 
311
     copy = (char *) malloc (length + 1);
310
     copy = (char *) malloc (length + 1);
312
 
311
 
313
     if (copy)
312
     if (copy)
314
       {
313
       {
315
	 ptr1 = str;
314
   ptr1 = str;
316
	 ptr2 = copy;
315
   ptr2 = copy;
317
 
316
 
318
	 while (*ptr1)
317
   while (*ptr1)
319
	   {
318
     {
320
	     switch (*ptr1)
319
       switch (*ptr1)
321
	       {
320
         {
322
	       case '<':
321
         case '<':
323
		 strcpy (ptr2, "&lt;");
322
     strcpy (ptr2, "&lt;");
324
		 ptr2 += 4;
323
     ptr2 += 4;
325
		 break;
324
     break;
326
	       case '>':
325
         case '>':
327
		 strcpy (ptr2, "&gt;");
326
     strcpy (ptr2, "&gt;");
328
		 ptr2 += 4;
327
     ptr2 += 4;
329
		 break;
328
     break;
330
	       case '&':  /* &amp;  */
329
         case '&':  /* &amp;  */
331
		 strcpy (ptr2, "&amp;");
330
     strcpy (ptr2, "&amp;");
332
		 ptr2 += 5;
331
     ptr2 += 5;
333
		 break;
332
     break;
334
	       case '\'': /* &apos; */
333
         case '\'': /* &apos; */
335
		 strcpy (ptr2, "&apos;");
334
     strcpy (ptr2, "&apos;");
336
		 ptr2 += 6;
335
     ptr2 += 6;
337
		 break;
336
     break;
338
	       case '"':  /* &quot; */
337
         case '"':  /* &quot; */
339
		 strcpy (ptr2, "&quot;");
338
     strcpy (ptr2, "&quot;");
340
		 ptr2 += 6;
339
     ptr2 += 6;
341
		 break;
340
     break;
342
	       case '-':  /* &#x2d; */
341
         case '-':  /* &#x2d; */
343
		 strcpy (ptr2, "&#x2d;");
342
     strcpy (ptr2, "&#x2d;");
344
		 ptr2 += 6;
343
     ptr2 += 6;
345
		 break;
344
     break;
346
	       default:
345
         default:
347
		 *ptr2++ = *ptr1;
346
     *ptr2++ = *ptr1;
348
		 break;
347
     break;
349
	       }
348
         }
350
	     ++ptr1;
349
       ++ptr1;
351
	   }
350
     }
352
	 *ptr2 = 0;
351
   *ptr2 = 0;
353
       }
352
       }
354
     return copy ? copy : wims_mathml_empty_string;
353
     return copy ? copy : wims_mathml_empty_string;
355
   }
354
   }
356
 
355
 
357
 /* Create a hex character reference string corresponding to code
356
 /* Create a hex character reference string corresponding to code
Line 836... Line 835...
836
  wims_mathml_rowposn = 2;
835
  wims_mathml_rowposn = 2;
837
  $$ = wims_mathml_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
836
  $$ = wims_mathml_copy3("<mo maxsize=\"1.8em\" minsize=\"1.8em\">", $2, "</mo>");
838
  wims_mathml_free_string($2);
837
  wims_mathml_free_string($2);
839
}
838
}
840
| BIGGL LEFTDELIM {
839
| BIGGL LEFTDELIM {
841
  wims_mathml_rowposn = 2;
840
  wims_mathml_rowposn = 2;
842
  $$ = wims_mathml_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
841
  $$ = wims_mathml_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
843
  wims_mathml_free_string($2);
842
  wims_mathml_free_string($2);
844
} 
843
} 
845
| BIGGL OTHERDELIM {
844
| BIGGL OTHERDELIM {
846
  wims_mathml_rowposn = 2;
845
  wims_mathml_rowposn = 2;
847
  $$ = wims_mathml_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
846
  $$ = wims_mathml_copy3("<mo maxsize=\"2.4em\" minsize=\"2.4em\">", $2, "</mo>");
848
  wims_mathml_free_string($2);
847
  wims_mathml_free_string($2);
Line 916... Line 915...
916
  wims_mathml_rowposn = 2;
915
  wims_mathml_rowposn = 2;
917
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
916
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
918
  wims_mathml_free_string($1);
917
  wims_mathml_free_string($1);
919
}
918
}
920
| OTHERDELIM {
919
| OTHERDELIM {
921
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
920
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
922
  wims_mathml_free_string($1);
921
  wims_mathml_free_string($1);
923
}
922
}
924
| MOF {
923
| MOF {
925
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
924
  $$ = wims_mathml_copy3("<mo stretchy=\"false\">", $1, "</mo>");
926
  wims_mathml_free_string($1);
925
  wims_mathml_free_string($1);
927
}
926
}
928
| PERIODDELIM {
927
| PERIODDELIM {
929
  $$ = wims_mathml_copy3("<mo>", $1, "</mo>");
928
  $$ = wims_mathml_copy3("<mo>", $1, "</mo>");
930
  wims_mathml_free_string($1);
929
  wims_mathml_free_string($1);
931
}
930
}
932
| MOS {
931
| MOS {
933
  wims_mathml_rowposn=2;
932
  wims_mathml_rowposn=2;
934
  $$ = wims_mathml_copy3("<mo lspace=\"mediummathspace\" rspace=\"mediummathspace\">", $1, "</mo>");
933
  $$ = wims_mathml_copy3("<mo lspace=\"mediummathspace\" rspace=\"mediummathspace\">", $1, "</mo>");
935
  wims_mathml_free_string($1);
934
  wims_mathml_free_string($1);
936
}
935
}
937
| MOP {
936
| MOP {
938
  wims_mathml_rowposn = 2;
937
  wims_mathml_rowposn = 2;
939
  $$ = wims_mathml_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $1, "</mo>");
938
  $$ = wims_mathml_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $1, "</mo>");
940
  wims_mathml_free_string($1);
939
  wims_mathml_free_string($1);
Line 943... Line 942...
943
  wims_mathml_rowposn = 2;
942
  wims_mathml_rowposn = 2;
944
  $$ = wims_mathml_copy3("<mo lspace=\"verythinmathspace\">", $1, "</mo>");
943
  $$ = wims_mathml_copy3("<mo lspace=\"verythinmathspace\">", $1, "</mo>");
945
  wims_mathml_free_string($1);
944
  wims_mathml_free_string($1);
946
}
945
}
947
| OPERATORNAME TEXTSTRING {
946
| OPERATORNAME TEXTSTRING {
948
  wims_mathml_rowposn = 2;
947
  wims_mathml_rowposn = 2;
949
  $$ = wims_mathml_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $2, "</mo>");
948
  $$ = wims_mathml_copy3("<mo lspace=\"0em\" rspace=\"thinmathspace\">", $2, "</mo>");
950
  wims_mathml_free_string($2);
949
  wims_mathml_free_string($2);
951
}
950
}
952
| MATHOP TEXTSTRING {
951
| MATHOP TEXTSTRING {
953
  wims_mathml_rowposn = 2;
952
  wims_mathml_rowposn = 2;
954
  $$ = wims_mathml_copy3("<mo lspace=\"thinmathspace\" rspace=\"thinmathspace\">", $2, "</mo>");
953
  $$ = wims_mathml_copy3("<mo lspace=\"thinmathspace\" rspace=\"thinmathspace\">", $2, "</mo>");
955
  wims_mathml_free_string($2);
954
  wims_mathml_free_string($2);
956
}
955
}
957
| MATHBIN TEXTSTRING {
956
| MATHBIN TEXTSTRING {
958
  wims_mathml_rowposn = 2;
957
  wims_mathml_rowposn = 2;
959
  $$ = wims_mathml_copy3("<mo lspace=\"mediummathspace\" rspace=\"mediummathspace\">", $2, "</mo>");
958
  $$ = wims_mathml_copy3("<mo lspace=\"mediummathspace\" rspace=\"mediummathspace\">", $2, "</mo>");
960
  wims_mathml_free_string($2);
959
  wims_mathml_free_string($2);
961
}
960
}
962
| MATHREL TEXTSTRING {
961
| MATHREL TEXTSTRING {
963
  wims_mathml_rowposn = 2;
962
  wims_mathml_rowposn = 2;
Line 969... Line 968...
969
  char * s1 = wims_mathml_copy3("<mspace height=\"", $3, "ex\" depth=\"");
968
  char * s1 = wims_mathml_copy3("<mspace height=\"", $3, "ex\" depth=\"");
970
  char * s2 = wims_mathml_copy3($6, "ex\" width=\"", $9);
969
  char * s2 = wims_mathml_copy3($6, "ex\" width=\"", $9);
971
  $$ = wims_mathml_copy3(s1, s2, "em\"></mspace>");
970
  $$ = wims_mathml_copy3(s1, s2, "em\"></mspace>");
972
  wims_mathml_free_string(s1);
971
  wims_mathml_free_string(s1);
973
  wims_mathml_free_string(s2);
972
  wims_mathml_free_string(s2);
974
  wims_mathml_free_string($3);
973
  wims_mathml_free_string($3);
975
  wims_mathml_free_string($6);
974
  wims_mathml_free_string($6);
976
  wims_mathml_free_string($9);
975
  wims_mathml_free_string($9);
977
};
976
};
978
 
977
 
979
statusline: STATLINE TEXTSTRING closedTerm {
978
statusline: STATLINE TEXTSTRING closedTerm {
980
  char * s1 = wims_mathml_copy3("<maction actiontype=\"statusline\">", $3, "<mtext>");
979
  char * s1 = wims_mathml_copy3("<maction actiontype=\"statusline\">", $3, "<mtext>");
981
  $$ = wims_mathml_copy3(s1, $2, "</mtext></maction>");
980
  $$ = wims_mathml_copy3(s1, $2, "</mtext></maction>");
982
  wims_mathml_free_string(s1);
981
  wims_mathml_free_string(s1);
983
  wims_mathml_free_string($2);
982
  wims_mathml_free_string($2);
984
  wims_mathml_free_string($3);
983
  wims_mathml_free_string($3);
985
};
984
};
986
 
985
 
987
tooltip: TOOLTIP TEXTSTRING closedTerm {
986
tooltip: TOOLTIP TEXTSTRING closedTerm {
988
  char * s1 = wims_mathml_copy3("<maction actiontype=\"tooltip\">", $3, "<mtext>");
987
  char * s1 = wims_mathml_copy3("<maction actiontype=\"tooltip\">", $3, "<mtext>");
989
  $$ = wims_mathml_copy3(s1, $2, "</mtext></maction>");
988
  $$ = wims_mathml_copy3(s1, $2, "</mtext></maction>");
990
  wims_mathml_free_string(s1);
989
  wims_mathml_free_string(s1);
991
  wims_mathml_free_string($2);
990
  wims_mathml_free_string($2);
992
  wims_mathml_free_string($3);
991
  wims_mathml_free_string($3);
993
};
992
};
994
 
993
 
995
toggle: TOGGLE closedTerm closedTerm {
994
toggle: TOGGLE closedTerm closedTerm {
996
  char * s1 = wims_mathml_copy3("<maction actiontype=\"toggle\" selection=\"2\">", $2, " ");
995
  char * s1 = wims_mathml_copy3("<maction actiontype=\"toggle\" selection=\"2\">", $2, " ");
997
  $$ = wims_mathml_copy3(s1, $3, "</maction>");
996
  $$ = wims_mathml_copy3(s1, $3, "</maction>");
998
  wims_mathml_free_string(s1);
997
  wims_mathml_free_string(s1);
999
  wims_mathml_free_string($2);
998
  wims_mathml_free_string($2);
1000
  wims_mathml_free_string($3);
999
  wims_mathml_free_string($3);
1001
};
1000
};
1002
 
1001
 
1003
fghighlight: FGHIGHLIGHT ATTRLIST closedTerm {
1002
fghighlight: FGHIGHLIGHT ATTRLIST closedTerm {
1004
  char * s1 = wims_mathml_copy3("<maction actiontype=\"highlight\" other=\"color=", $2, "\">");
1003
  char * s1 = wims_mathml_copy3("<maction actiontype=\"highlight\" other=\"color=", $2, "\">");
1005
  $$ = wims_mathml_copy3(s1, $3, "</maction>");
1004
  $$ = wims_mathml_copy3(s1, $3, "</maction>");
Line 1048... Line 1047...
1048
    int found_right = 0;
1047
    int found_right = 0;
1049
    int cnt=0;
1048
    int cnt=0;
1050
    char tmp[2];
1049
    char tmp[2];
1051
    int i;
1050
    int i;
1052
    for(i = 0 ; i < len ; i++){
1051
    for(i = 0 ; i < len ; i++){
1053
	if( yylval[i] == '{' ){
1052
  if( yylval[i] == '{' ){
1054
	    found_left=1;found_right=0;
1053
      found_left=1;found_right=0;
1055
	}
1054
  }
1056
	else
1055
  else
1057
	{
1056
  {
1058
	    if( yylval[i] == '}' ){
1057
      if( yylval[i] == '}' ){
1059
		cnt++;found_left=0;found_right=1;
1058
    cnt++;found_left=0;found_right=1;
1060
	    }
1059
      }
1061
	    else
1060
      else
1062
	    {
1061
      {
1063
		if(found_left == 1 && found_right == 0){
1062
    if(found_left == 1 && found_right == 0){
1064
		    tmp[0] = yylval[i];
1063
        tmp[0] = yylval[i];
1065
		    tmp[1] = '\0';
1064
        tmp[1] = '\0';
1066
		    switch (cnt){
1065
        switch (cnt){
1067
			case 0 : strncat(size,tmp,1);break;
1066
      case 0 : strncat(size,tmp,1);break;
1068
		        case 1 : strncat(id,tmp,1);break;
1067
            case 1 : strncat(id,tmp,1);break;
1069
		        case 2 : strncat(style,tmp,1);break;
1068
            case 2 : strncat(style,tmp,1);break;
1070
		        case 3 : strncat(value,tmp,1);break;
1069
            case 3 : strncat(value,tmp,1);break;
1071
		        case 4 : strncat(readonly,tmp,1);break;
1070
            case 4 : strncat(readonly,tmp,1);break;
1072
			default : break;
1071
      default : break;
1073
		    }
1072
        }
1074
		}	
1073
    } 
1075
	    }
1074
      }
1076
	}
1075
  }
1077
    }
1076
    }
1078
    $1 = wims_mathml_copy_string(size);
1077
    $1 = wims_mathml_copy_string(size);
1079
    char * s1 = wims_mathml_copy3("<mn><input type=\"text\"  size=\"",$1,"\" id=\"mathml");
1078
    char * s1 = wims_mathml_copy3("<mn><input type=\"text\"  size=\"",$1,"\" id=\"mathml");
1080
    $1 = wims_mathml_copy_string(id);
1079
    $1 = wims_mathml_copy_string(id);
1081
    s1 = wims_mathml_copy3(s1,$1,"\" value=\"");
1080
    s1 = wims_mathml_copy3(s1,$1,"\" value=\"");
1082
    $1 = wims_mathml_copy_string(value);
1081
    $1 = wims_mathml_copy_string(value);
1083
    s1 = wims_mathml_copy3(s1,$1,"\" style=\"");
1082
    s1 = wims_mathml_copy3(s1,$1,"\" style=\"");
1084
    if( strstr(readonly,"1") != NULL){
1083
    if( strstr(readonly,"1") != NULL){
1085
	$1 = wims_mathml_copy_string(style);
1084
  $1 = wims_mathml_copy_string(style);
1086
	s1 = wims_mathml_copy3(s1,$1,"\" ");
1085
  s1 = wims_mathml_copy3(s1,$1,"\" ");
1087
	s1 = wims_mathml_copy2(s1,"readonly /></mn>");
1086
  s1 = wims_mathml_copy2(s1,"readonly /></mn>");
1088
    }
1087
    }
1089
    else
1088
    else
1090
    {
1089
    {
1091
	$1 = wims_mathml_copy_string(style);
1090
  $1 = wims_mathml_copy_string(style);
1092
	s1 = wims_mathml_copy3(s1,$1,"\" /></mn>");
1091
  s1 = wims_mathml_copy3(s1,$1,"\" /></mn>");
1093
    }
1092
    }
1094
    $$ = wims_mathml_copy_string(s1);
1093
    $$ = wims_mathml_copy_string(s1);
1095
    wims_mathml_free_string(s1);
1094
    wims_mathml_free_string(s1);
1096
    wims_mathml_free_string($1);
1095
    wims_mathml_free_string($1);
1097
};
1096
};
Line 1364... Line 1363...
1364
subsupList: subsupTerm {
1363
subsupList: subsupTerm {
1365
  $$ = wims_mathml_copy_string($1);
1364
  $$ = wims_mathml_copy_string($1);
1366
  wims_mathml_free_string($1);
1365
  wims_mathml_free_string($1);
1367
}
1366
}
1368
| subsupList subsupTerm {
1367
| subsupList subsupTerm {
1369
  $$ = wims_mathml_copy3($1, " ", $2);
1368
  $$ = wims_mathml_copy3($1, " ", $2);
1370
  wims_mathml_free_string($1);
1369
  wims_mathml_free_string($1);
1371
  wims_mathml_free_string($2);
1370
  wims_mathml_free_string($2);
1372
};
1371
};
1373
 
1372
 
1374
subsupTerm: SUB closedTerm SUP closedTerm {
1373
subsupTerm: SUB closedTerm SUP closedTerm {
1375
  $$ = wims_mathml_copy3($2, " ", $4);
1374
  $$ = wims_mathml_copy3($2, " ", $4);
1376
  wims_mathml_free_string($2);
1375
  wims_mathml_free_string($2);
1377
  wims_mathml_free_string($4);
1376
  wims_mathml_free_string($4);
1378
}
1377
}
1379
| SUB closedTerm {
1378
| SUB closedTerm {
1380
  $$ = wims_mathml_copy2($2, " <none></none>");
1379
  $$ = wims_mathml_copy2($2, " <none></none>");
1381
  wims_mathml_free_string($2);
1380
  wims_mathml_free_string($2);
Line 1396... Line 1395...
1396
  wims_mathml_free_string($2);
1395
  wims_mathml_free_string($2);
1397
  wims_mathml_free_string($3);
1396
  wims_mathml_free_string($3);
1398
}
1397
}
1399
| FRAC closedTerm closedTerm {
1398
| FRAC closedTerm closedTerm {
1400
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"true\"><mfrac>", $2, $3);
1399
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"true\"><mfrac>", $2, $3);
1401
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle>");
1400
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle>");
1402
  wims_mathml_free_string(s1);
1401
  wims_mathml_free_string(s1);
1403
  wims_mathml_free_string($2);
1402
  wims_mathml_free_string($2);
1404
  wims_mathml_free_string($3);
1403
  wims_mathml_free_string($3);
1405
}
1404
}
1406
| TFRAC closedTerm closedTerm {
1405
| TFRAC closedTerm closedTerm {
1407
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"false\"><mfrac>", $2, $3);
1406
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"false\"><mfrac>", $2, $3);
1408
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle>");
1407
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle>");
1409
  wims_mathml_free_string(s1);
1408
  wims_mathml_free_string(s1);
1410
  wims_mathml_free_string($2);
1409
  wims_mathml_free_string($2);
1411
  wims_mathml_free_string($3);
1410
  wims_mathml_free_string($3);
1412
}
1411
}
1413
| SFRAC closedTerm closedTerm{
1412
| SFRAC closedTerm closedTerm{
1414
  $$ = wims_mathml_copy5("<mstyle scriptlevel=\"1\"><msup><mrow/>",$2,"</msup><msub><mo lspace=\"verythinmathspace\" stretchy=\"true\">&#x2571;</mo>",$3,"</msub></mstyle>");
1413
  $$ = wims_mathml_copy5("<mstyle scriptlevel=\"1\"><msup><mrow/>",$2,"</msup><msub><mo lspace=\"verythinmathspace\" stretchy=\"true\">&#x2571;</mo>",$3,"</msub></mstyle>");
1415
  wims_mathml_free_string($2);
1414
  wims_mathml_free_string($2);
1416
  wims_mathml_free_string($3);
1415
  wims_mathml_free_string($3);
1417
};
1416
};
Line 1430... Line 1429...
1430
  wims_mathml_free_string($4);
1429
  wims_mathml_free_string($4);
1431
}
1430
}
1432
| MROWOPEN compoundTermList TEXOVER compoundTermList MROWCLOSE {
1431
| MROWOPEN compoundTermList TEXOVER compoundTermList MROWCLOSE {
1433
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"true\"><mfrac><mrow>", $2, "</mrow><mrow>");
1432
  char * s1 = wims_mathml_copy3("<mstyle displaystyle=\"true\"><mfrac><mrow>", $2, "</mrow><mrow>");
1434
  $$ = wims_mathml_copy3(s1, $4, "</mrow></mfrac></mstyle>");
1433
  $$ = wims_mathml_copy3(s1, $4, "</mrow></mfrac></mstyle>");
1435
  wims_mathml_free_string(s1);
1434
  wims_mathml_free_string(s1);
1436
  wims_mathml_free_string($2);
1435
  wims_mathml_free_string($2);
1437
  wims_mathml_free_string($4);
1436
  wims_mathml_free_string($4);
1438
}
1437
}
1439
| left compoundTermList TEXOVER compoundTermList right {
1438
| left compoundTermList TEXOVER compoundTermList right {
1440
  char * s1 = wims_mathml_copy3("<mrow>", $1, "<mstyle displaystyle=\"true\"><mfrac><mrow>");
1439
  char * s1 = wims_mathml_copy3("<mrow>", $1, "<mstyle displaystyle=\"true\"><mfrac><mrow>");
1441
  char * s2 = wims_mathml_copy3($2, "</mrow><mrow>", $4);
1440
  char * s2 = wims_mathml_copy3($2, "</mrow><mrow>", $4);
1442
  char * s3 = wims_mathml_copy3("</mrow></mfrac></mstyle>", $5, "</mrow>");
1441
  char * s3 = wims_mathml_copy3("</mrow></mfrac></mstyle>", $5, "</mrow>");
1443
  $$ = wims_mathml_copy3(s1, s2, s3);
1442
  $$ = wims_mathml_copy3(s1, s2, s3);
1444
  wims_mathml_free_string(s1);
1443
  wims_mathml_free_string(s1);
1445
  wims_mathml_free_string(s2);
1444
  wims_mathml_free_string(s2);
1446
  wims_mathml_free_string(s3);
1445
  wims_mathml_free_string(s3);
1447
  wims_mathml_free_string($1);
1446
  wims_mathml_free_string($1);
1448
  wims_mathml_free_string($2);
1447
  wims_mathml_free_string($2);
1449
  wims_mathml_free_string($4);
1448
  wims_mathml_free_string($4);
1450
  wims_mathml_free_string($5);
1449
  wims_mathml_free_string($5);
1451
};
1450
};
1452
 
1451
 
1453
texatop: MROWOPEN compoundTermList TEXATOP compoundTermList MROWCLOSE {
1452
texatop: MROWOPEN compoundTermList TEXATOP compoundTermList MROWCLOSE {
1454
  char * s1 = wims_mathml_copy3("<mfrac linethickness=\"0\"><mrow>", $2, "</mrow><mrow>");
1453
  char * s1 = wims_mathml_copy3("<mfrac linethickness=\"0\"><mrow>", $2, "</mrow><mrow>");
Line 1460... Line 1459...
1460
| left compoundTermList TEXATOP compoundTermList right {
1459
| left compoundTermList TEXATOP compoundTermList right {
1461
  char * s1 = wims_mathml_copy3("<mrow>", $1, "<mfrac linethickness=\"0\"><mrow>");
1460
  char * s1 = wims_mathml_copy3("<mrow>", $1, "<mfrac linethickness=\"0\"><mrow>");
1462
  char * s2 = wims_mathml_copy3($2, "</mrow><mrow>", $4);
1461
  char * s2 = wims_mathml_copy3($2, "</mrow><mrow>", $4);
1463
  char * s3 = wims_mathml_copy3("</mrow></mfrac>", $5, "</mrow>");
1462
  char * s3 = wims_mathml_copy3("</mrow></mfrac>", $5, "</mrow>");
1464
  $$ = wims_mathml_copy3(s1, s2, s3);
1463
  $$ = wims_mathml_copy3(s1, s2, s3);
1465
  wims_mathml_free_string(s1);
1464
  wims_mathml_free_string(s1);
1466
  wims_mathml_free_string(s2);
1465
  wims_mathml_free_string(s2);
1467
  wims_mathml_free_string(s3);
1466
  wims_mathml_free_string(s3);
1468
  wims_mathml_free_string($1);
1467
  wims_mathml_free_string($1);
1469
  wims_mathml_free_string($2);
1468
  wims_mathml_free_string($2);
1470
  wims_mathml_free_string($4);
1469
  wims_mathml_free_string($4);
1471
  wims_mathml_free_string($5);
1470
  wims_mathml_free_string($5);
1472
};
1471
};
1473
 
1472
 
1474
binom: BINOM closedTerm closedTerm {
1473
binom: BINOM closedTerm closedTerm {
1475
  char * s1 = wims_mathml_copy3("<mrow><mo>(</mo><mfrac linethickness=\"0\">", $2, $3);
1474
  char * s1 = wims_mathml_copy3("<mrow><mo>(</mo><mfrac linethickness=\"0\">", $2, $3);
1476
  $$ = wims_mathml_copy2(s1, "</mfrac><mo>)</mo></mrow>");
1475
  $$ = wims_mathml_copy2(s1, "</mfrac><mo>)</mo></mrow>");
1477
  wims_mathml_free_string(s1);
1476
  wims_mathml_free_string(s1);
1478
  wims_mathml_free_string($2);
1477
  wims_mathml_free_string($2);
1479
  wims_mathml_free_string($3);
1478
  wims_mathml_free_string($3);
1480
}
1479
}
1481
| TBINOM closedTerm closedTerm {
1480
| TBINOM closedTerm closedTerm {
1482
  char * s1 = wims_mathml_copy3("<mrow><mo>(</mo><mstyle displaystyle=\"false\"><mfrac linethickness=\"0\">", $2, $3);
1481
  char * s1 = wims_mathml_copy3("<mrow><mo>(</mo><mstyle displaystyle=\"false\"><mfrac linethickness=\"0\">", $2, $3);
1483
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle><mo>)</mo></mrow>");
1482
  $$ = wims_mathml_copy2(s1, "</mfrac></mstyle><mo>)</mo></mrow>");
Line 1491... Line 1490...
1491
  wims_mathml_free_string($2);
1490
  wims_mathml_free_string($2);
1492
};
1491
};
1493
 
1492
 
1494
munderline: UNDERLINE closedTerm {
1493
munderline: UNDERLINE closedTerm {
1495
  $$ = wims_mathml_copy3("<munder>", $2, "<mo>&#x00332;</mo></munder>");
1494
  $$ = wims_mathml_copy3("<munder>", $2, "<mo>&#x00332;</mo></munder>");
1496
  wims_mathml_free_string($2);
1495
  wims_mathml_free_string($2);
1497
};
1496
};
1498
 
1497
 
1499
moverbrace: OVERBRACE closedTerm {
1498
moverbrace: OVERBRACE closedTerm {
1500
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&OverBrace;</mo></mover>");
1499
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&OverBrace;</mo></mover>");
1501
  wims_mathml_free_string($2);
1500
  wims_mathml_free_string($2);
1502
};
1501
};
Line 1552... Line 1551...
1552
  $$ = wims_mathml_copy3("<mover>", $2, "<mo stretchy=\"false\">&#x2c7;</mo></mover>");
1551
  $$ = wims_mathml_copy3("<mover>", $2, "<mo stretchy=\"false\">&#x2c7;</mo></mover>");
1553
  wims_mathml_free_string($2);
1552
  wims_mathml_free_string($2);
1554
}
1553
}
1555
| WIDECHECK closedTerm {
1554
| WIDECHECK closedTerm {
1556
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&#x2c7;</mo></mover>");
1555
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&#x2c7;</mo></mover>");
1557
  wims_mathml_free_string($2);
1556
  wims_mathml_free_string($2);
1558
};
1557
};
1559
 
1558
 
1560
hat: HAT closedTerm {
1559
hat: HAT closedTerm {
1561
  $$ = wims_mathml_copy3("<mover>", $2, "<mo stretchy=\"false\">&#x5E;</mo></mover>");
1560
  $$ = wims_mathml_copy3("<mover>", $2, "<mo stretchy=\"false\">&#x5E;</mo></mover>");
1562
  wims_mathml_free_string($2);
1561
  wims_mathml_free_string($2);
1563
}
1562
}
1564
| WIDEHAT closedTerm {
1563
| WIDEHAT closedTerm {
1565
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&#x5E;</mo></mover>");
1564
  $$ = wims_mathml_copy3("<mover>", $2, "<mo>&#x5E;</mo></mover>");
1566
  wims_mathml_free_string($2);
1565
  wims_mathml_free_string($2);
1567
};
1566
};
1568
 
1567
 
1569
msqrt: SQRT closedTerm {
1568
msqrt: SQRT closedTerm {
1570
  $$ = wims_mathml_copy3("<msqrt>", $2, "</msqrt>");
1569
  $$ = wims_mathml_copy3("<msqrt>", $2, "</msqrt>");
1571
  wims_mathml_free_string($2);
1570
  wims_mathml_free_string($2);
1572
};
1571
};
1573
 
1572
 
1574
mroot: SQRT OPTARGOPEN compoundTermList OPTARGCLOSE closedTerm {
1573
mroot: SQRT OPTARGOPEN compoundTermList OPTARGCLOSE closedTerm {
1575
  char * s1 = wims_mathml_copy3("<mroot>", $5, $3);
1574
  char * s1 = wims_mathml_copy3("<mroot>", $5, $3);
1576
  $$ = wims_mathml_copy2(s1, "</mroot>");
1575
  $$ = wims_mathml_copy2(s1, "</mroot>");
Line 1585... Line 1584...
1585
  wims_mathml_free_string($2);
1584
  wims_mathml_free_string($2);
1586
  wims_mathml_free_string($3);
1585
  wims_mathml_free_string($3);
1587
};
1586
};
1588
 
1587
 
1589
raisebox: RAISEBOX TEXTSTRING TEXTSTRING TEXTSTRING closedTerm {
1588
raisebox: RAISEBOX TEXTSTRING TEXTSTRING TEXTSTRING closedTerm {
1590
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"", $2, "\" height=\"");
1589
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"", $2, "\" height=\"");
1591
  char * s2 = wims_mathml_copy3(s1, $3, "\" depth=\"");
1590
  char * s2 = wims_mathml_copy3(s1, $3, "\" depth=\"");
1592
  char * s3 = wims_mathml_copy3(s2, $4, "\">");
1591
  char * s3 = wims_mathml_copy3(s2, $4, "\">");
1593
  $$ = wims_mathml_copy3(s3, $5, "</mpadded>");
1592
  $$ = wims_mathml_copy3(s3, $5, "</mpadded>");
1594
  wims_mathml_free_string(s1);
1593
  wims_mathml_free_string(s1);
1595
  wims_mathml_free_string(s2);
1594
  wims_mathml_free_string(s2);
1596
  wims_mathml_free_string(s3);
1595
  wims_mathml_free_string(s3);
1597
  wims_mathml_free_string($2);
1596
  wims_mathml_free_string($2);
1598
  wims_mathml_free_string($3);
1597
  wims_mathml_free_string($3);
1599
  wims_mathml_free_string($4);
1598
  wims_mathml_free_string($4);
1600
  wims_mathml_free_string($5);
1599
  wims_mathml_free_string($5);
1601
}
1600
}
1602
| RAISEBOX NEG TEXTSTRING TEXTSTRING TEXTSTRING closedTerm {
1601
| RAISEBOX NEG TEXTSTRING TEXTSTRING TEXTSTRING closedTerm {
1603
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"-", $3, "\" height=\"");
1602
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"-", $3, "\" height=\"");
1604
  char * s2 = wims_mathml_copy3(s1, $4, "\" depth=\"");
1603
  char * s2 = wims_mathml_copy3(s1, $4, "\" depth=\"");
1605
  char * s3 = wims_mathml_copy3(s2, $5, "\">");
1604
  char * s3 = wims_mathml_copy3(s2, $5, "\">");
1606
  $$ = wims_mathml_copy3(s3, $6, "</mpadded>");
1605
  $$ = wims_mathml_copy3(s3, $6, "</mpadded>");
1607
  wims_mathml_free_string(s1);
1606
  wims_mathml_free_string(s1);
1608
  wims_mathml_free_string(s2);
1607
  wims_mathml_free_string(s2);
1609
  wims_mathml_free_string(s3);
1608
  wims_mathml_free_string(s3);
1610
  wims_mathml_free_string($3);
1609
  wims_mathml_free_string($3);
1611
  wims_mathml_free_string($4);
1610
  wims_mathml_free_string($4);
1612
  wims_mathml_free_string($5);
1611
  wims_mathml_free_string($5);
1613
  wims_mathml_free_string($6);
1612
  wims_mathml_free_string($6);
1614
}
1613
}
1615
| RAISEBOX TEXTSTRING TEXTSTRING closedTerm {
1614
| RAISEBOX TEXTSTRING TEXTSTRING closedTerm {
1616
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"", $2, "\" height=\"");
1615
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"", $2, "\" height=\"");
1617
  char * s2 = wims_mathml_copy3(s1, $3, "\" depth=\"depth\">");
1616
  char * s2 = wims_mathml_copy3(s1, $3, "\" depth=\"depth\">");
1618
  $$ = wims_mathml_copy3(s2, $4, "</mpadded>");
1617
  $$ = wims_mathml_copy3(s2, $4, "</mpadded>");
1619
  wims_mathml_free_string(s1);
1618
  wims_mathml_free_string(s1);
1620
  wims_mathml_free_string(s2);
1619
  wims_mathml_free_string(s2);
1621
  wims_mathml_free_string($2);
1620
  wims_mathml_free_string($2);
1622
  wims_mathml_free_string($3);
1621
  wims_mathml_free_string($3);
1623
  wims_mathml_free_string($4);
1622
  wims_mathml_free_string($4);
1624
}
1623
}
1625
| RAISEBOX NEG TEXTSTRING TEXTSTRING closedTerm {
1624
| RAISEBOX NEG TEXTSTRING TEXTSTRING closedTerm {
1626
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"-", $3, "\" height=\"");
1625
  char * s1 = wims_mathml_copy3("<mpadded voffset=\"-", $3, "\" height=\"");
Line 2069... Line 2068...
2069
 
2068
 
2070
  void (*save_error_fn) (const char * msg) = wims_mathml_error;
2069
  void (*save_error_fn) (const char * msg) = wims_mathml_error;
2071
 
2070
 
2072
  wims_mathml_error = wims_mathml_keep_error;
2071
  wims_mathml_error = wims_mathml_keep_error;
2073
 
2072
 
2074
 _until_math:
2073
  _until_math:
2075
  ptr2 = ptr1;
2074
  ptr2 = ptr1;
2076
 
2075
 
2077
  while (ptr2 < end)
2076
  while (ptr2 < end)
-
 
2077
  {
-
 
2078
    if (*ptr2 == '$') break;
-
 
2079
    if ((*ptr2 == '\\') && (ptr2 + 1 < end))
2078
    {
2080
    {
2079
      if (*ptr2 == '$') break;
-
 
2080
      if ((*ptr2 == '\\') && (ptr2 + 1 < end))
-
 
2081
	{
-
 
2082
	  if (*(ptr2+1) == '[') break;
2081
      if (*(ptr2+1) == '[') break;
2083
	}
-
 
2084
      ++ptr2;
-
 
2085
    }
2082
    }
-
 
2083
    ++ptr2;
-
 
2084
  }
2086
  if (wims_mathml_write && ptr2 > ptr1)
2085
  if (wims_mathml_write && ptr2 > ptr1)
2087
    (*wims_mathml_write) (ptr1, ptr2 - ptr1);
2086
    (*wims_mathml_write) (ptr1, ptr2 - ptr1);
2088
 
2087
 
2089
  if (ptr2 == end) goto _finish;
2088
  if (ptr2 == end) goto _finish;
2090
 
2089
 
2091
 _until_html:
2090
  _until_html:
2092
  ptr1 = ptr2;
2091
  ptr1 = ptr2;
2093
 
2092
 
2094
  if (ptr2 + 1 < end)
2093
  if (ptr2 + 1 < end)
2095
    {
2094
  {
2096
      if ((*ptr2 == '\\') && (*(ptr2+1) == '['))
2095
    if ((*ptr2 == '\\') && (*(ptr2+1) == '['))
2097
	{
2096
    {
2098
	  type = ITEX_DELIMITER_SQUARE;
2097
      type = ITEX_DELIMITER_SQUARE;
2099
	  ptr2 += 2;
2098
      ptr2 += 2;
2100
	}
2099
    }
2101
      else if ((*ptr2 == '$') && (*(ptr2+1) == '$'))
2100
    else if ((*ptr2 == '$') && (*(ptr2+1) == '$'))
2102
	{
2101
    {
2103
	  type = ITEX_DELIMITER_DOUBLE;
2102
      type = ITEX_DELIMITER_DOUBLE;
2104
	  ptr2 += 2;
2103
      ptr2 += 2;
2105
	}
2104
    }
2106
      else
2105
    else
2107
	{
2106
    {
2108
	  type = ITEX_DELIMITER_DOLLAR;
2107
      type = ITEX_DELIMITER_DOLLAR;
2109
	  ptr2 += 2;
2108
      ptr2 += 2;
2110
	}
2109
    }
2111
    }
2110
  }
2112
  else goto _finish;
2111
  else goto _finish;
2113
 
2112
 
2114
  skip = 0;
2113
  skip = 0;
2115
  match = 0;
2114
  match = 0;
2116
 
2115
 
2117
  while (ptr2 < end)
2116
  while (ptr2 < end)
-
 
2117
  {
-
 
2118
    switch (*ptr2)
2118
    {
2119
    {
2119
      switch (*ptr2)
-
 
2120
	{
-
 
2121
	case '<':
2120
    case '<':
2122
	case '>':
2121
    case '>':
2123
	  if (forbid_markup == 1) skip = 1;
2122
      if (forbid_markup == 1) skip = 1;
2124
	  break;
2123
      break;
2125
 
2124
 
2126
	case '\\':
2125
    case '\\':
2127
	  if (ptr2 + 1 < end)
2126
      if (ptr2 + 1 < end)
2128
	    {
2127
      {
2129
	      if (*(ptr2 + 1) == '[')
2128
        if (*(ptr2 + 1) == '[')
2130
		{
2129
        {
2131
		  skip = 1;
2130
          skip = 1;
2132
		}
2131
        }
2133
	      else if (*(ptr2 + 1) == ']')
2132
        else if (*(ptr2 + 1) == ']')
2134
		{
2133
        {
2135
		  if (type == ITEX_DELIMITER_SQUARE)
2134
          if (type == ITEX_DELIMITER_SQUARE)
2136
		    {
2135
          {
2137
		      ptr2 += 2;
2136
            ptr2 += 2;
2138
		      match = 1;
2137
            match = 1;
2139
		    }
2138
          }
2140
		  else
2139
          else
2141
		    {
2140
          {
2142
		      skip = 1;
2141
            skip = 1;
2143
		    }
2142
          }
2144
		}
2143
        }
2145
	    }
2144
      }
2146
	  break;
2145
      break;
2147
 
2146
 
2148
	case '$':
2147
    case '$':
2149
	  if (type == ITEX_DELIMITER_SQUARE)
2148
      if (type == ITEX_DELIMITER_SQUARE)
2150
	    {
2149
      {
2151
	      skip = 1;
2150
        skip = 1;
2152
	    }
2151
      }
2153
	  else if (ptr2 + 1 < end)
2152
      else if (ptr2 + 1 < end)
2154
	    {
2153
      {
2155
	      if (*(ptr2 + 1) == '$')
2154
        if (*(ptr2 + 1) == '$')
2156
		{
2155
        {
2157
		  if (type == ITEX_DELIMITER_DOLLAR)
2156
          if (type == ITEX_DELIMITER_DOLLAR)
2158
		    {
2157
          {
2159
		      ptr2++;
2158
            ptr2++;
2160
		      match = 1;
2159
            match = 1;
2161
		    }
2160
          }
2162
		  else
2161
          else
2163
		    {
2162
          {
2164
		      ptr2 += 2;
2163
            ptr2 += 2;
2165
		      match = 1;
2164
            match = 1;
2166
		    }
2165
          }
2167
		}
2166
        }
2168
	      else
2167
        else
2169
		{
2168
        {
2170
		  if (type == ITEX_DELIMITER_DOLLAR)
2169
          if (type == ITEX_DELIMITER_DOLLAR)
2171
		    {
2170
          {
2172
		      ptr2++;
2171
            ptr2++;
2173
		      match = 1;
2172
            match = 1;
2174
		    }
2173
          }
2175
		  else
2174
          else
2176
		    {
2175
          {
2177
		      skip = 1;
2176
            skip = 1;
2178
		    }
-
 
2179
		}
-
 
2180
	    }
-
 
2181
	  else
-
 
2182
	    {
-
 
2183
	      if (type == ITEX_DELIMITER_DOLLAR)
-
 
2184
		{
-
 
2185
		  ptr2++;
-
 
2186
		  match = 1;
-
 
2187
		}
-
 
2188
	      else
2177
          }
2189
		{
-
 
2190
		  skip = 1;
-
 
2191
		}
-
 
2192
	    }
2178
        }
2193
	  break;
-
 
2194
 
-
 
2195
	default:
-
 
2196
	  break;
-
 
2197
	}
-
 
2198
      if (skip || match) break;
-
 
2199
 
-
 
2200
      ++ptr2;
-
 
2201
    }
2179
      }
2202
  if (skip)
-
 
2203
    {
-
 
2204
      if (type == ITEX_DELIMITER_DOLLAR)
-
 
2205
	{
-
 
2206
	  if (wims_mathml_write)
-
 
2207
	    (*wims_mathml_write) (ptr1, 1);
-
 
2208
	  ptr1++;
-
 
2209
	}
-
 
2210
      else
2180
      else
2211
	{
2181
      {
-
 
2182
        if (type == ITEX_DELIMITER_DOLLAR)
-
 
2183
        {
-
 
2184
          ptr2++;
2212
	  if (wims_mathml_write)
2185
          match = 1;
-
 
2186
        }
-
 
2187
        else
-
 
2188
        {
2213
	    (*wims_mathml_write) (ptr1, 2);
2189
          skip = 1;
-
 
2190
        }
-
 
2191
      }
2214
	  ptr1 += 2;
2192
      break;
2215
	}
2193
 
-
 
2194
    default:
2216
      goto _until_math;
2195
      break;
2217
    }
2196
    }
-
 
2197
    if (skip || match) break;
-
 
2198
 
-
 
2199
    ++ptr2;
-
 
2200
  }
-
 
2201
  if (skip)
-
 
2202
  {
-
 
2203
    if (type == ITEX_DELIMITER_DOLLAR)
-
 
2204
    {
-
 
2205
      if (wims_mathml_write)
-
 
2206
        (*wims_mathml_write) (ptr1, 1);
-
 
2207
      ptr1++;
-
 
2208
    }
-
 
2209
    else
-
 
2210
    {
-
 
2211
      if (wims_mathml_write)
-
 
2212
        (*wims_mathml_write) (ptr1, 2);
-
 
2213
      ptr1 += 2;
-
 
2214
    }
-
 
2215
    goto _until_math;
-
 
2216
  }
2218
  if (match)
2217
  if (match)
-
 
2218
  {
-
 
2219
    mathml = wims_mathml_parse (ptr1, ptr2 - ptr1);
-
 
2220
    if (mathml)
2219
    {
2221
    {
2220
      mathml = wims_mathml_parse (ptr1, ptr2 - ptr1);
-
 
2221
 
-
 
2222
      if (mathml)
-
 
2223
	{
-
 
2224
	  if (wims_mathml_write_mathml)
2222
      if (wims_mathml_write_mathml)
2225
	    (*wims_mathml_write_mathml) (mathml);
2223
        (*wims_mathml_write_mathml) (mathml);
2226
	  wims_mathml_free_string (mathml);
2224
      wims_mathml_free_string (mathml);
2227
	  mathml = 0;
2225
      mathml = 0;
2228
	}
2226
    }
2229
      else
2227
    else
2230
	{
2228
    {
2231
	  ++result;
2229
      ++result;
2232
	  if (wims_mathml_write)
2230
      if (wims_mathml_write)
2233
	    {
2231
      {
2234
	      if (type == ITEX_DELIMITER_DOLLAR)
2232
        if (type == ITEX_DELIMITER_DOLLAR)
2235
		(*wims_mathml_write) ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"inline\"><merror><mtext>", 0);
2233
          (*wims_mathml_write) ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"inline\"><merror><mtext>", 0);
2236
	      else
2234
        else
2237
		(*wims_mathml_write) ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><merror><mtext>", 0);
2235
          (*wims_mathml_write) ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><merror><mtext>", 0);
2238
 
-
 
2239
	      (*wims_mathml_write) (wims_mathml_last_error, 0);
2236
          (*wims_mathml_write) (wims_mathml_last_error, 0);
2240
	      (*wims_mathml_write) ("</mtext></merror></math>", 0);
2237
          (*wims_mathml_write) ("</mtext></merror></math>", 0);
2241
	    }
2238
        }
2242
	}
-
 
2243
      ptr1 = ptr2;
-
 
2244
 
-
 
2245
      goto _until_math;
-
 
2246
    }
2239
    }
-
 
2240
    ptr1 = ptr2;
-
 
2241
 
-
 
2242
    goto _until_math;
-
 
2243
  }
2247
  if (wims_mathml_write)
2244
  if (wims_mathml_write)
2248
    (*wims_mathml_write) (ptr1, ptr2 - ptr1);
2245
    (*wims_mathml_write) (ptr1, ptr2 - ptr1);
2249
 
2246
 
2250
 _finish:
2247
  _finish:
2251
  if (wims_mathml_last_error)
2248
  if (wims_mathml_last_error)
2252
    {
2249
  {
2253
      wims_mathml_free_string (wims_mathml_last_error);
2250
    wims_mathml_free_string (wims_mathml_last_error);
2254
      wims_mathml_last_error = 0;
2251
    wims_mathml_last_error = 0;
2255
    }
2252
  }
2256
  wims_mathml_error = save_error_fn;
2253
  wims_mathml_error = save_error_fn;
2257
 
2254
 
2258
  return result;
2255
  return result;
2259
}
2256
}