%{ #include "config_lex.h" config_yytype config_yylval; %} ID [_a-zA-Z][-_a-zA-Z0-9]* NUM [-+]?[0-9]+ HNUM "0x"[0-9a-fzA-F]+ BNUM "0b"[01]+ FLOAT [-+]?[0-9]*"."[0-9]* STRING \"[^\n"]\" %option noyywrap nounput %option prefix="config_yy" %% {FLOAT} { config_yylval.fl = strtod (config_yytext, 0); return FLOAT; } {BNUM} { config_yylval.num = strtol (config_yytext + 2, 0, 2); return NUM; } {HNUM} { config_yylval.num = strtol (config_yytext + 2, 0, 16); return NUM; } {NUM} { config_yylval.num = strtol (config_yytext, 0, 10); return NUM; } "true" { config_yylval.boolean = true; return BOOL; } "false" { config_yylval.boolean = false; return BOOL; } {ID} { config_yylval.id = config_yytext; return ID; } "#".* /* Commentaires. */ [ \t\n]+ /* Rien à battre. */ . return ERR; %% int config_yyopen (const char *filename) { config_yyin = fopen (filename, "r"); if (!config_yyin) return -1; return 0; } void config_yyclose (void) { fclose (config_yyin); } // vim: ft=lex