Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
|
Go to the documentation of this file.
45 #ifdef DEPENDENCIES_DEBUG
46 static void vPrintReferences(
attrs_ctx* spAtt);
47 static void vPrintReferals(
attrs_ctx* spAtt);
48 static void vPrintRulesByType(
attrs_ctx* spAtt);
60 aint ui, uj, uiNewGroup, uiGroupNumber;
64 abool baIsScanned[uiRuleCount];
67 for (ui = 0; ui < uiRuleCount; ui++) {
68 memset((
void*)baIsScanned, 0, (
sizeof(
abool) * uiRuleCount));
73 for (ui = 0; ui < uiRuleCount; ui++) {
74 for (uj = 0; uj < uiRuleCount; uj++) {
93 for (ui = 0; ui < uiRuleCount; ui++) {
118 #ifdef DEPENDENCIES_DEBUG
119 vPrintReferences(spAtt);
120 vPrintReferals(spAtt);
121 vPrintRulesByType(spAtt);
131 bpIsScanned[uiRuleIndex] =
APG_TRUE;
132 for (; spOp < spOpEnd; spOp++) {
135 if(!bpIsScanned[spOp->
uiIndex]){
136 vScan(spAtt, spOp->
uiIndex, spAttr, bpIsScanned);
145 vScan(spAtt, spOp->
uiBkrIndex, spAttr, bpIsScanned);
154 #ifdef DEPENDENCIES_DEBUG
155 static void vPrintReferences(
attrs_ctx* spAtt) {
156 aint ui, uj, uiCount;
159 printf(
"RULE REFERENCES\n");
162 printf(
"%s refers to:\n", spAttri->
cpRuleName);
172 printf(
" %s\n",
"<none>");
178 static void vPrintReferals(
attrs_ctx* spAtt) {
179 aint ui, uj, uiCount;
182 printf(
"RULE REFERALS\n");
185 printf(
"%s is referenced by:\n", spAttri->
cpRuleName);
195 printf(
" %s\n",
"<none>");
203 printf(
"%s is referenced by:\n", spUdt->
cpName);
213 printf(
" %s\n",
"<none>");
220 static void vPrintRulesByType(
attrs_ctx* spAtt) {
222 aint ui, uj, uiCount;
224 printf(
"ID_ATTR_N (non-recursive, never refers to itself)\n");
225 for (ui = 0, uiCount = 0; ui < spApi->
uiRuleCount; ui++) {
241 printf(
"ID_ATTR_R (recursive, refers to itself)\n");
242 for (ui = 0, uiCount = 0; ui < spApi->
uiRuleCount; ui++) {
259 "ID_ATTR_MR (mutually-recursive, within a set, each rule refers to every other rule in the set, including itself)\n");
260 for (ui = 0, uiCount = 0; ui < spApi->
uiRuleCount; ui++) {
268 printf(
"index| set| name\n");
269 printf(
"-----|------|-----\n");
270 for (uj = 1; uj <= uiCount; uj++) {
abool * bpRefersToUdt
a list of all the UDTs that this rule refers to
aint uiUdtCount
The number of UDTs referenced in the SABNF grammar.
api_rule * spRules
Points to an array of rule structures.
abool * bpIsReferencedBy
a list of all the rules that refer to this rule
api_op * spOpcodes
Pointer to the array of opcodes for the SANF grammar.
The API will construct an attributes object. This is the attribute object's context.
Working attribute information about a each rule.
#define ID_BKR
back reference to a previously matched rule or UDT name
#define ID_UDT
user-defined terminal
API information about each rule.
Private header file for the APG API suite of functions.
#define ID_ATTR_N
rule is non-recursive - never refers to itself
api_udt * spUdts
Points to an array of UDT structures, if one or more UDTs are referenced in the SABNF grammar.
aint uiRuleCount
The number of rules in the SABNF grammar and in the array.
uint_fast32_t aint
The APG parser's unsigned integer type.
char * cpName
pointer to null-terminated string in the string table
api * spApi
Pointer to the parent API context.
aint uiIndex
index of this referenced rule or UDT
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
aint uiRecursiveType
ID_ATTR_N, ID_ATTR_R, ID_ATTR_MR, ID_ATTR_NMR, or ID_ATTR_RMR.
char * cpRuleName
the rule name for these attributes
API information about each opcode.
API information about each UDT.
void * vpVecGroupNumbers
A vector for the discovery of groups of mutually recursive rules.
Header file for the attributes functions.
#define ID_ATTR_MR
rule is one of a mutually-recursive group (each rule in the group refers to itself and all others)
abool * bpRefersTo
a list of all the rules that this rule refers to
aint uiId
type of opcode, ID_ALT, etc.
api_attr_w * spWorkingAttrs
An array of private attribute structures.
uint8_t abool
abool is the APG bool type.
aint uiRuleIndex
the index of the rule for these attributes
aint uiIndex
index of this UDT in the UDT list
aint uiBkrIndex
if BKR, this is the index to the rule or UDT that is being back referenced
aint uiMRGroup
the group number, if this is a member of a mutually-recursive group (there may be multiple groups)
#define ID_ATTR_R
rule is recursive - refers to itself, directly or indirectly, one or more times
void vRuleDependencies(attrs_ctx *spAtt)
Compute each rule's dependencies on the other rules, and possibly on itself if the rule is recursive.
aint uiOpOffset
offset into the opcode table to the first opcode of this rule
void * vpVecPush(void *vpCtx, void *vpElement)
Adds one element to the end of the array.
aint uiOpCount
the number of opcodes in this rule
Public header file for the APG API suite of functions.
APG Version 7.0 is licensed under the
2-Clause BSD License,
an Open Source Initiative Approved License.