%option nounput noinput %{ #include "proto-color.h" void echo(char *lex_cat) { fprintf(stdout,GREEN("[%s:%s]"), lex_cat, yytext); } void echo1(char *lex_cat) { fprintf(stdout,REV(GREEN("[%s:%s]")), lex_cat, yytext); } void echo2(char *lex_cat) { fprintf(stdout,RED("[%s:%s]"), lex_cat, yytext); } %} OK (a.*|.*a) NOT ([^a](.*[^a])?) %% ^{OK}$ echo("OK"); ^{NOT}$ echo1("NOT"); \n ECHO; ^[ab]*$ echo2("UNK"); .* echo2("UNK"); %% int yywrap(void) { return 1; } int main(int argc, char *argv[]) { while (yylex()!=0) ; return 0; }