%{ #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 j=0,i=0; int _stack[MAX]; int cont_nota=1; int cont_refbib=0; int cont_item_lista; int cont_pag=0; int cont_titulo=0; int cont_subtit1=0; int cont_subtit2=0; int cont_subtit3=0; int cont_sec=0; char *refbibs[]={"FRS90","CAR89","YOU78","PES67","CUN66","FRA60","CUN38","JOA88","ANT90","FRE72","CUN38","PAL33","HEA81","QUE72","JOA88","BOY74","SMI59","OLI89","MUL36","GOL77","EUL96","GIU89","NEW11","MUL57a","JOA88","MAR87","JOA88","MUL57a","BEL56a","BEL56b","DUA87","DUA90a","DUA90b","QUE72"}; /* e1 - inicial e2 - pagina e3 - titulo e4 - sc e5 - em e6 - nota e7 - bibref e8 - subtit1 e9 - subtit2 e10 - subtit3 e11 - texto e12 - centrado e13 - realce_centrado e14 - realce e15 - italico e16 - lista e17 - supert e18 - parbox e19 - hfill e20 - ss e21 - minipage e22 - notesize e23 - matematica */ %} PALAVRA [a-zA-Z&0-9\[\]]+ BLANK [ \t\n] PONTUACAO [:\.;',?!\-_=] TEXTO ({BLANK}*{PALAVRA}{BLANK}*{PONTUACAO}*{BLANK}*{PONTUACAO}*)+ NUMINT [0-9]+ NUMREAL {NUMINT}\.{NUMINT} BIBS (\\[a-z]+) %Start e1 e2 e3 e4 e5 e6 e7 sair e8 e9 e10 e11 e12 e13 e14 e15 e16 e17 e18 e19 e20 e21 e22 e23 e90 %% set_estado(e1); (\\novapagina)|(\\newpage) { switch(cont_pag){ case 0: cont_pag++; break; case 5: printf("\n\n\n\n"); printf("\n\n\n\n"); cont_pag++; break; case 9: printf("\n"); break; default: printf("\n\n"); cont_pag++;} push_to_stack(e2); } \\desc\[aZZ='{BLANK}*'{PALAVRA} printf("\n\n"); \{\\Huge {printf(""); push_to_stack(e8);} \} {printf("\n");pop_back;} \\realce{BLANK}*\{{BLANK}*\{{BLANK}*\\Huge {printf(""); push_to_stack(e3);} \}\} {printf("\n");pop_back;} \\centrado{BLANK}*\{{BLANK}*\{{BLANK}*\\[lL]arge{BLANK}*\\realce{BLANK}*\{ {switch (cont_subtit2){ case 0: printf(""); cont_subtit2++; push_to_stack(e9); break; default:printf(""); push_to_stack(e9); }} \}\}\} {printf("\n");pop_back;} \\centrado{BLANK}*\{{BLANK}*\\[lL]arge{BLANK}*\{ {printf(""); push_to_stack(e10);} \}\} {printf("\n");pop_back;} \{\\large ; \\centrado\{ {printf(""); push_to_stack(e12);} \} {printf("");pop_back;} \\realce\{ {printf(""); push_to_stack(e13);} \} {printf("");pop_back;} {NUMINT}\.{BLANK}*\\realce\{ {switch(cont_sec){ case 0: printf("\n\n"); cont_sec++; printf("1. "); push_to_stack(e90); break; case 1: printf("\n\n"); cont_sec++; printf("2. "); push_to_stack(e90); break; case 2: printf("\n\n"); cont_sec++; printf("3. "); push_to_stack(e90); break;}} \} {printf("\n");pop_back;} \\realce\{ {printf(""); push_to_stack(e14);} \} {printf("");pop_back;} \\italico\{ {printf(""); push_to_stack(e15);} \} {printf("");pop_back;} \\parbox\{({NUMINT}|{NUMREAL})(cm)\}\{ push_to_stack(e18); \} pop_back; \\\( {printf("\n\n\n\n"); push_to_stack(e23);} \\\) {printf("\n\n\n\n"); pop_back;} \{\\notesize push_to_stack(e22); \} pop_back; \\hfill\{ push_to_stack(e19); \} pop_back; \\begin\{minipage\}\{{NUMREAL}\\textwidth\} {printf(""); push_to_stack(e21);} \\end\{minipage\} {printf("");pop_back;} \\ss{BLANK}*\{ push_to_stack(e20); \} pop_back; \\begin\{description\} {push_to_stack(e16); printf("");} \\item\{{BLANK}*{NUMINT}{BLANK}*{PONTUACAO}*{BLANK}*\} {if(cont_item_lista==0) printf(""); else printf(""); cont_item_lista++;} \\end\{description\} {printf("");pop_back;} ((\\supers)|(\\supert)|(\\super))\{ {printf(".");push_to_stack(e17);} \} pop_back; \{\\sc push_to_stack(e4); {TEXTO}(\n)*\} {i=0; while(yytext[i]!='}'){ if(yytext[i]!='&') printf("%c",toupper(yytext[i])); else{ printf("&"); printf("%c",toupper(yytext[i+1])); i=i+2; while(yytext[i]!=';'){ printf("%c",yytext[i]); i++; } printf("%c",yytext[i]); } i++; } pop_back; } \{\\em push_to_stack(e5); \} {i=0; while(yytext[i]!='}'){ printf("%c", yytext[i]); i++;} pop_back;} \\nota\{\{\\ss {printf("",cont_nota); printf("\n",cont_nota); cont_nota++; push_to_stack(e6); } {BLANK}*{BIBS}{BLANK}*(\.*)\}\} {printf("",refbibs[cont_refbib++]); i=0; while(yytext[i]!='}'){ printf("%c",yytext[i]); i++; } printf(""); pop_back; } ({BLANK}*{BIBS}{BLANK}*;{BLANK}*{BIBS}*{BLANK}*)+(\.*)\}\} {printf("",refbibs[cont_refbib++]); i=0; while(yytext[i]!= '}'){ if (yytext[i]!= ';') printf("%c", yytext[i]); else{ printf(";"); printf(""); printf("", refbibs[ cont_refbib++]); } i++; } yyless(0); push_to_stack(sair); } ({BLANK}*{BIBS}{BLANK}*;{BLANK}*{BIBS}*{BLANK}*)+(\.*)\}\} { printf(""); pop_back; pop_back;} %%