q2c input files are divided into two sections: the grammar rules
and the supporting code. The grammar rules, which make up the
first part of the input, are used to define the syntax of the
statistical procedure to be parsed. The supporting code,
following the grammar rules, are copied largely unchanged to the output
file, except for certain escapes.
The most important lines in the grammar rules are used for defining
procedure syntax. These lines can be prefixed with a dollar sign
(`$'), which prevents Emacs' CC-mode from munging them. Besides
this, a bang (`!') at the beginning of a line causes the line,
minus the bang, to be written verbatim to the output file (useful for
comments). As a third special case, any line that begins with the exact
/* *INDENT is ignored and not written to the output.
.q files to be processed through
without being munged.
The syntax of the grammar rules themselves is given in the following sections.
The supporting code is passed into the output file largely unchanged. However, the following escapes are supported. Each escape must appear on a line by itself.
/* (header) */
#includedirectives which include the headers that are required for the parser generated by
enums input and output by the
q2cparser. scope must be either
localcauses the declarations to be output as function locals.
globalcauses them to be declared as
staticmodule variables; thus,
globalis a bit of a misnomer.
/* (parser) */
/* (free) */
freefunction for variables declared by the parser. Only needs to be invoked if subcommands of type
stringare used in the grammar rules.