manpagez: man pages & more
info flex
Home | html | info | man

File: flex.info,  Node: Rules Section,  Next: User Code Section,  Prev: Definitions Section,  Up: Format

5.2 Format of the Rules Section
===============================

The "rules" section of the 'flex' input contains a series of rules of
the form:

         pattern   action

   where the pattern must be unindented and the action must begin on the
same line.  *Note Patterns::, for a further description of patterns and
actions.

   In the rules section, any indented or %{ %} enclosed text appearing
before the first rule may be used to declare variables which are local
to the scanning routine and (after the declarations) code which is to be
executed whenever the scanning routine is entered.  Other indented or %{
%} text in the rule section is still copied to the output, but its
meaning is not well-defined and it may well cause compile-time errors
(this feature is present for POSIX compliance.  *Note Lex and Posix::,
for other such features).

   Any _indented_ text or text enclosed in '%{' and '%}' is copied
verbatim to the output (with the %{ and %} symbols removed).  The %{ and
%} symbols must appear unindented on lines by themselves.  Because
whitespace is easy to mangle without noticing, it's good style to use
the explicit %{ and %} delimiters.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.