%{ /* Prologue C */ #ifdef FLEXALONE enum Return_Token_Values { NEWLINE=1000, BYE, HELLO, THANKS, FUCK, CMD_SEP}; #else #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,BLUE("[\\n]")"\n"); } %} /*end Prologue C */ /* Options Flex*/ %option nounput noinput /* Macro-Definition */ newline \n|\r|\r\n cmd_sep [;] blanc [ \t] comment [#|@].* %% hi|hello echo("Builtin"); return(HELLO); thanks echo("Builtin"); return(THANKS); fuck|shit|"3-" echo("Builtin"); return(FUCK); bye|quit|exit echo("Builtin"); return(BYE); {newline} echonl(); return(NEWLINE); {cmd_sep} echo("Cmd_Sep"); return(CMD_SEP); {blanc} echo("Blancs "); {comment} echo("Comment"); . echo("Unknown"); return(yytext[0]); %% int yywrap (void) {return 1;} #ifdef FLEXALONE int main(int argc, char *argv[]) { while (yylex()!=0) ; return 0; } #endif