%{ /*------------------------------------------------------------------- # # # # # # # ###### # # # #### #### # # ## # # # # # # # # # # # # # # # # ##### ## # # # # ####### # # # ### # # ## # # # # # # # ## ### # # # # # # # # # # # # # ### ####### ###### # # # #### #### Versao <%M%%I%(%E%)> -------------------------------------------------------------------*/ char *versao_lex="@(#) Versao <%M%%I%(%E%)>"; void comentario(); void poe_directo(); #include #if INTERACTIVE || FUNC #ifndef PIPE #if !FUNC #include #endif /*!FUNC */ #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ { \ int c = jjgetc( yyin ); \ result = c == EOF ? 0 : 1; \ buf[0] = (char) c; \ } static char* line_read = (char *)NULL; #ifdef FUNC extern char * S_GLOBI; static int jjgetc(fp) FILE * fp; { static int p=0; if(line_read == (char *)NULL) { line_read=S_GLOBI; p=0; } if(*(line_read+p) == '\0') return EOF; else return(*(line_read+(p++))); } #else /* FUNC */ int do_gets() { int ret; if(line_read != (char *)NULL) { free (line_read); line_read=(char *) NULL; } if(setjmp( xljmpbuf )) {exit(1) ;} ret=(int)(line_read = readline("?- ")); if(line_read && *line_read) add_history(line_read); return(ret); } static int jjgetc(fp) FILE * fp; { static int p=0; if((line_read == (char *)NULL) || (*(line_read+p) == '\0') ) { if(do_gets()== EOF) return EOF; p=0; return(10); } else return(*(line_read+(p++))); } #endif /* FUNC*/ #else /*PIPE */ #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ { \ int c = getchar(); \ result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ } #endif /*PIPE */ #endif /* INTERACTIVE */ int contachav; char mboxstr[200]; %} INT ([+-]?[0-9]+) STR (\"([^\"\n]|\\\")*\") BOOL (true|false) SIMBOLO ([a-zA-Z0-9\$\_\!áéíóúàâêôãõçÁÉÍÓÚÀÂÊÔÃÕÇ]+) QUOTE (\') CONS ({INT}|{STR}|{BOOL}|{QUOTE}{SIMBOLO}) %x metoo com pod mbox %o 5000 %a 4000 %p 3200 %% %{/*--(Codigo METOO)-----------------------------------------------------*/ %} ^metoo {BEGIN metoo;} ^endmetoo {BEGIN 0;} .* {poe_directo(yytext);} \n { #ifdef FLEX_SCANNER /* yylineno++; */ #endif } %{/*--(Includes)---------------------------------------------------------*/ %} ^#include {return(INCLUDE);} ^#debugon {return(DEBUGON);} ^#debugoff {return(DEBUGOFF);} ^#includemetoo {return(INCLUDEM);} %{/*--(Constantes: Int. String Bool Quote)-------------------------------*/ %} {INT} {yylval.str=strdup(yytext); return(INTEGER);} {STR} {yylval.str=strdup(yytext); return(STRING);} {BOOL} {yylval.str=strdup(yytext); return(BOOL);} {QUOTE}{SIMBOLO} {yylval.str=strdup(yytext); return(CONSTANTE);} %{/*--(Palavras reservadas)----------------------------------------------*/ %} deftype {return(DEFTYPE);} let {return(LET);} in {return(IN);} notin {return(NOTIN);} if {return(IF);} then {return(THEN);} else {return(ELSE);} otherwise {return(OTHER);} lambda {return(LAMBDA);} inv {return(INV);} PRE|pre {return(PRE);} U {return(UNION);} "&&"|\/\\ {return(AND);} "||"|\\\/ {return(OR);} "=>" {return(IMPLICA);} \* {return(INTER);} or {return(OR2);} NIL {return(NIL);} MODEL {return(MODEL);} ENDMODEL {return(ENDMODEL);} TYPE {return(TYPE);} ENDTYPE {return(ENDTYPE);} \*FUNC|\*func {yylval.str=strdup(yytext);return(FUNCAO);} FUNC|func {yylval.str="";return(FUNCAO);} STATE|state {return(ESTADO);} RETURN(S)?|return(s)? {return(RETUR);} all|ALL {return(ALL);} exist|EXIST {return(EXIST);} exist1|EXIST1 {return(EXIST1);} \-orio {return(ORIO);} \-red {return(ORIO);} \-list {return(LIST);} \-seq {return(LIST);} \-set {return(SET);} is\- {return(IS);} in\- {return(TIN);} out\- {return(TOUT);} id\- {return(ID);} \:\: {return(P4);} \=\= {return(EQ);} \~ {return(NOT);} \+ {return(PLUS);} \+\+ {return(STRCAT);} \.\+ {return(ADD);} \.\- {return(SUB);} \.\* {return(MUL);} \.\/ {return(DIV);} \<\-\> {return(RELACAO);} \<\- {return(PERTENCE);} _o_ {return(COMP);} _x_|×|\>\< {return(FPROD);} _\+_ {return(FADD);} \-\|\-_ {return(FADD);} _c {return(CONSF);} \-\> {return(SETA);} \-\>\* {return(FSETA);} \-\-\> {return(SSETA);} \*\-\> {return(FSETA2);} \>\= {return(GEQ);} \<\= {return(LEQ);} \!\= {return(NEQ);} \[\* {return(RELBEGIN);} \*\] {return(RELEND);} quit\. {return(QUIT);} \*\= {yylval.str=strdup(yytext);return('=');} !nl return NEWLINE; !caixa\( return BEGINARRAY; %{/*--(Simbolos)---------------------------------------------------------*/ %} do {yylval.str=strdup("progn"); return(SIMB);} bool|BOOL return(TBOOL); {SIMBOLO} {yylval.str=strdup(yytext); return(SIMB);} {QUOTE} {return(QUOTE);} %{/*--(Comentarios)------------------------------------------------------*/ %} \.\.\. { yylval.str = strdup("\\mbox{...}"); return(NYAVAIL);} nya\{ {BEGIN mbox; contachav = 1; strcpy(mboxstr,"\\mbox{\\it ");} nyavail\{ {BEGIN mbox; contachav = 1; strcpy(mboxstr,"\\mbox{");} \} { strcat(mboxstr,yytext); if(--contachav == 0) { BEGIN 0; yylval.str = strdup(mboxstr); return(NYAVAIL);}} \{ {contachav++; strcat(mboxstr,yytext);} \||\\\\|\n strcat(mboxstr, "}\\\\\\mbox{" ); . strcat(mboxstr,yytext); ^= {BEGIN pod;} ^=cut {BEGIN 0;} .|\n ; \= {yylval.str="" ;return('=');} \/\* {BEGIN com;} \*\/ {BEGIN 0;} .|\n ; ^\;.* { comentario(yytext);} ^\#\!.* { comentario(yytext);} %{/*--(outros)-----------------------------------------------------------*/ %} \n { #ifdef FLEX_SCANNER /* yylineno++; */ #endif } " "|" " ; > {if (in_sequence) return('>'); else return(GT);} . {return(yytext[0]);} %%