The general form of a Lex source file is:
center;
l.
{definitions}
%%
{rules}
%%
{user subroutines}
The definitions section contains
a combination of
Lines in the rules section have the form ``expression action'' where the action may be continued on succeeding lines by using braces to delimit it.
Regular expressions in Lex use the following
operators:
center;
l l.
x the character "x"
"x" an "x", even if x is an operator.
\x an "x", even if x is an operator.
[xy] the character x or y.
[x-z] the characters x, y or z.
[^x] any character but x.
. any character but newline.
^x an x at the beginning of a line.
<y>x an x when Lex is in start condition y.
x$ an x at the end of a line.
x? an optional x.
x* 0,1,2, ... instances of x.
x+ 1,2,3, ... instances of x.
x|y an x or a y.
(x) an x.
x/y an x but only if followed by y.
{xx} the translation of xx from the definitions section.
x{m,n} m through n occurrences of x