[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.4 Comments in the Input
Flex supports C-style comments, that is, anything between ‘/*’ and ‘*/’ is considered a comment. Whenever flex encounters a comment, it copies the entire comment verbatim to the generated source code. Comments may appear just about anywhere, but with the following exceptions:
- Comments may not appear in the Rules Section wherever flex is expecting a regular expression. This means comments may not appear at the beginning of a line, or immediately following a list of scanner states.
- Comments may not appear on an ‘%option’ line in the Definitions Section.
If you want to follow a simple rule, then always begin a comment on a new line, with one or more whitespace characters before the initial ‘/*’). This rule will work anywhere in the input file.
All the comments in the following example are valid:
%{ /* code block */ %} /* Definitions Section */ %x STATE_X %% /* Rules Section */ ruleA /* after regex */ { /* code block */ } /* after code block */ /* Rules Section (indented) */ <STATE_X>{ ruleC ECHO; ruleD ECHO; %{ /* code block */ %} } %% /* User Code Section */
This document was generated on November 4, 2011 using texi2html 5.0.