How can I match C-style comments?
You might be tempted to try something like this:
or, worse, this:
The above rules will eat too much input, and blow up on things like:
| /* a comment */ do_my_thing( "oops */" );
|
Here is one way which allows you to track line information:
| <INITIAL>{
"/*" BEGIN(IN_COMMENT);
}
<IN_COMMENT>{
"*/" BEGIN(INITIAL);
[^*\n]+ // eat comment in chunks
"*" // eat the lone star
\n yylineno++;
}
|
This document was generated by Wolfram Kahl on September, 9 2006 using texi2html 1.76.