%top { #include "grammar.h" } %option noyywrap %option nounput %option noinput %option yylineno %option stack %option noyy_top_state %x binval %x hexval %% %{ /* Choix d'un des démarrages multiples */ if (*init_token != ALLOW_ALL) { unsigned int first; first = *init_token; *init_token = ALLOW_ALL; return first; } %} [A-Za-z_][A-Za-z0-9_]* { if (strcmp(yytext, "NOT") == 0) return NOT; else if (strcmp(yytext, "AND") == 0) return AND_LOG; else if (strcmp(yytext, "EOR") == 0) return EOR; else { yylvalp->string = strdup(yytext); return NAME; } } [0-9][0-9]* { yylvalp->integer = atoi(yytext); return NUMBER; } "'" { yy_push_state(binval); } [01][01]* { yylvalp->string = strdup(yytext); return BINVAL; } "'" { yy_pop_state(); } \"[^\"]*\" { yylvalp->string = strndup(yytext + 1, strlen(yytext) - 2); return STRING; } "0x" { yy_push_state(hexval); } [0-9a-f][0-9a-f]* { yylvalp->string = strdup(yytext); yy_pop_state(); return HEXVAL; } "," { return COMMA; } ":" { return COLON; } "&" { return AND_LOG; } "<<" { return LSHIFT; } "==" { return EQ; } "!=" { return NE; } "&&" { return AND_BOOL; } "||" { return OR_BOOL; } "(" { yy_push_state(INITIAL); return OP; } ")" { yy_pop_state(); return CP; } [ ]+ { } . { char *msg; asprintf(&msg, "Unhandled token in d2c args block: '%s'", yytext); YY_FATAL_ERROR(msg); free(msg); } %%