Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Functions
api.c File Reference

Some basic functions of the APG Application Programming Interface. More...

#include "./api.h"
#include "./apip.h"
#include "./attributes.h"
Include dependency graph for api.c:

Go to the source code of this file.

Functions

void * vpApiCtor (exception *spEx)
 Construct an API component context (object). More...
 
void vApiDtor (void *vpCtx)
 The API component destructor. More...
 
abool bApiValidate (void *vpCtx)
 Validates an API context pointer. More...
 
void * vpApiGetErrorLog (void *vpCtx)
 Get the internal message log. More...
 
void vApiRulesToHtml (void *vpCtx, const char *cpFileName)
 Display the grammar rules in human-readable, HTML format. More...
 
void vApiRulesToAscii (void *vpCtx, const char *cpMode, const char *cpFileName)
 Display rules and UDTs in human-readable format in ASCII format. More...
 
void vApiOpcodesToAscii (void *vpCtx, const char *cpFileName)
 Display all opcodes in human-readable format. More...
 
void vApiFile (void *vpCtx, const char *cpFileName, abool bStrict, abool bPppt)
 Quicky way to generate a parser from a grammar file. More...
 
void vApiString (void *vpCtx, const char *cpString, abool bStrict, abool bPppt)
 Quicky way to generate a parser from a grammar string. More...
 
void vHtmlHeader (FILE *spFile, const char *cpTitle)
 Prints an HTML header to an open file. More...
 
void vHtmlFooter (FILE *spFile)
 Prints an HTML footer to an open file. More...
 

Detailed Description

Some basic functions of the APG Application Programming Interface.

NOTE: The macro APG_AST must be defined for compliation of the APG A{I; The Abstract Syntax Tree (AST) is used for syntax translation. APG_AST must be defined to allow its use.

Definition in file api.c.

Function Documentation

◆ bApiValidate()

abool bApiValidate ( void *  vpCtx)

Validates an API context pointer.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
Returns
True is the context pointer is valid, false otherwise.

Definition at line 104 of file api.c.

◆ vApiDtor()

void vApiDtor ( void *  vpCtx)

The API component destructor.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
Returns
Silently ignores NULL context pointer. However, if non-NULL the API context pointer must be valid.

Definition at line 84 of file api.c.

◆ vApiFile()

void vApiFile ( void *  vpCtx,
const char *  cpFileName,
abool  bStrict,
abool  bPppt 
)

Quicky way to generate a parser from a grammar file.

Calls all of the intermediate steps in one function. Input is limited to a single file.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpFileName- Name of the grammar file.
bStrictIf true, only strictly ABNF (RFC 5234 & RFC7405) grammars allowed.
bPpptIf true, Partially-Predictive Parsing Tables (PPPTs) are generated. Note that in this single, collective call to generate a parser there is no opportunity to protect any rules from PPPT replacement. If any rules need protecting it will be necessary to do the full sequence of API calls.

Definition at line 517 of file api.c.

◆ vApiOpcodesToAscii()

void vApiOpcodesToAscii ( void *  vpCtx,
const char *  cpFileName 
)

Display all opcodes in human-readable format.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpFileName- Name of the file to display on. Any directories in the path name must exist. If NULL, stdout is used.

Definition at line 328 of file api.c.

◆ vApiRulesToAscii()

void vApiRulesToAscii ( void *  vpCtx,
const char *  cpMode,
const char *  cpFileName 
)

Display rules and UDTs in human-readable format in ASCII format.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpMode(note: the first character (case-insensitive) of the following options is all that is needed)
  • "index" sort rule names index (the order they appear in the grammar syntax)
  • "alpha" sort rule names alphabetically
  • NULL, empty string or any string not beginning with "i" or "a", defaults to "index"
cpFileName- Name of the file to display on. Any directories in the path name must exist. If NULL, stdout is used.

Definition at line 257 of file api.c.

◆ vApiRulesToHtml()

void vApiRulesToHtml ( void *  vpCtx,
const char *  cpFileName 
)

Display the grammar rules in human-readable, HTML format.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpFileName- Name of the file to display on. Any directories in the path name must exist. If NULL, stdout is used.

Definition at line 132 of file api.c.

◆ vApiString()

void vApiString ( void *  vpCtx,
const char *  cpString,
abool  bStrict,
abool  bPppt 
)

Quicky way to generate a parser from a grammar string.

Calls all of the intermediate steps in one function. Input is limited to a single file.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpString- Pointer to a string which contains the entire grammar.
bStrictIf true, only strictly ABNF (RFC 5234 & RFC7405) grammars allowed.
bPpptIf true, Partially-Predictive Parsing Tables (PPPTs) are generated. Note that in this single, collective call to generate a parser there is no opportunity to protect any rules from PPPT replacement. If any rules need protecting it will be necessary to do the full sequence of API calls.

Definition at line 544 of file api.c.

◆ vHtmlFooter()

void vHtmlFooter ( FILE *  spFile)

Prints an HTML footer to an open file.

Parameters
[out]spFile- pointer to an open file handle.
Returns
void

Definition at line 589 of file api.c.

◆ vHtmlHeader()

void vHtmlHeader ( FILE *  spFile,
const char *  cpTitle 
)

Prints an HTML header to an open file.

Parameters
[out]spFile- pointer to an open file handle.
cpTitle- the HTML page title. If NULL a default will be used.
Returns
void

Definition at line 565 of file api.c.

◆ vpApiCtor()

void* vpApiCtor ( exception spEx)

Construct an API component context (object).

Parameters
spExPointer to a valid exception object. See XCTOR(). If invalid, the application will silently exit with a BAD_CONTEXT exit code.
Returns
Pointer to an API context. Exception thrown on memory allocation error.

Definition at line 55 of file api.c.

◆ vpApiGetErrorLog()

void* vpApiGetErrorLog ( void *  vpCtx)

Get the internal message log.

User may want to display or otherwise use the list of messages.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
Returns
Pointer to a message log context.

Definition at line 117 of file api.c.

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