| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The definitions section contains declarations of simple name definitions to simplify the scanner specification, and declarations of start conditions, which are explained in a later section.
Name definitions have the form:
name definition |
The `name' is a word beginning with a letter or an underscore (`_') followed by zero or more letters, digits, `_', or `-' (dash). The definition is taken to begin at the first non-whitespace character following the name and continuing to the end of the line. The definition can subsequently be referred to using `{name}', which will expand to `(definition)'. For example,
DIGIT [0-9]
ID [a-z][a-z0-9]*
|
Defines `DIGIT' to be a regular expression which matches a single digit, and `ID' to be a regular expression which matches a letter followed by zero-or-more letters-or-digits. A subsequent reference to
{DIGIT}+"."{DIGIT}*
|
is identical to
([0-9])+"."([0-9])* |
and matches one-or-more digits followed by a `.' followed by zero-or-more digits.
An unindented comment (i.e., a line beginning with `/*') is copied verbatim to the output up to the next `*/'.
Any indented text or text enclosed in `%{' and `%}' is also copied verbatim to the output (with the %{ and %} symbols removed). The %{ and %} symbols must appear unindented on lines by themselves.
A %top block is similar to a `%{' ... `%}' block, except
that the code in a %top block is relocated to the top of the
generated file, before any flex definitions (1).
The %top block is useful when you want certain preprocessor macros to be
defined or certain files to be included before the generated code.
The single characters, `{' and `}' are used to delimit the
%top block, as show in the example below:
%top{
/* This code goes at the "top" of the generated file. */
#include <stdint.h>
#include <inttypes.h>
}
|
Multiple %top blocks are allowed, and their order is preserved.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Wolfram Kahl on September, 9 2006 using texi2html 1.76.