APG
… an ABNF Parser Generator
|
The SABNF parser. More...
#include "./lib.h"
#include "./parserp.h"
#include "./operators.h"
#include "./tracep.h"
#include "./statsp.h"
#include "./backref.h"
#include "./backrefu.h"
#include "./backrefp.h"
Go to the source code of this file.
Functions | |
void * | vpParserCtor (exception *spException, void *vpParserInit) |
The parser's constructor for file initialization data. More... | |
void * | vpParserAllocCtor (exception *spException, void *vpParserInit, abool bAllocateTables) |
The parser constructor. More... | |
void | vParserDtor (void *vpCtx) |
Clears the parser component's context and frees all heap memory associated with this parser. More... | |
void | vParserParse (void *vpCtx, parser_config *spConfig, parser_state *spState) |
Parse an input string of alphabet characters. More... | |
void | vParserSetRuleCallback (void *vpCtx, aint uiRuleId, parser_callback pfnCallback) |
Set a call back function for a specific rule. More... | |
void | vParserSetUdtCallback (void *vpCtx, aint uiUdtId, parser_callback pfnCallback) |
Set a call back function for a specific UDT. More... | |
abool | bParserValidate (void *vpCtx) |
Validate the context pointer of a parser. More... | |
aint | uiParserRuleLookup (void *vpCtx, const char *cpRuleName) |
Find the rule index corresponding to a rule name. More... | |
const char * | cpParserRuleName (void *vpCtx, aint uiRuleIndex) |
Find the rule name from the corresponding index. More... | |
const char * | cpParserUdtName (void *vpCtx, aint uiUdtIndex) |
Find the UDT name corresponding to a UDT index. More... | |
The SABNF parser.
Definition in file parser.c.
abool bParserValidate | ( | void * | vpCtx | ) |
Validate the context pointer of a parser.
vpCtx | Pointer to a supposedly valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). |
const char* cpParserRuleName | ( | void * | vpCtx, |
aint | uiRuleIndex | ||
) |
Find the rule name from the corresponding index.
A rule's index is the 0-based order in which it appears in the SABNF grammar. Used in many places instead of the name to identify a rule. The parser's start rule (parser_config) would be a prime example.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
uiRuleIndx | Index (order of appearance in the SABNF grammar) of the rule name to look up |
const char* cpParserUdtName | ( | void * | vpCtx, |
aint | uiUdtIndex | ||
) |
Find the UDT name corresponding to a UDT index.
A UDT's index is the 0-based order in which it appears in the SABNF grammar. Used in some places instead of the name to identify a UDT. vParserSetUdtCallback() would be an example.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
uiUdtIndex | Index of the UDT to look up. |
aint uiParserRuleLookup | ( | void * | vpCtx, |
const char * | cpRuleName | ||
) |
Find the rule index corresponding to a rule name.
A rule's index is the 0-based order in which it appears in the SABNF grammar. Used in many places instead of the name to identify a rule. The parser's start rule (parser_config) would be a prime example.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
cpRuleName | Name of the rule to look up. Case insensitive. |
void vParserDtor | ( | void * | vpCtx | ) |
Clears the parser component's context and frees all heap memory associated with this parser.
vpCtx | a parser context pointer previously returned from vpParserCtor() or vpApiOutputParser(). NULL is silently ignored. However, non-NULL values must be valid parser context pointers. |
void vParserParse | ( | void * | vpCtx, |
parser_config * | spConfig, | ||
parser_state * | spState | ||
) |
Parse an input string of alphabet characters.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
spConfig | Pointer to the configuration defining the input string and other parsing parameters. See parser_config. |
spState | Pointer to a parser state structure. See parser_state. |
void vParserSetRuleCallback | ( | void * | vpCtx, |
aint | uiRuleId, | ||
parser_callback | pfnCallback | ||
) |
Set a call back function for a specific rule.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
uiRuleId | The index of the rule to set the call back function for. |
pfnCallback | Pointer to the call back function. |
void vParserSetUdtCallback | ( | void * | vpCtx, |
aint | uiUdtId, | ||
parser_callback | pfnCallback | ||
) |
Set a call back function for a specific UDT.
Note that the parser, vParserParse(), checks on initialization that all UDTs in the SABNF grammar have call back functions set.
vpCtx | Pointer to a valid parser context previously returned from vpParserCtor() or vpApiOutputParser(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
uiUdtId | The index of the UDT to set the call back function for. |
pfnCallback | Pointer to the call back function. |
The parser constructor.
The generator can generate the parser's initialization data in one of two ways.
spException | Pointer to a valid exception structure initialized with vExCtor() or XCTOR(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
vpParserInit | Pointer to the initialization data. |
bAllocateTables | If true, memory is allocated to copy the initialization data into the parser'scontext. If false, no memory allocation and copying is done. |
void* vpParserCtor | ( | exception * | spException, |
void * | vpParserInit | ||
) |
The parser's constructor for file initialization data.
This function is used to construct a parser from grammar file, "namespace.c", generated by vApiOutput().
spException | Pointer to a valid exception structure initialized with vExCtor() or XCTOR(). If not valid, the application will silently exit with a BAD_CONTEXT exit code. |
vpParserInit | - Pointer to the initialization data in the generated "namespace.c" file. |