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

Private header for the SABNF parser. More...

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

Go to the source code of this file.

Data Structures

struct  parser_init
 The initialization information generated by APG. More...
 
struct  init_hdr
 Header for the parser initialization data. More...
 
struct  rule
 Data structure for a single rule. More...
 
struct  udt
 Data structure for a single UDT. More...
 
struct  op_alt
 Data structure for a single ALT opcode. More...
 
struct  op_cat
 Data structure for a single CAT opcode. More...
 
struct  op_rep
 Data structure for a single REP opcode. More...
 
struct  op_rnm
 Data structure for a single RNM opcode. More...
 
struct  op_trg
 Data structure for a single TRG opcode. More...
 
struct  op_tls
 Data structure for a single TLS opcode. More...
 
struct  op_tbs
 Data structure for a single TBS opcode. More...
 
struct  op_udt
 Data structure for a single UDT opcode. More...
 
struct  op_and
 Data structure for a single AND opcode. More...
 
struct  op_not
 Data structure for a single NOT opcode. More...
 
struct  op_bkr
 Data structure for a single BKR opcode. More...
 
struct  op_bka
 Data structure for a single BKA opcode. More...
 
struct  op_bkn
 Data structure for a single BKN opcode. More...
 
struct  op_abg
 Data structure for a single ABG opcode. More...
 
struct  op_aen
 Data structure for a single AEN opcode. More...
 
struct  op_gen
 General opcode. Only holds the opcode ID and PPPT map pointer. More...
 
union  opcode_tag
 A union of all possible node type opcode data structures. More...
 
struct  parser_tag
 The parser object's context. Holds the parser's state. Opaque to user. More...
 

Typedefs

typedef void(* pfn_op) (struct parser_tag *spCtx, const union opcode_tag *spOp)
 Prototype for the node operation functions. More...
 

Functions

void * vpParserAllocCtor (exception *spException, void *vpParserInit, abool bAllocateTables)
 The parser constructor. More...
 
aint uiGetAcharTable (parser_init *spHdr, achar *acpAcharTable)
 Extract the alphabet character table from the initialization data. More...
 
abool bGetParserInitData (parser_init *spHdr, luint *luipParserInit)
 Re-size the initialization data to the required integer size. More...
 
void vGetChildListTable (init_hdr *spHdr, aint *uipList)
 Extract the child index list from the initialization data. More...
 
void vTranslateRules (parser *spCtx, rule *spRules, opcode *spOpcodes, luint *luipData)
 Translate the initialization data for the rules into the internal rules format. More...
 
void vTranslateUdts (parser *spCtx, udt *spUdts, luint *luipData)
 Translate the initialization data for the UDTs into the internal UDT format. More...
 
void vTranslateOpcodes (parser *spCtx, rule *spRules, udt *spUdts, opcode *spOpcodes, luint *luipData)
 Translate the initialization data for the opcodes into the internal opcode format. More...
 
uint8_t ucGetMapVal (const uint8_t *ucpMap, luint luiOffset, luint luiChar)
 

Detailed Description

Private header for the SABNF parser.

The declarations here are used internally by the parser. Some of the APG utilities and helper objects will use this "inside" information but the user should rarely need this header for an application.

Definition in file parserp.h.

Typedef Documentation

◆ pfn_op

pfn_op

Prototype for the node operation functions.

Parameters
spCtxPointer to the parser object's context.
spOpPointer to the node operation's opcode (all the data required to define and execute the node operation).

Definition at line 114 of file parserp.h.

Function Documentation

◆ bGetParserInitData()

abool bGetParserInitData ( parser_init spParserInit,
luint luipParserInit 
)

Re-size the initialization data to the required integer size.

Definition at line 80 of file parser-get-init.c.

◆ ucGetMapVal()

uint8_t ucGetMapVal ( const uint8_t *  ucpMap,
luint  luiOffset,
luint  luiChar 
)

◆ uiGetAcharTable()

aint uiGetAcharTable ( parser_init spParserInit,
achar acpAcharTable 
)

Extract the alphabet character table from the initialization data.

Definition at line 43 of file parser-get-init.c.

◆ vGetChildListTable()

void vGetChildListTable ( init_hdr spInitHdr,
aint uipList 
)

Extract the child index list from the initialization data.

Definition at line 130 of file parser-get-init.c.

◆ vpParserAllocCtor()

void* vpParserAllocCtor ( exception spException,
void *  vpParserInit,
abool  bAllocateTables 
)

The parser constructor.

The generator can generate the parser's initialization data in one of two ways.

  • With vApiOutput() the data is in an C-language code file, "namespace.c". When constructing a parser from the file data, no further memory allocations for it are necessary.
  • With vpApiOutputParser() the data is in the API object's context and must be copied to the parser's context to separate it completely from the API. That is, the parser's context must remain complete and valid even if the API context is destroyed. This function has a switch to chose between the two.
Parameters
spExceptionPointer to a valid exception structure initialized with vExCtor() or XCTOR(). If not valid, the application will silently exit with a BAD_CONTEXT exit code.
vpParserInitPointer to the initialization data.
bAllocateTablesIf true, memory is allocated to copy the initialization data into the parser'scontext. If false, no memory allocation and copying is done.
Returns
Pointer to a parser context. Exceptions thrown on errors.

Definition at line 88 of file parser.c.

◆ vTranslateOpcodes()

void vTranslateOpcodes ( parser *  spCtx,
rule spRules,
udt spUdts,
opcode *  spOpcodes,
luint luipData 
)

Translate the initialization data for the opcodes into the internal opcode format.

Definition at line 76 of file parser-translate-init.c.

◆ vTranslateRules()

void vTranslateRules ( parser *  spCtx,
rule spRules,
opcode *  spOpcodes,
luint luipData 
)

Translate the initialization data for the rules into the internal rules format.

Definition at line 43 of file parser-translate-init.c.

◆ vTranslateUdts()

void vTranslateUdts ( parser *  spCtx,
udt spUdts,
luint luipData 
)

Translate the initialization data for the UDTs into the internal UDT format.

Definition at line 60 of file parser-translate-init.c.

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