%{ #include using namespace std; /* idea here is to strip comments out of C code. */ /* INITIAL is the default start state. Comment is our new */ /* state where we remove comments. */ %} %s COMMENT %% "//".* ; "/*" BEGIN COMMENT; . ECHO; [\n] ECHO; "*/" BEGIN INITIAL; . ; [\n] ; %% main() { yylex(); }