%option nounput noinput %{ #ifdef FLEXALONE /* Mode flex seul */ enum Return_Token_Values { WORD=1000, MAJWORD, MINWORD, QUOTED}; #else /* couplage flex/bison */ #include "yyparse.h" #endif #include "proto-color.h" void echo(char *lex_cat) { fprintf(stdout,GREEN("[%s:%s]"), lex_cat, yytext); } void echonl() { fprintf(stdout,GREEN("[\\n]")"\n"); } %} LETTRE [[:lower:][:upper:]] %% [[:upper:]]{LETTRE}* { echo("MajWord"); return MAJWORD; } [[:lower:]]{LETTRE}* { echo("MinWord"); return MINWORD; } \"[^ \n]*\" { echo("Quoted"); return QUOTED; } \.|\, { echo("PUNCT"); return yytext[0];} [ \t] { ECHO; } \n {echonl();} . { ECHO;} %% int yywrap (void) {return 1;} #ifdef FLEXALONE int main(int argc, char *argv[]) { while (yylex()!=0) ; return 0; } #endif