Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)

User Commands (d - f)
ex(1)
-Sskeleton
Overrides the default skeleton le from which the command constructs its scanners.
This is useful for ex maintenance or development.
-c Species table-compression options. (Obsolescent)
-n Suppresses the statistics summaries that the -v ag typically generates. (Obsolescent.)
DESCRIPTION
The lex and ex commands have the same functionality.
The ex command is a tool for generating scanners: programs that recognize lexical patterns in
text. ex reads the given input les, or its standard input le if no lenames are given or if a le
operand is - (dash), for a description of a scanner to generate. The description is in the form of
pairs of regular expressions and C code, called rules. ex generates as output a C source le,
named lex.yy.c, which denes a routine yylex(). This le is compiled and linked with the -ll
library to produce an executable. When the executable is run, it scans its input and the regular
expressions in its rules looking for the best match (longest input). When it has selected a rule it
executes the associated C code, which has access to the matched input sequence (commonly
referred to as a token). This process then repeats until input is exhausted.
ex treats multiple input les as one.
Syntax for ex Input
This subsection contains a description of the ex input les, which are normally named with a .l
sufx. It provides a listing of the special values, macros, and functions recognized by the ex com-
mand.
The ex input le consists of three sections, separated by a line with just %% in it:
[ denitions ]
%%
[ rules ]
[ %%
[ user_functions ]]
where
definitions Contains declarations to simplify the scanner specication and declarations of
start states, which are explained below.
rules Describes what the scanner is to do.
user_functions Contains user-supplied functions, which are copied directly to le lex.yy.c.
With the exception of the rst %% sequence, all sections are optional. The minimal scanner,
%%, copies its input to the standard output le.
Each line in the denitions section can be:
name regexp Denes name to expand to regexp. name is a word beginning with a letter or an
underscore ( _ ) followed by zero or more letters, digits, underscores, or dashes ( -
). In the regular-expression parts of the rules section, the command substitutes
regexp wherever you refer to {name}(name within braces).
%x state [ state ... ] or %s state [ state ... ]
Denes names for states used in the rules section. A rule can be made condition-
ally active based on the current scanner state. Multiple lines dening states can
appear, and each can contain multiple state names, separated by white space. The
name of a state follows the same syntax as that of regexp names except that
527188-003 Hewlett-Packard Company 3145