LEX(2)

Table of Contents

Name

lex-definitions specifies a list of lex definitions lex-declarations specifies a list of lex declarations

Synopsis

%lex-definitions
[ name description ] ...
[ changes to internal array sizes ] ...

%lex-declarations
C declarations

Description

The lex-definitions and lex-declarations sections of a source description file specify lex definitions and lex declarations; they contain code that is inserted into the generated lex file, lex.l.

The lex-definitions section is used to define lex pattern names; these names can make a grammar shorter and more readable. The names must begin in column one.

The lex-definitions section can also be used to adjust the sizes of arrays within lex; this is sometimes needed to increase lex limits; see the lex documentation.

Note: Lines for which lex requires an initial percent sign must be escaped with an additional percent sign (see example).

Start conditions cannot be defined in the lex-definitions section, because they are automatically computed and inserted by ivy*meta SDTB for all red tokens.

The lex-declarations section may contain C preprocessor declarations that change the default sizes of ivy*meta SDTB buffers. Specifically, the buffers and their default sizes are:

MAXTOKSIZE
5000 Maximum length of a lex token
MAXWHITE
5000 Maximum length of white space between tokens
MAXBALANCE
5000 Maximum length of a balanced token

These values can be changed with #define statements.

Example

%lex-definitions

D
[0-9]
A
[A-Za-z] ID {A}({A}|{D})* NUM {D}+("."{D}*)? %%a 2000 %lex-declarations
#define MAXTOKSIZE 10000
#define MAXWHITE 10000

%grammar
input: ( id:{ID} number:{NUM} )

See Also

RED(2)
WHITESPACE(2)
YACC(2)
TOKEN(5)

Documentation

Lex A Lexical Analyzer Generator, M.E. Lesk and E. Schmidt


© 1990 Lucent Technologies, Inc
© 1998 Harmony Software, Inc