%{ #include #include //counter int measures = 0; %} %option yylineno %option outfile = "text-abcfilter.c" %option noyywrap %x ABC %% \ {BEGIN(ABC);} "||" {measures++;} "|" {measures++;} \<\/abc\> {BEGIN(INITIAL);} <*>.|\n {;} <> { int newState; if(measures==0) newState=0; else newState=1; fprintf(stdout,"%d",newState); return 0; } %% void yyerror(char *s){ fprintf(stderr,"ERRO (linha %d):antes de '%s'\n-%s",yylineno, yytext,s); } int main( int argc, char **argv ) { ++argv, --argc; if ( argc > 0 ){ yyin = fopen( argv[0], "r" ); } else{ yyin = stdin; } yylex(); return 0; }