Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Data Structures | Macros | Functions
config.h File Reference

The configuration object header file. More...

This graph shows which files directly or indirectly include this file:

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 configspConfigOptions (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...
 

Detailed Description

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.

Macro Definition Documentation

◆ CONFIG_FILE

#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.

Definition at line 99 of file config.h.

Function Documentation

◆ spConfigOptions()

const config* spConfigOptions ( void *  vpCtx,
int  iArgCount,
char **  cppArgs 
)

Reads the command line arguments and parses them into a configuration structure.

Parameters
vpCtxPointer to the configuration context previously returned by a call to the constructor vConfigCtor().
iArgCountthe number of arguments on the command line.
cppArgsan array of pointers to the command line arguments.
Returns
Pointer to a configuration structure with all of the input from the command line in a form easily used by main();

Definition at line 194 of file config.c.

◆ vConfigDefault()

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.

Parameters
vpCtxPointer to the configuration context previously returned by a call to the constructor vConfigCtor().
cpFileNameName of the file to open and write the default configuration to. If NULL, prints to stdout.

Definition at line 282 of file config.c.

◆ vConfigDisplay()

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.

Parameters
spConfigPointer to the configuration structure.
iArgCountThe number of option arguments.
cppArgsArray of pointers to the arguments
Returns
void

Definition at line 431 of file config.c.

◆ vConfigDtor()

void vConfigDtor ( void *  vpCtx)

The configuration destructor.

Closes the open config file, if necessary.

Parameters
vpCtxPointer 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.

Definition at line 171 of file config.c.

◆ vConfigHelp()

void vConfigHelp ( void  )

Prints the help screen when requested or if there is a command line options error.

Definition at line 210 of file config.c.

◆ vConfigVersion()

void vConfigVersion ( void  )

Display the version number.

Definition at line 266 of file config.c.

◆ vpConfigCtor()

void* vpConfigCtor ( exception spEx)

Constructs a configuration object to hold all data relating to this instance of the configuration.

Parameters
spExPointer to a valid exception object.
See also
XCTOR().
Returns
Pointer to the configuration context. Exception thrown on error.

Definition at line 97 of file config.c.

APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.