Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
apip.h
Go to the documentation of this file.
1 /* *************************************************************************************
2  Copyright (c) 2021, Lowell D. Thomas
3  All rights reserved.
4 
5  This file is part of APG Version 7.0.
6  APG Version 7.0 may be used under the terms of the BSD 2-Clause License.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 * *************************************************************************************/
34 #ifndef APIP_H_
35 #define APIP_H_
36 
40 typedef struct {
50 } alt_data;
51 
55 typedef struct {
56  char *cpName;
64 } api_rule;
65 
69 typedef struct {
70  char *cpName;
73 } api_udt;
74 
78 typedef struct {
92 } api_op;
93 
99 typedef struct {
107  char *cpRuleName;
115  // admin during discovery
118 } api_attr_w;
119 
123 typedef struct {
124  const void *vpValidate;
126  void *vpMem;
127  void *vpParser;
128  void *vpAltStack;
129  void *vpAst;
130  void *vpAttrsCtx;
134  char* cpLineBuffer;
135 
136  // input
137  void *vpVecInput;
138  void* vpVecGrammar;
139  char *cpInput;
141  void* vpLines;
143 
144  // rules & opcodes
164 // char *cpInitName; ///< \brief
165 
166  // PPPT table
169  uint8_t *ucpPpptEmptyMap;
170  uint8_t *ucpPpptTable;
177 
178  // the error hierarchy
179  void *vpLog;
180 
181  // the grammar stage indicators.
190 } api;
191 
192 void vLineError(api *spCtx, aint uiCharIndex, const char *cpSrc, const char *cpMsg);
193 void vHtmlHeader(FILE *spFile, const char *cpTitle);
194 void vHtmlFooter(FILE *spFile);
195 
196 #endif /* APIP_H_ */
api::ucpPpptEmptyMap
uint8_t * ucpPpptEmptyMap
Common PPPT character map for an operator that is an empty match on the next alphabet character.
Definition: apip.h:169
api_attr_w::bpRefersToUdt
abool * bpRefersToUdt
a list of all the UDTs that this rule refers to
Definition: apip.h:111
api::uiUdtCount
aint uiUdtCount
The number of UDTs referenced in the SABNF grammar.
Definition: apip.h:148
api_op::uiPpptIndex
aint uiPpptIndex
Index to the PPPT map for this opcode.
Definition: apip.h:91
api::ucpPpptUndecidedMap
uint8_t * ucpPpptUndecidedMap
Common PPPT character map for an operator that is indeterminate on the next alphabet character.
Definition: apip.h:168
api_attr_w::bRight
abool bRight
APG_TRUE if the rule is right recursive.
Definition: apip.h:102
api_attr_w::bLeaf
abool bLeaf
APG_TRUE if this is a leaf rule (appears for a second time on a branch)
Definition: apip.h:106
api_rule::uiIndex
aint uiIndex
index of this rule in the rule list
Definition: apip.h:57
api::spRules
api_rule * spRules
Points to an array of rule structures.
Definition: apip.h:145
alt_data::uiStringTab
aint uiStringTab
Definition: apip.h:48
api_attr_w::bpIsReferencedBy
abool * bpIsReferencedBy
a list of all the rules that refer to this rule
Definition: apip.h:113
api_op::luiMax
luint luiMax
maximum value for REP and TRG opcodes
Definition: apip.h:85
api::uiLicenseOffset
aint uiLicenseOffset
Offset into the string table for the License string.
Definition: apip.h:153
api::uiOpcodeCount
aint uiOpcodeCount
Number of opcodes.
Definition: apip.h:163
api_rule::uiPpptIndex
aint uiPpptIndex
Index to the PPPT map for this opcode.
Definition: apip.h:62
api::cpInput
char * cpInput
Definition: apip.h:139
api::spOpcodes
api_op * spOpcodes
Pointer to the array of opcodes for the SANF grammar.
Definition: apip.h:162
api::uiVersionLength
aint uiVersionLength
Length of the Version Number string.
Definition: apip.h:152
vHtmlFooter
void vHtmlFooter(FILE *spFile)
Prints an HTML footer to an open file.
Definition: api.c:589
api_op::uiAcharLength
aint uiAcharLength
number of characters in TLS/TBS strings
Definition: apip.h:87
api::luiAcharEos
luint luiAcharEos
The special End-Of-String character. In practice, luiAcharMax + 1.
Definition: apip.h:176
api::vpLog
void * vpLog
A msglog context for error reporting.
Definition: apip.h:179
api::vpOutputParserInit
void * vpOutputParserInit
Storage for variable integer width output parser init data.
Definition: apip.h:132
api_attr_w
Working attribute information about a each rule.
Definition: apip.h:99
api::luipInit
luint * luipInit
Storage variable for intermediate parser initialization data.
Definition: apip.h:133
vHtmlHeader
void vHtmlHeader(FILE *spFile, const char *cpTitle)
Prints an HTML header to an open file.
Definition: api.c:565
api_rule
API information about each rule.
Definition: apip.h:55
api::bInputValid
abool bInputValid
APG_TRUE if theer is input and it has been validated, APG_FALSE otherwise.
Definition: apip.h:182
api_op::uiChildCount
aint uiChildCount
number of children for this ALT or CAT operator
Definition: apip.h:83
alt_data::uiBasicError
aint uiBasicError
Definition: apip.h:49
api::vpAttrsCtx
void * vpAttrsCtx
context handle to the attributes object
Definition: apip.h:130
api::cpStringTable
char * cpStringTable
Pointer to a list of null-terminated ASCII strings representing the rule and UDT names.
Definition: apip.h:149
alt_data
Used by syntax.c but needed here for constructor/destructor.
Definition: apip.h:40
api_attr_w::bLeft
abool bLeft
APG_TRUE if the rule is left recursive.
Definition: apip.h:100
alt_data::uiTlsOpen
aint uiTlsOpen
Definition: apip.h:45
api_attr_w::bFinite
abool bFinite
APG_TRUE if the rule is finite.
Definition: apip.h:104
api_op::luipAchar
luint * luipAchar
pointer to the first character in the achar table for this TLS/TBS operator
Definition: apip.h:86
api_attr_w::bIsComplete
abool bIsComplete
admin
Definition: apip.h:117
api_op::luiMin
luint luiMin
minimum value for REP and TRG opcodes
Definition: apip.h:84
api::spUdts
api_udt * spUdts
Points to an array of UDT structures, if one or more UDTs are referenced in the SABNF grammar.
Definition: apip.h:147
api::uiRuleCount
aint uiRuleCount
The number of rules in the SABNF grammar and in the array.
Definition: apip.h:146
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
api::uipChildIndexTable
aint * uipChildIndexTable
Pointer to a list of child indexes. ALT & CAT operators have two or more children operators....
Definition: apip.h:159
api_rule::bProtected
abool bProtected
if true, this rule will be protected from being hidden under a fully-predictive node in the parse tre...
Definition: apip.h:63
api_op::uiMode
aint uiMode
ID_BKR_MODE_U of ID_BKR_MODE_P for BKR.
Definition: apip.h:89
api::uiChildIndexTableLength
aint uiChildIndexTableLength
The number of indexes (integers) in the child index table.
Definition: apip.h:161
api::uiCopyrightOffset
aint uiCopyrightOffset
Offset into the string table for the Copyright string.
Definition: apip.h:155
api_udt::cpName
char * cpName
pointer to null-terminated string in the string table
Definition: apip.h:70
api::vpLines
void * vpLines
Context pointer to a lines object.
Definition: apip.h:141
api::luiPpptMapCount
luint luiPpptMapCount
The number of operator maps in the table.
Definition: apip.h:172
api::uiLicenseLength
aint uiLicenseLength
Length of the License string.
Definition: apip.h:154
exception
A structure to describe the type and location of a caught exception.
Definition: exception.h:47
alt_data::uiGroupError
aint uiGroupError
Definition: apip.h:42
api_op::uiCase
aint uiCase
ID_BKR_CASE_S or ID_BKR_CASE_I for BKR.
Definition: apip.h:88
api_op::uiIndex
aint uiIndex
index of this referenced rule or UDT
Definition: apip.h:80
api
The API context.
Definition: apip.h:123
api::luipAcharTable
luint * luipAcharTable
Pointer to the Achar Table - a table of all of the alphabet characters referenced by the terminal nod...
Definition: apip.h:157
alt_data::uiGroupOpen
aint uiGroupOpen
Definition: apip.h:41
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition: apg.h:133
api::vpVecGrammar
void * vpVecGrammar
The (achar) input grammar, if sizeof(achar) > sizeof(char).
Definition: apip.h:138
api_rule::bIsOpen
abool bIsOpen
used for walking the SEST, set to true at the root it will tell when a recursive instance of the rule...
Definition: apip.h:60
api_attr_w::uiRecursiveType
aint uiRecursiveType
ID_ATTR_N, ID_ATTR_R, ID_ATTR_MR, ID_ATTR_NMR, or ID_ATTR_RMR.
Definition: apip.h:109
api_attr_w::cpRuleName
char * cpRuleName
the rule name for these attributes
Definition: apip.h:107
api::bSyntaxValid
abool bSyntaxValid
APG_TRUE if the input syntax is valid, APG_FALSE otherwise.
Definition: apip.h:183
api_op
API information about each opcode.
Definition: apip.h:78
api::vpAst
void * vpAst
context handle to the AST object
Definition: apip.h:129
api_udt
API information about each UDT.
Definition: apip.h:69
api::bAttributesComputed
abool bAttributesComputed
APG_TRUE if attributes have been computed (even is there are attribute errors), APG_FALSE otherwise.
Definition: apip.h:188
api::uiVersionOffset
aint uiVersionOffset
Offset into the string table for the Version Number string.
Definition: apip.h:151
api::vpValidate
const void * vpValidate
the "magic number" to indicate that this is a valid context
Definition: apip.h:124
api::vpVecInput
void * vpVecInput
The (ASCII) input grammar files and/or strings accumulate here. Always a NULL-terminated string.
Definition: apip.h:137
api::uiInputLength
aint uiInputLength
The number of input characters.
Definition: apip.h:140
api::vpOutputAcharTable
void * vpOutputAcharTable
Storage for variable character width output parser achar table.
Definition: apip.h:131
api_attr_w::bpRefersTo
abool * bpRefersTo
a list of all the rules that this rule refers to
Definition: apip.h:112
api::uiAcharTableLength
aint uiAcharTableLength
Number of alphabet characters in the Achar Table.
Definition: apip.h:158
api::luiPpptMapSize
luint luiPpptMapSize
The size, in bytes, of a single operator map.
Definition: apip.h:173
api::ucpPpptTable
uint8_t * ucpPpptTable
Pointer to the PPPT table of operator maps.
Definition: apip.h:170
api_op::uiId
aint uiId
type of opcode, ID_ALT, etc.
Definition: apip.h:79
api::uiCopyrightLength
aint uiCopyrightLength
Length of the copyright string.
Definition: apip.h:156
api::bAttributesValid
abool bAttributesValid
APG_TRUE if there the rule attributes have been computed and have no fatal errors,...
Definition: apip.h:186
api::vpVecTempChars
void * vpVecTempChars
Temporary vector of characters. Here for clean up on unusual exit.
Definition: apip.h:142
api_attr_w::bNested
abool bNested
APG_TRUE if the rule is nested recursive.
Definition: apip.h:101
api_op::uiEmpty
aint uiEmpty
APG_TRUE if this UDT can be empty, APG_FALSE otherwise
Definition: apip.h:81
api_attr_w::bIsOpen
abool bIsOpen
admin
Definition: apip.h:116
alt_data::uiOptionError
aint uiOptionError
Definition: apip.h:44
alt_data::uiClsOpen
aint uiClsOpen
Definition: apip.h:46
api::bUsePppt
abool bUsePppt
True of PPPT are being used.
Definition: apip.h:167
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
api::vpAltStack
void * vpAltStack
A temporary vector for the AST translator.
Definition: apip.h:128
api_rule::cpName
char * cpName
pointer to null-terminated string in the string table
Definition: apip.h:56
api_attr_w::bCyclic
abool bCyclic
APG_TRUE if the rule is cyclic.
Definition: apip.h:103
api::uiStringTableLength
aint uiStringTableLength
The number of characters in the string table.
Definition: apip.h:150
api_attr_w::uiRuleIndex
aint uiRuleIndex
the index of the rule for these attributes
Definition: apip.h:108
api_udt::uiIndex
aint uiIndex
index of this UDT in the UDT list
Definition: apip.h:71
api::luiAcharMin
luint luiAcharMin
The minimum alphabet character referenced by the terminal nodes, TLS, TBL & TRG.
Definition: apip.h:174
api_op::uiBkrIndex
aint uiBkrIndex
if BKR, this is the index to the rule or UDT that is being back referenced
Definition: apip.h:90
api::vpParser
void * vpParser
context handle to the SABNF grammar parser object
Definition: apip.h:127
api::vpMem
void * vpMem
Pointer to the memory context used for all memory allocations and exceptions thrown.
Definition: apip.h:126
api_attr_w::uiMRGroup
aint uiMRGroup
the group number, if this is a member of a mutually-recursive group (there may be multiple groups)
Definition: apip.h:110
alt_data::uiOptionOpen
aint uiOptionOpen
Definition: apip.h:43
api::luiAcharMax
luint luiAcharMax
The maximum alphabet character referenced by the terminal nodes, TLS, TBL & TRG.
Definition: apip.h:175
api_attr_w::bEmpty
abool bEmpty
APG_TRUE if the rule can be empty.
Definition: apip.h:105
api_op::uipChildIndex
aint * uipChildIndex
pointer to the first child index of this ALT or CAT operator
Definition: apip.h:82
alt_data::uiProseValOpen
aint uiProseValOpen
Definition: apip.h:47
api::cpLineBuffer
char * cpLineBuffer
Storage variable for intermediate parser line data.
Definition: apip.h:134
api::spException
exception * spException
Definition: apip.h:125
api::bSemanticsValid
abool bSemanticsValid
APG_TRUE if the the input semantics are valid. That is, the opcodes for the parser have been generate...
Definition: apip.h:184
vLineError
void vLineError(api *spCtx, aint uiCharIndex, const char *cpSrc, const char *cpMsg)
Finds the grammar line associated with a character index and formats an error message to the error lo...
Definition: input.c:383
api_rule::uiOpOffset
aint uiOpOffset
offset into the opcode table to the first opcode of this rule
Definition: apip.h:58
api_udt::uiEmpty
aint uiEmpty
APG_TRUE if this UDT can be empty, APG_FALSE otherwise
Definition: apip.h:72
api_rule::bIsComplete
abool bIsComplete
used when processing rules recursively. If the rule is already complete it need not be recursed again...
Definition: apip.h:61
api::luiPpptTableLength
luint luiPpptTableLength
The PPPT length.
Definition: apip.h:171
api_rule::uiOpCount
aint uiOpCount
the number of opcodes in this rule
Definition: apip.h:59
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.