Previous: Format of the User Code Section, Up: Format of the Input File [Contents][Index]
Flex supports C-style comments, that is, anything between ‘/*’ and ‘*/’ is considered a comment in the parts of the file Flex interprets. 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:
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:
%{
/* C code block - other target languages might have different comment syntax */
%}
/* Definitions Section */
%x STATE_X
%%
/* Rules Section */
ruleA /* after regex */ { /* C code block */ } /* after code block */
/* Rules Section (indented) */
<STATE_X>{
ruleC yyecho();
ruleD yyecho();
%{
/* C code block */
%}
}
%%
/* User C Code Section */
If the target language is something other than C/C++, you will need to use its normal comment syntax in actions and code blocks. Note that the optional { and } delimiters around actions a Flex syntax, not C syntax; you will be able to use those even if, e,g., your target language is Pascal-like and delimits blocs with begin/end.
Previous: Format of the User Code Section, Up: Format of the Input File [Contents][Index]