/itexToMML

To download this project, use:
bzr branch http://golem.ph.utexas.edu/~distler/code/itexToMML/

« back to all changes in this revision

Viewing changes to itex-src/itex2MML.l

  • Committer: Jacques Distler
  • Date: 2010-09-30 19:34:46 UTC
  • Revision ID: distler@golem.ph.utexas.edu-20100930193446-6joromf0at4k5nqv
Tags: 1.4.4
Nested Extensible Arrows

Now you can nest extensible arrows, with
optional arguments, in a LaTeX-compatible
fashion.

Show diffs side-by-side

added added

removed removed

1
 
/*             itex2MML 1.4.3
2
 
 *   itex2MML.l last modified 9/29/2010
 
1
/*             itex2MML 1.4.4
 
2
 *   itex2MML.l last modified 9/30/2010
3
3
 */
4
4
 
5
5
%{
20
20
static int s_itex2MML_read (char * buffer, int max_size);
21
21
 
22
22
#define yylval itex2MML_yylval
 
23
#define itex2MML_optarg_depth 100
23
24
 
24
25
extern char * yylval;
25
26
 
26
27
int itex2MML_lineno = 1;
27
 
int itex2MML_inoptarg = 0;
 
28
int itex2MML_inoptarg[itex2MML_optarg_depth];
 
29
int itex2MML_optarg_ind = 0;
28
30
 
29
31
int itex2MML_rowposn = 0;
30
32
int itex2MML_displaymode = 0;
 
33
 
31
34
%} 
32
35
%%
33
36
%{ if (itex2MML_rowposn==1) itex2MML_rowposn=0;
34
37
   if (itex2MML_rowposn==2) itex2MML_rowposn=1;
35
38
%}
36
39
 
37
 
<INITIAL>"$"{1,2}   BEGIN(MATH); itex2MML_rowposn=2; if (yyleng==2) { itex2MML_displaymode=1; return STARTDMATH;}; itex2MML_displaymode=0; return STARTMATH;
38
 
<INITIAL>"\\[" BEGIN(MATH); itex2MML_rowposn=2; itex2MML_displaymode=1; return STARTDMATH;
 
40
<INITIAL>"$"{1,2}   BEGIN(MATH); itex2MML_inoptarg[0] = 0; itex2MML_rowposn=2; if (yyleng==2) { itex2MML_displaymode=1; return STARTDMATH;}; itex2MML_displaymode=0; return STARTMATH;
 
41
<INITIAL>"\\[" BEGIN(MATH); itex2MML_inoptarg[0] = 0; itex2MML_rowposn=2; itex2MML_displaymode=1; return STARTDMATH;
39
42
<INITIAL>EOF    return 0;
40
43
<INITIAL>"\n" {itex2MML_lineno++; yylval=itex2MML_copy_string(yytext); return CHAR;}
41
44
<INITIAL>.     {yylval=itex2MML_copy_string(yytext); return CHAR;}
52
55
"^"            return SUP;
53
56
"_"            return SUB; 
54
57
"{"[\t\r\n ]*"}"   return EMPTYMROW;
55
 
"{"            {itex2MML_rowposn = 2; itex2MML_inoptarg = itex2MML_inoptarg*2; return MROWOPEN;}
56
 
"}"            {itex2MML_inoptarg = itex2MML_inoptarg/2; return MROWCLOSE;}
 
58
"{"            {itex2MML_rowposn = 2; itex2MML_inoptarg[itex2MML_optarg_ind] = itex2MML_inoptarg[itex2MML_optarg_ind]*2; return MROWOPEN;}
 
59
"}"            {itex2MML_inoptarg[itex2MML_optarg_ind] = itex2MML_inoptarg[itex2MML_optarg_ind]/2; return MROWCLOSE;}
57
60
 
58
61
"\\left"       itex2MML_rowposn=2; return LEFT;
59
62
"\\right"      return RIGHT;
101
104
"["             {yylval=itex2MML_copy_string(yytext); return LEFTDELIM;}
102
105
 
103
106
")"   {yylval=itex2MML_copy_string(yytext); return RIGHTDELIM;}
104
 
"]"   {if(itex2MML_inoptarg==1) {itex2MML_inoptarg=0; return OPTARGCLOSE;} else {yylval=itex2MML_copy_string(yytext); return RIGHTDELIM;}}
 
107
"]"   {if(itex2MML_inoptarg[itex2MML_optarg_ind]==1 && itex2MML_optarg_ind > 0) {itex2MML_inoptarg[itex2MML_optarg_ind]=0; itex2MML_optarg_ind--; return OPTARGCLOSE;} else {yylval=itex2MML_copy_string(yytext); return RIGHTDELIM;}}
105
108
 
106
109
"\\lbrace" |
107
110
"\\{"           {yylval=itex2MML_copy_string("{"); return LEFTDELIM;}
925
928
<ATTRIBUTELIST>"{"[ \t\n\r #a-zA-Z0-9.\-]*"}"  {BEGIN(MATH); yylval=itex2MML_copy_string(yytext); if (yylval != itex2MML_empty_string) { yylval[0]='"'; yylval[yyleng-1]='"'; } return ATTRLIST;}
926
929
 
927
930
<OPTARG>{
928
 
"[" {itex2MML_inoptarg=1; BEGIN(MATH); return OPTARGOPEN;}
 
931
"[" {if(itex2MML_optarg_ind < itex2MML_optarg_depth - 1 && itex2MML_inoptarg[itex2MML_optarg_ind] !=1 ){itex2MML_optarg_ind++; itex2MML_inoptarg[itex2MML_optarg_ind]=1;}; BEGIN(MATH); return OPTARGOPEN;}
929
932
.   {BEGIN(MATH); unput(yytext[0]);}
930
933
}
931
934