Reputation: 113
I have a problem with my flex script. I write it for C++ multiline comment. My flex pattern is:
"/""*"[^"*""/"]*"*""/" {strcpy(mlc[mlc_count++],yytext);}
It can find one multiline comment. But when I put entire code in multiline comment it doesn't work. I tried lot but can't find any solution.
Upvotes: 1
Views: 1040
Reputation: 490108
Flex reads input one buffer at a time. Using normal matching, a single token can occupy no more than one buffer of data. If memory serves, the buffer is normally something like 8 kilobytes, so a single token longer than that won't match correctly.
Typically you work around this with an exclusive start condition, something on this general order:
"/*" BEGIN(COMMENT);
<COMMENT>*/ BEGIN(INITIAL);
<COMMENT>. { current_comment += yytext[0]; }
Upvotes: 1