Appendix H. POSIX lex and yacc

The IEEE POSIX P1003.2 standard will define portable standard versions of lex and yacc. In nearly all cases the standards merely codify long-standing existing practice. POSIX lex closely resembles flex, minus the more exotic features. POSIX yacc closely resembles AT&T or Berkeley yacc. The input and output filenames are identical to those in flex and AT&T yacc.

Options

The syntax of the POSIX lex command is:

lex [options] [file . . .]

If multiple input files are specified, they are catenated together to form one lexer specification.

The options are as follows:

-c

Writes actions in C (obsolescent).

-n

Suppresses the summary statistics line.

-t

Sends source code to standard output instead of to the default file lex.yy.c.

-v

Generates a short statistical summary of the finite state machine. This option is implied when any of the tables sizes are specified in the definitions section of the lex specification.

The syntax of the yacc command is:

yacc [options] file

where options are as follows:

-bxx

Uses “xx” rather than the default "yy" as the prefix in generated filenames.

-d

Generates header file y.tab.h that contains definitions of token names for use by lexical analyzer routine.

-l

Does not include #line constructs in the generated code. These constructs help identify lines in the specification file in error messages.

-pxx

Uses “xx” rather than the default "yy" as the prefix in symbols in the generated C code. This lets you use multiple parsers in one program.

-

Get lex & yacc, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.