|
|
The mandatory rules section opens with the delimiter ``%%''. If a routines section follows, another ``%%'' delimiter ends the rules section. The ``%%'' delimiters must be entered at the beginning of a line, without leading blanks. If there is no second delimiter, the rules section is presumed to continue to the end of the program. Lines in the rules section that begin with white space and that appear before the first rule are copied to the beginning of the function yylex(), immediately after the first brace. You might use this feature to declare local variables for yylex().
Each rule consists of a specification of the pattern sought and the action(s) to take on finding it. The specification of the pattern must be entered at the beginning of a line. The scanner writes input that does not match a pattern directly to the output file. So the simplest lexical analyzer program is just the beginning rules delimiter, ``%%''. It writes out the entire input to the output with no changes at all.