Go to the first, previous, next, last section, table of contents.

Text-Substitution Scanner

The following flex input specifies a scanner which, whenever it encounters the string `username', will replace it with the user's login name:

%%
username    printf( "%s", getlogin() );

By default, any text not matched by a flex scanner is copied to the output, so the net effect of this scanner is to copy its input file to its output with each occurrence of `username' expanded. In this input, there is just one rule. `username' is the pattern and the printf is the action. The `%%' marks the beginning of the rules.


Go to the first, previous, next, last section, table of contents.