%x COMMENT %x STRING %% "--" { BEGIN(COMMENT); } \" { ECHO; BEGIN(STRING); } "\n" { ECHO; BEGIN(INITIAL); } \\\" { ECHO; } \" { ECHO; BEGIN(INITIAL); } . { ECHO; } . { } . { ECHO; } %% // https://westes.github.io/flex/manual/Start-Conditions.html #include int main(void) { yylex(); return EXIT_SUCCESS; }