APG
… an ABNF Parser Generator
|
The configuration object header file. More...
Go to the source code of this file.
Data Structures | |
struct | config |
This data controls the flow of the main program of the APG parser generator. More... | |
Macros | |
#define | CONFIG_FILE "apg-configuration" |
The default file name for generated configuration files. More... | |
Functions | |
void * | vpConfigCtor (exception *spEx) |
Constructs a configuration object to hold all data relating to this instance of the configuration. More... | |
void | vConfigDtor (void *vpCtx) |
The configuration destructor. More... | |
const config * | spConfigOptions (void *vpCtx, int iArgCount, char **cppArgs) |
Reads the command line arguments and parses them into a configuration structure. More... | |
void | vConfigDefault (void *vpCtx, char *cpFileName) |
Prints a default configuration file. More... | |
void | vConfigHelp (void) |
Prints the help screen when requested or if there is a command line options error. More... | |
void | vConfigVersion (void) |
Display the version number. More... | |
void | vConfigDisplay (const config *spConfig, int iArgCount, char **cppArgs) |
Displays the full configuration as determined from the command line or command file arguments. More... | |
The configuration object header file.
This file and config.c define the configuration of the APG command line application. Run ./apg –help to see all options.
usage: apg options binary options: -i filename : the file name of the input grammar (see note 5.) -o filename : the file name of the generated C-language header and source files (see note 6.)
unary options: --input=filename : the file name of the input grammar (see note 5.) --output=filename : the file name of the generated C-language header and source files (see note 6.) -c : generate a default configuration file named "apg-configuration" --config-file=fname : generate a default configuration file named "fname" --p-rules=name[,name] : comma-delimited list of protected rule names (see note 9.) --grammar-html=fname : display input grammar in HTML format on file "fname" --rules-html=fname : display rule/UDT names and dependencies in HTML format on file "fname" --lf=filename : converts all input line end to LF(\n) on file "filename" (see note 8.) --crlf=filename : converts all input line end to CRLF(\r\n) on file "filename" (see note 8.) @ : read the options from the configuration file named "apg-configuration" @filename : read the options from the configuration file named "filename"
flags: true if present, otherwise false ? : display this help screen -h : display this help screen --help : display this help screen -v : display version information --version : display version information --strict : only ABNF as strictly defined in RFC 5234 allowed --ignore-attributes : attribute information will not be computed, proceed at your own risk --no-pppt : do not produce Partially-Predictive Parsing Tables (PPPTs)
display flags -dv : verbose - sets flags -dc, -dg, dr, -dp and -da -dc : display the complete configuration found on the command line or in the command file -dg : display an annotated version of the input grammar -dr : display the grammar rule names, in the order they are found in the grammar -dra : display the grammar rule names, in alphabetical order -da : display the rule attributes -dp : display the Partially-Predictive Parsing Table (PPPT) sizes -do : display the opcodes in human-readable format (warning: may generate many lines of output)
NOTES: 1. All options and flags are case sensitive. 2. Binary options require one or more spaces between the flag and the name. 3. No spaces are allowed in unary options or flags (no space before or after "="). 4. If any or all of -h, -v or -c (or any of their alternatives) is present all other options are ignored. 5. File names may be absolute (/home/user/filname) or relative ([./ | ../]mydir/filename). Directories in the path name must exist. 6. Any file name extension will be stripped and replaced with .h for the header file and .c for the source file. 7. Absent -h, -v or -c, if a configuration file is indicated (@ or @filename) all other options are ignored. 8. Both --lf and --crlf may be present. If either is present, all other options except -h, -v and -c are ignored. 9. Protected rules are protected from being hidden under predictive PPPT-mapped nodes. Rule names are case insensitive. The argument may be a comma-delimited list with no spaces allowed. Multiple instances of the --p-rules flag will accumulate rule names in the list. 10. No command line arguments generates this help screen.
Definition in file config.h.
#define CONFIG_FILE "apg-configuration" |
The default file name for generated configuration files.
The command line option "-c" can be used to generate a default configuration file named CONFIG_FILE. To customize the configuration file name use the command line option "--config-file=filename" instead.
const config* spConfigOptions | ( | void * | vpCtx, |
int | iArgCount, | ||
char ** | cppArgs | ||
) |
Reads the command line arguments and parses them into a configuration structure.
vpCtx | Pointer to the configuration context previously returned by a call to the constructor vConfigCtor(). |
iArgCount | the number of arguments on the command line. |
cppArgs | an array of pointers to the command line arguments. |
void vConfigDefault | ( | void * | vpCtx, |
char * | cpFileName | ||
) |
Prints a default configuration file.
A configuration file may in many cases be a more convenient than a command line for providing the main() program with its options. This program will print a default file with all options available commented out. The user can then conveniently un-comment the options desired and customize it to his/her needs. This is especially useful to avoid the need to re-type long file names onto the command line for repeated applications.
vpCtx | Pointer to the configuration context previously returned by a call to the constructor vConfigCtor(). |
cpFileName | Name of the file to open and write the default configuration to. If NULL, prints to stdout. |
void vConfigDisplay | ( | const config * | spConfig, |
int | iArgCount, | ||
char ** | cppArgs | ||
) |
Displays the full configuration as determined from the command line or command file arguments.
After all options have been read from the command line, or command file if present, the final interpretation of them is stored in the configuration structure. This function displays all of the arguments passed to the main function and the configuration that results from them. It is called if the flag -dc is set.
spConfig | Pointer to the configuration structure. |
iArgCount | The number of option arguments. |
cppArgs | Array of pointers to the arguments |
void vConfigDtor | ( | void * | vpCtx | ) |
The configuration destructor.
Closes the open config file, if necessary.
vpCtx | Pointer to the configuration context previously returned by a call to the constructor vConfigCtor(). NULL is silently ignored. However, if non-NULL it must be a valid config context pointer. |
void vConfigHelp | ( | void | ) |
void* vpConfigCtor | ( | exception * | spEx | ) |