%option nounput noinput %{ #define MAXLINE 80 int car_pos=0; void NL() { printf("\n"); car_pos=0; } %} SP [[:space:]] CAR [^[:space:]] %% ^{SP}+ ; \n\n NL();NL(); \n ; {SP}+ { if (car_pos!=MAXLINE-1) {printf(" "); car_pos++; }} /* nb : il reste des blancs en fin de ligne */ {CAR}+ { if ((car_pos+yyleng)>MAXLINE-1) NL(); printf("%s",yytext); car_pos+=yyleng;} . { ECHO; car_pos++;} %% int yywrap(void) { return 1; } int main(int argc, char *argv[]) { while (yylex()!=0) ; return 0; }