Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
|
Go to the documentation of this file.
37 #ifndef LIB_PARSERP_H_
38 #define LIB_PARSERP_H_
390 abool bPpptEval(parser* spCtx,
const opcode* spOp,
aint uiOffset);
391 aint uiPpptState(parser* spCtx,
const opcode* spOp,
aint uiOffset);
aint uiId
The operation identifier, ID_ALT.
const void * vpValidate
Set to a "magic number" by the constructor. Must be valid for all other parser function calls.
Data structure for a single TLS opcode.
op_cat sCat
The concatenation CAT opcode.
aint uiMapSize
Number of bytes in a single PPPT map.
aint uiStrLen
Number of characters in the string.
aint uiId
The operation identifier, ID_ALT.
luint uiVersionOffset
Offset from the beginning of the string table to the null-terminated version number string.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
const achar * acpStrTbl
Pointer to the alphabet character table for the first character of the allowed string.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
abool bGetParserInitData(parser_init *spHdr, luint *luipParserInit)
Re-size the initialization data to the required integer size.
const aint * uipChildList
Pointer to the table of child indexes for ALT and CAT operators.
op_rep sRep
The repetition REP opcode.
const achar * acpAcharTable
Pointer to the alphabet character table for TLS and TBS operators.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
const aint * uipChildList
Pointer to the first child opcode index.
achar acMin
Minimum alphabet character in the allowed range.
callback_data sCBData
The callback data, initialized by the parser and passed to user-defined call back functions.
rule * spRule
Pointer to the rule for this operation.
uint32_t uiSizeofUint
Minimum size, in bytes, required for the basic parser unsigned integer, aint.
aint uiSubStringLength
The number of characters in the substring to parse.
op_not sNot
The negative look ahead NOT opcode.
parser_callback pfnCallback
Pointer to the call back function for this UDT. The parser will throw an exception if this is NULL....
rule * spRules
Pointer to the list of rules.
luint uiOpcodesOffset
Offset from the beginning of the initialization data to the to the list of opcodes.
op_trg sTrg
The terminal range TRG opcode.
aint uiStartRule
The current index of the start rule.
const char * cpStringTable
Pointer to the string table.
luint uiUdtCount
The number of UDTs in the grammar.
void * vpVecInputString
Vector to keep a copy of the input string.
Data structure for a single REP opcode.
op_bka sBka
The positive look behind BKA opcode.
Data structure for a single UDT opcode.
luint uiRuleCount
The number of rules in the grammar.
pfn_op * pfnOpFunc
Pointer to the current node operation function.
luint uiChildListOffset
Offset from the beginning of the initialization data to the list of ALT and CAT child node opcode ind...
uint32_t uiAcharTableLength
Length of this data's alphabet character table.
parser_callback pfnCallback
Pointer to the call back function for this rule. NULL if the user has not defined a call back functio...
exception * spException
Pointer to the exception structure to use for reporting fatal errors.
const aint * uipChildList
Pointer to the first child opcode index.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
aint uiGetAcharTable(parser_init *spHdr, achar *acpAcharTable)
Extract the alphabet character table from the initialization data.
Data structure for a single BKN opcode.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
uint_fast8_t achar
achar is the type for the parser's alphabet characters.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
opcode sStartOp
Placeholder for the parser-generated RNM operator of the start rule. The root node of the parse tree.
const union opcode_tag * spOp
Pointer to the first opcode of the rule.
aint uiOpcodeCount
The number of opcodes (node operations) generated by the SABNF grammar.
Data structure for a single RNM opcode.
achar acMax
Maximum alphabet character in the allowed range.
void * vpTrace
Pointer to the trace object context, if any. See vpTraceCtor().
aint uiStrLen
Number of characters in the string.
const void * vpParserInit
aint uiMapCount
Number of maps in the PPPT.
luint uiOpcodeCount
The number of opcodes in the grammar.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
aint uiId
The operation identifier, ID_ALT.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
luint uiSizeInInts
The number of integers in the initialization data, including this header.
aint uiId
The opcode identifier e.g. ID_ALT.
uint32_t uiSizeofAchar
Minimum size, in bytes, required for the alphabet characters, achar.
uint32_t uiParserInitLength
Length of the parser initialization data.
uint32_t uiStringTableLength
Length of this data's string table.
The initialization information generated by APG.
void(* parser_callback)(callback_data *spData)
User-written callback function prototype.
aint uiId
The operation identifier, ID_ALT.
aint uiOpState
State of the current opcode being processed.
luint uiLicenseOffset
Offset from the beginning of the string table to the null-terminated license string.
aint uiId
The operation identifier, ID_ALT.
const uint8_t * ucpMaps
Pointer to the PPPT maps.
const void * vpAcharTable
Pointer to the alphabet character table or NULL if none. (Possible for small grammars....
void vGetChildListTable(init_hdr *spHdr, aint *uipList)
Extract the child index list from the initialization data.
aint uiId
The operation identifier, ID_ALT.
aint uiRuleIndex
The rule index - zero-based order in which the rule appears in the SABNF grammar.
uint_fast32_t aint
The APG parser's unsigned integer type.
parser_state sState
The final state of the parser.
op_udt sUdt
The User-Defined Terminal UDT opcode.
opcode * spOpcodes
Pointer to the list of opcodes.
op_aen sAen
The end-of-string anchor AEN opcode.
const achar * acpStrTbl
Pointer to the alphabet character table for the first character of the allowed string.
aint uiId
The operation identifier, ID_ALT.
luint uiAcharMin
The minimum value of all of the alphabet characters (achar) present in the grammar.
const char * cpUdtName
Pointer to the (null-terminated) ASCII rule name.
op_bkr sBkr
The back reference BKR opcode.
const char * cpStringTable
Pointer to the ASCII string table with rule and UDT names.
aint uiMin
Minimum number of repetitions allowed.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
luint uiUdtsOffset
Offset from the beginning of the initialization data to the to the list of UDTs.
void(* pfn_op)(struct parser_tag *spCtx, const union opcode_tag *spOp)
Prototype for the node operation functions.
luint uiUdtsLength
Number of integers in the UDT list.
The parser's final state.
aint uiLookBehindLength
The maximum number of character to search for a match in look behind.
luint uiUintMax
The maximum value of all of the integers present in this initialization data.
General opcode. Only holds the opcode ID and PPPT map pointer.
op_and sAnd
The positive look ahead AND opcode.
A structure to describe the type and location of a caught exception.
Data structure for a single TBS opcode.
Data structure for a single NOT opcode.
aint uiOffset
Offset to the current phrase to parse.
aint uiId
The operation identifier, ID_ALT.
void * vpAst
Pointer to the AST object context, if any. See vpAstCtor().
Data structure for a single AEN opcode.
aint uiInputStringLength
Number of characters in the input string.
luint uiOpcodesLength
Number of integers in the opcode list.
aint uiId
The operation identifier, ID_ALT.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
aint uiId
The operation identifier, ID_ALT.
void vTranslateOpcodes(parser *spCtx, rule *spRules, udt *spUdts, opcode *spOpcodes, luint *luipData)
Translate the initialization data for the opcodes into the internal opcode format.
op_abg sAbg
The begin-of-string anchor ABG opcode.
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
op_tls sTls
The terminal literal string TLS opcode.
The data struct passed to each callback function.
aint uiEmpty
True if this UDT can return EMPTY, false otherwise.
const uint8_t * ucpPpptTable
Pointer to the PPPT or NULL if none.
op_alt sAlt
The alternation ALT opcode.
op_gen sGen
Each opcode has its ID as the first integer. This general opcode serves only the purpose of getting t...
Data structure for a single AND opcode.
aint uiEmpty
APG_TRUE if this UDT can be empty, APG_FALSE otherwise. Parser will throw an exception if this if fal...
achar acAcharMin
The minimum alphabet character referenced by the SABNF grammar.
aint uiRuleCount
The number of rules in the SABNF grammar.
luint uiSizeofAchar
The minimum size, in bytes, required to hold all alphabet characters in the grammar.
void vTranslateUdts(parser *spCtx, udt *spUdts, luint *luipData)
Translate the initialization data for the UDTs into the internal UDT format.
op_bkn sBkn
The negative look behind BKN opcode.
aint uiMax
Maximum number of repetitions allowed.
udt * spUdts
Pointer to the list of UDTs.
aint uiSubStringBeg
The offset to the first character of the sub-string to parse.
Data structure for a single rule.
aint uiTreeDepth
The current parse tree depth.
aint uiUdtCount
The number of UDTs in the SABNF grammar.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
luint uiRulesOffset
Offset from the beginning of the initialization data to the to the list of rules.
void * vpBkru
Pointer to the universal-mode back reference object context, if any. See vpBkruCtor().
void * vpBkrp
Pointer to the parent-mode back reference object context, if any. See vpBkrpCtor().
aint uiInLookaround
True if in look ahead or look behind mode.
void vTranslateRules(parser *spCtx, rule *spRules, opcode *spOpcodes, luint *luipData)
Translate the initialization data for the rules into the internal rules format.
luint uiAcharMax
The maximum value of all of the alphabet characters (achar) present in the grammar.
Data structure for a single ALT opcode.
Data structure for a single BKA opcode.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
aint uiId
The operation identifier, ID_ALT.
aint uiRuleIndex
Index of the rule to back reference.
aint uiOpcodeCount
Number of opcodes in this rule.
Data structure for a single CAT opcode.
uint8_t ucGetMapVal(const uint8_t *ucpMap, luint luiOffset, luint luiChar)
aint uiId
The operation identifier, ID_ALT.
luint uiChildListLength
The number of integers in the child index list.
uint8_t abool
abool is the APG bool type.
aint uiEmpty
APG_TRUE if this rule can be empty, APG_FALSE otherwise.
aint uiId
The operation identifier, ID_ALT.
aint uiSubStringEnd
The offset to the first character beyond the end of the sub-string to parse.
op_rnm sRnm
The rule name RNM opcode.
void * vpMem
Pointer to a memory object context used for all memory allocations by the parser.
The parser object's context. Holds the parser's state. Opaque to user.
uint32_t uiPpptTableLength
Length of this data's PPPT.
luint uiMapSize
The number of bytes in one PPPT map.
luint uiCopyrightOffset
Offset from the beginning of the string table to the null-terminated copyright string.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
void * vpParserAllocCtor(exception *spException, void *vpParserInit, abool bAllocateTables)
The parser constructor.
Data structure for a single ABG opcode.
const achar * acpInputString
Pointer to the input string.
luint uiMapCount
The number rule, UDT, and opcode PPPT maps.
op_tbs sTbs
The terminal binary string TBS opcode.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for this opcode, if any.
Header for the parser initialization data.
Data structure for a single TRG opcode.
aint uiPhraseLength
Phrase length of a matched phrase.
luint uiSizeofUint
The minimum integer size, in bytes, required to hold all of the integers in the initialization data.
const void * vpParserInit
Pointer to the parser's initialization data.
achar acAcharMax
The maximum alphabet character referenced by the SABNF grammar.
A union of all possible node type opcode data structures.
const uint8_t * ucpPpptMap
Pointer to the PPPT map for the rule.
luint uiRulesLength
Number of integers in the rules list.
aint uiId
The operation identifier, ID_ALT.
Data structure for a single UDT.
udt * spUdt
Pointer to the UDT structure.
aint uiUdtIndex
The UDT index - the zero-based order in which the UDT appears in the SABNF grammar.
aint uiId
The operation identifier, ID_ALT.
aint uiChildCount
Number of children.
const char * cpRuleName
Pointer to the (null-terminated) ASCII rule name.
aint uiChildCount
Number of children.
void * vpStats
Pointer to the stats object context, if any. See vpStatsCtor().
Data structure for a single BKR opcode.
APG Version 7.0 is licensed under the
2-Clause BSD License,
an Open Source Initiative Approved License.