Download pacc - a compiler

Transcript
Chapter 21: User manual
24
21 User manual
This User Manual is a complete but concise description of all the features of pacc.
21.1 Invoking pacc
Usage:
pacc [OPTION]... FILE
pacc must be invoked with the name of a grammar file, which conventionally has a .pacc
extension. pacc will write an output file with the same name but a .c extension.
Option summary:
Operation modes
-h, --help
-v, --version
-D, --dump-ast=WHEN
display this help and exit
report version number and exit
dump the parse tree at various points
Parser:
-n, --name=NAME
-f, --feed=FILE
name the grammar (default: pacc)
write extra feed parser to FILE
Output:
-d, --defines[=FILE]
-o, --output=FILE
also produce a header file
write output to FILE
21.1.1 Output options
Some options control the output of pacc.
‘--output=FILE’
With the option ‘-oFILE’ or ‘--output=FILE’, pacc will write its output to the
named FILE. Since pacc’s output is C source code, you should specify a FILE that
has a .c extension.
‘--defines[=FILE]’
With the option ‘-d’ or ‘--defines’, pacc will additionally write a header file,
containing external definitions. If no FILE is specified, the defines file will have the
same name as the output file but with a .h extension.
21.1.2 Parser options
Some options control the parser (or parsers) that pacc generates.
‘--name=NAME’
The parser created by pacc is interfaced to your C program through a number of
functions with names such as ‘pacc_new()’ (see Section 21.7 [Interfaces], page 28).
When the ‘-nNAME’ or ‘--name=NAME’ option is specified, the functions are instead
named ‘NAME_new()’.
‘--feed=FILE’
With the option ‘-fFILE’ or ‘--feed=file’, pacc writes an extra feed parser to the
named FILE. This can be used for parsing command line input where some lines
are correct but incomplete (see Section 21.6 [Feeding], page 28). If the main parser
returns an error, but the feed parser recognises the input, the controlling program
should solicit more input from the user, and feed it to the parser.