%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,RED("[%s:%s]"), lex_cat, yytext); } %} D [0-9] I2 {D}{2} H [0-9A-Fa-f] H3 {H}{3} S [ ]+ AN [A-Za-z][A-Za-z0-9]* %% {D}+pt { echo("FT_SIZE_VAL"); } [-]?{D}*\.{D}+ | {D}+\. { echo("FLOAT"); } [-]?{D}+ { echo("INT"); } #{H3}{1,2} { echo("COLOR_H"); } rgb\({I2}%,{S}{I2}%,{S}{I2}%\) { echo("COLOR_RBG"); } black|blue|gray | green|red|yellow|none { echo("COLOR_KW"); } href { echo("HREF"); } style { echo("STYLE"); } fill { echo("FILL"); } stroke { echo("STROKE"); } font-family { echo("FT_FAMILY"); } font-size { echo("FT_SIZE"); } points { echo("POINTS"); } transform { echo("TRANSFORM"); } (sans-)?serif { echo("FT_FAM_VAL"); } [#]{AN} { echo("REFERENCE"); } {AN} { echo("SYMB"); } [,:;=()\"] { ECHO; } [ \t\n] { ECHO; } . { echo1("UNK"); } %% int yywrap(void) { return 1; } int main(int argc, char *argv[]) { while (yylex()!=0) ; return 0; }