Chapter 4: Format of the input file

The flexc++ input file consists of two (not three!) sections, separated by a line containing `%%'.

definitions
%%
rules

4.1: Definition section

All flexc++ options are specified either on the command line or in the definition section. For more information on options, see ??

Furthermore, the definition section contains declarations of simple name definitions to simplify scanner specification. A name definition looks like:

name	pattern

where name is is a word beginning with a letter or an underscore (`_') followed by zero or more letters, digits, `_', or `-' (dash). pattern is a pattern, see Patterns 5.

Finally, in the definition section we can declare start conditions 7. Miniscanners are a kind of startcondition, and they are very useful for scanning small `sublanguages' in the language you want to scan. An example is scanning a C-string in a C-program.

4.2: Rules section

The rules section of the flexc++ input contains a series of rules of the form:

pattern    action

action is here an end-of-line comment, a single-line C-statement, or a compound statement that may span several lines. action may also be empty.

An action consisting solely of a vertical bar (`|') means ``same as the action for the next rule''.

4.3: Comments

Flexc++ allows one to place comments anywhere in the document, indented or not. Both multiline comments (/* ... */) and end of line comments (// ...) are supported.

When a multiline comment is encountered outside an action, flexc++ discards the comment, while all comments in actions will be copied verbatim to the source.