%{ #define set_estado(x) BEGIN(_stack[_i]=x) #define push_to_stack(x) _stack[++_i]=YY_START; set_estado(x) #define pop_back set_estado(_stack[--_i]) #include #include #define MAX 1000 int _i=0; int _stack[MAX]; int i; int cont_idmat=19; %} LETRA [a-zA-Z\.:] OP [\+\-=] NUMINT [0-9]+ NUMREAL ({NUMINT}(\.|,){NUMINT}*)+ BLANK [\n\t ] %Start e1 e2 e3 e4 e5 %% set_estado(e1); \{BLANK}*({LETRA}|{NUMINT})+{BLANK}*(({LETRA}|{NUMINT})*{BLANK}*)+\<\/matematica\> {printf("\n"); i=12; while(yytext[i]!='<'){ printf("%c", yytext[i]); i++; } printf("\n"); } \{BLANK}*{OP}*{BLANK}*({NUMINT}|{NUMREAL})*{BLANK}*{LETRA}*{BLANK}*{OP}*({NUMINT}|{NUMREAL})*{BLANK}*\<\/matematica\> {printf("\n"); i=12; while(yytext[i]!='<'){ printf("%c", yytext[i]); i++; } printf("\n"); } \{BLANK}*\\ast{BLANK}*\<\/matematica\> printf("*"); \{BLANK}*{OP}*{BLANK}*({LETRA}|{NUMINT}|{NUMREAL})+{BLANK}*(({OP}|<|>)+{BLANK}*({LETRA}|{NUMINT}|{NUMREAL})+{BLANK}*)+\<\/matematica\> {printf("\n"); i=12; while(yytext[i]!='<'){ printf("%c", yytext[i]); i++; } printf("\n"); } \{BLANK}*\\n\<\/displaymat\> {printf(""); pop_back;} \\n {printf("", cont_idmat++); push_to_stack(e5);} \<\/displaymat\> {printf(""); pop_back;} \ printf("", cont_idmat++); %%