Next: , Previous: , Up: Common Patterns   [Contents][Index]

A.4.3 Quoted Constructs

C99 String Literal


C99 Comment


Note that in C99, a ‘//’-style comment may be split across lines, and, contrary to popular belief, does not include the trailing ‘\n’ character.

A better way to scan ‘/* */’ comments is by line, rather than matching possibly huge comments all at once. This will allow you to scan comments of unlimited length, as long as line breaks appear at sane intervals. This is also more efficient when used with automatic line number processing. See option-yylineno.

    "/*"      BEGIN(COMMENT);
    "*/"      BEGIN(0);
    [^*\n]+   ;
    "*"[^/]   ;
    \n        ;