%top { #include "grammar.h" } %option noyywrap %option nounput %option noinput %option yylineno %option stack %option noyy_top_state %x cond %x cond_binval %x cond_hexval %x action %x raw_line %% \/\/[^\n]+ { } "if" { yy_push_state(cond); return IF; } [ ]+ { } "(" { return EXPR_START; } [A-Za-z_][A-Za-z0-9_]* { yylvalp->string = strdup(yytext); return NAME; } "==" { return EQUAL; } "'" { yy_push_state(cond_binval); } [01][01]* { yylvalp->string = strdup(yytext); return BINVAL; } "'" { yy_pop_state(); } "0x" { yy_push_state(cond_hexval); } [0-9a-f][0-9a-f]* { yylvalp->string = strdup(yytext); yy_pop_state(); return HEXVAL; } ")" { return EXPR_END; } "&&" { return AND; } "&" { return AND_LOG; } ";" { yy_pop_state(); return THEN; } [ \t\n] { } "see " { yy_push_state(raw_line); return SEE; } "unpredictable" { return UNPREDICTABLE; } "call" { yy_push_state(raw_line); return CALL; } "check" { yy_push_state(raw_line); return CHK_CALL; } [^\n]+ { yylvalp->cstring = yytext; return RAW_LINE; } "\n" { yy_pop_state(); } . { char *msg; asprintf(&msg, "Unhandled token in d2c rules block: '%s'", yytext); YY_FATAL_ERROR(msg); free(msg); } %%