Possible Duplicate:
problem getting c-style comments in flex/lex
I am writing a lexical analyzer using flex how can I make it avoid the comments that look like this:
/* COMMENTS */
Possible Duplicate:
problem getting c-style comments in flex/lex
I am writing a lexical analyzer using flex how can I make it avoid the comments that look like this:
/* COMMENTS */
It is a bit complicated. Here is a solution I found:
<INITIAL>{
"/*" BEGIN(IN_COMMENT);
}
<IN_COMMENT>{
"*/" BEGIN(INITIAL);
[^*\n]+ // eat comment in chunks
"*" // eat the lone star
\n yylineno++;
} { return COMMENT; }
The "obvious" solution, something like this:
"/*".*"*/" { return COMMENT; }
will match too much.