%{ #include "y.tab.h" #include "readlinejj" void erro(char * s); %} %x Indices Condicao %option yylineno %% [a-zA-Z][a-zA-Z]* { yylval.string = strdup(yytext); return T; } [ \t] { } [?=.*()}\]\n] { return yytext[0]; } [\[] { BEGIN Indices; return yytext[0]; } [\{] { BEGIN Condicao; return yytext[0]; } [^\]]+ { BEGIN 0; yylval.string = strdup(yytext); return Ids; } [^}]+ { BEGIN 0; yylval.string = strdup(yytext); return Cond; } . { erro("Caracter inválido"); } %% int yywrap(){ return 1; } void erro(char * s) { fprintf(stderr,"# %d: Erro %s. '%s'\n",yylineno, s, yytext); }