Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
attributes.c
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 * *************************************************************************************/
42 #include "./api.h"
43 #include "./apip.h"
44 #include "./attributes.h"
45 
46 static const char* s_cpTrue = "yes";
47 static const char* s_cpFalse = "no";
48 static const char* s_cpFatal = "error";
49 static const char* s_cpEmpty = "empty";
50 static const char* s_cpUndef = "undef";
51 static const void* s_vpMagicNumber = (void*)"attributes";
52 
53 static int iCompName(const void* vpL, const void* vpR);
54 static int iCompType(const void* vpL, const void* vpR);
55 static const char * cpEmpty(abool aTF);
56 static const char * cpBool(abool aTF);
57 static const char * cpShouldBeTrue(abool aTF);
58 static const char * cpShouldBeFalse(abool aTF);
59 static attrs_ctx* spAttrsCtor(api* spApi);
60 
79 abool bApiAttrs(void* vpCtx) {
80  if(!bApiValidate(vpCtx)){
81  vExContext();
82  }
83  api* spApi = (api*) vpCtx;
84  // validate the prerequisites
85  if(!spApi->bSemanticsValid){
86  XTHROW(spApi->spException,
87  "attempting to compute attributes before semantics (opcodes) are complete");
88  }
89 
90  attrs_ctx* spAtt = NULL;
91  spAtt = spAttrsCtor(spApi);
92 
93  // compute rule dependencies
94  vRuleDependencies(spAtt);
95 
96  // compute the rule attributes
97  vRuleAttributes(spAtt);
98 
100  if(spAtt->uiErrorCount){
101  return APG_FALSE;
102  }
103  spApi->bAttributesValid = APG_TRUE;
104  return APG_TRUE;
105 }
106 
116 static attrs_ctx* spAttrsCtor(api* spApi) {
117  if(!bApiValidate(spApi)){
118  vExContext();
119  }
120  attrs_ctx* spCtx = NULL;
121  aint ui;
122  spCtx = (attrs_ctx*) vpMemAlloc(spApi->vpMem, (aint) sizeof(attrs_ctx));
123  memset((void*) spCtx, 0, sizeof(attrs_ctx));
124  spCtx->vpMem = spApi->vpMem;
125  spCtx->spException = spMemException(spApi->vpMem);
126  spCtx->spApi = spApi;
127  spApi->vpAttrsCtx = (void*)spCtx;
128 
129  // allocate the working array of attributes
130  spCtx->spWorkingAttrs = (api_attr_w*) vpMemAlloc(spCtx->vpMem, (aint) ((aint)sizeof(api_attr_w) * spApi->uiRuleCount));
131  memset((void*) spCtx->spWorkingAttrs, 0, (aint) ((aint)sizeof(api_attr_w) * spApi->uiRuleCount));
132 
133  // allocate the final array of attributes
134  spCtx->spAttrs = (api_attr_w*) vpMemAlloc(spCtx->vpMem, (aint) ((aint)sizeof(api_attr_w) * spApi->uiRuleCount));
135  memset((void*) spCtx->spAttrs, 0, (aint) ((aint)sizeof(api_attr_w) * spApi->uiRuleCount));
136 
137  // allocate the array of public attributes
138  spCtx->spPublicAttrs = (api_attr*) vpMemAlloc(spCtx->vpMem, (aint) ((aint)sizeof(api_attr) * spApi->uiRuleCount));
139  memset((void*) spCtx->spPublicAttrs, 0, (aint) ((aint)sizeof(api_attr) * spApi->uiRuleCount));
140 
141  // allocate the array of public error attributes
142  spCtx->spErrorAttrs = (api_attr*) vpMemAlloc(spCtx->vpMem, (aint) ((aint)sizeof(api_attr) * spApi->uiRuleCount));
143  memset((void*) spCtx->spErrorAttrs, 0, (aint) ((aint)sizeof(api_attr) * spApi->uiRuleCount));
144 
145  // initialize the working array of attributes
146  for (ui = 0; ui < spApi->uiRuleCount; ui++) {
147  spCtx->spWorkingAttrs[ui].cpRuleName = spApi->spRules[ui].cpName;
148  spCtx->spWorkingAttrs[ui].uiRuleIndex = spApi->spRules[ui].uiIndex;
149 
150  // get the array of "rules referred to"
151  spCtx->spWorkingAttrs[ui].bpRefersTo = (abool*) vpMemAlloc(spCtx->vpMem,
152  (aint) (sizeof(abool) * spApi->uiRuleCount));
153  memset((void*) spCtx->spWorkingAttrs[ui].bpRefersTo, 0, (sizeof(abool) * spApi->uiRuleCount));
154 
155  // get the array of "referenced by rules"
156  spCtx->spWorkingAttrs[ui].bpIsReferencedBy = (abool*) vpMemAlloc(spCtx->vpMem,
157  (aint) (sizeof(abool) * spApi->uiRuleCount));
158  memset((void*) spCtx->spWorkingAttrs[ui].bpIsReferencedBy, 0, (sizeof(abool) * spApi->uiRuleCount));
159 
160  if(spApi->uiUdtCount){
161  // get the array of "UDTs referred to"
162  spCtx->spWorkingAttrs[ui].bpRefersToUdt = (abool*) vpMemAlloc(spCtx->vpMem,
163  (aint) (sizeof(abool) * spApi->uiUdtCount));
164  memset((void*) spCtx->spWorkingAttrs[ui].bpRefersToUdt, 0, (sizeof(abool) * spApi->uiUdtCount));
165  }
166  }
167 
168  // create the vector of mutually-recursive group numbers
169  spCtx->vpVecGroupNumbers = vpVecCtor(spCtx->vpMem, (aint)sizeof(aint), 10);
170 
171  // success
172  spCtx->vpValidate = s_vpMagicNumber;
173  return spCtx;
174 }
175 
184 void vAttrsDtor(void* vpCtx) {
185  if (vpCtx ) {
186  attrs_ctx* spCtx = (attrs_ctx*) vpCtx;
187  if(spCtx->vpValidate == s_vpMagicNumber){
188  void* vpMem = spCtx->vpMem;
189  vVecDtor(spCtx->vpVecGroupNumbers);
190  aint ui = 0;
191  for(; ui < spCtx->spApi->uiRuleCount; ui++){
192  vMemFree(vpMem, spCtx->spWorkingAttrs[ui].bpRefersTo);
193  vMemFree(vpMem, spCtx->spWorkingAttrs[ui].bpIsReferencedBy);
194  vMemFree(vpMem, spCtx->spWorkingAttrs[ui].bpRefersToUdt);
195  }
196  vMemFree(vpMem, spCtx->spWorkingAttrs);
197  vMemFree(vpMem, spCtx->spAttrs);
198  vMemFree(vpMem, spCtx->spPublicAttrs);
199  vMemFree(vpMem, spCtx->spErrorAttrs);
200  spCtx->spApi->vpAttrsCtx = NULL;
201  memset(vpCtx, 0, sizeof(attrs_ctx));
202  vMemFree(vpMem, vpCtx);
203  }else{
204  vExContext();
205  }
206  }
207 }
208 
220 void vApiAttrsToAscii(void *vpCtx, const char *cpMode, const char* cpFileName) {
221  if (!vpCtx || !bApiValidate(vpCtx)) {
222  vExContext();
223  }
224  api *spApi = (api*) vpCtx;
225  if (!spApi->bAttributesComputed) {
226  XTHROW(spApi->spException,
227  "no attributes available - must first call bApiAttrs()");
228  }
229  FILE *spOut = stdout;
230  if(cpFileName){
231  spOut = fopen(cpFileName, "wb");
232  if (!spOut) {
233  char caBuf[126];
234  snprintf(caBuf, 126, "cannot open file name %s for writing", cpFileName);
235  XTHROW(spApi->spException, caBuf);
236  }
237  }
238  attrs_ctx *spAtt = (attrs_ctx*) spApi->vpAttrsCtx;
239  if(cpMode){
240  if (cpMode[0] == 'a' || cpMode[0] == 'A') {
241  vAttrsByName(spAtt->spPublicAttrs, spApi->uiRuleCount, spOut);
242  } else if (cpMode[0] == 't' || cpMode[0] == 'T') {
243  vAttrsByType(spAtt->spPublicAttrs, spApi->uiRuleCount, spOut);
244  } else {
245  // default to index
246  vAttrsByIndex(spAtt->spPublicAttrs, spApi->uiRuleCount, spOut);
247  }
248  }else{
249  // default to index
250  vAttrsByIndex(spAtt->spPublicAttrs, spApi->uiRuleCount, spOut);
251  }
252  if(spOut != stdout){
253  fclose(spOut);
254  }
255 }
256 
268 void vApiAttrsErrorsToAscii(void *vpCtx, const char *cpMode, const char* cpFileName) {
269  if (!vpCtx || !bApiValidate(vpCtx)) {
270  vExContext();
271  }
272  api *spApi = (api*) vpCtx;
273  if (!spApi->bAttributesComputed) {
274  XTHROW(spApi->spException,
275  "no attributes available - must first call bApiAttrs()");
276  }
277  FILE *spOut = stdout;
278  if(cpFileName){
279  spOut = fopen(cpFileName, "wb");
280  if (!spOut) {
281  char caBuf[126];
282  snprintf(caBuf, 126, "cannot open file name %s for writing", cpFileName);
283  XTHROW(spApi->spException, caBuf);
284  }
285  }
286  attrs_ctx *spAtt = (attrs_ctx*) spApi->vpAttrsCtx;
287  fprintf(spOut, "ATTRIBUTE ERRORS\n");
288  if(spAtt->uiErrorCount){
289  if(cpMode){
290  if (cpMode[0] == 'a' || cpMode[0] == 'A') {
291  vAttrsByName(spAtt->spErrorAttrs, spAtt->uiErrorCount, spOut);
292  } else if (cpMode[0] == 't' || cpMode[0] == 'T') {
293  vAttrsByType(spAtt->spErrorAttrs, spAtt->uiErrorCount, spOut);
294  } else {
295  // default to index
296  vAttrsByIndex(spAtt->spErrorAttrs, spAtt->uiErrorCount, spOut);
297  }
298  }else{
299  // default to index
300  vAttrsByIndex(spAtt->spErrorAttrs, spAtt->uiErrorCount, spOut);
301  }
302  }else{
303  fprintf(spOut, "<none>\n");
304  }
305  if(spOut != stdout){
306  fclose(spOut);
307  }
308 }
309 
310 static void vPrintOneAttrByName(api_attr* a, FILE* spStream){
311  fprintf(spStream, "%7s |%7s |%7s |%7s |%7s |%7s | %s\n",
312  cpShouldBeFalse(a->bLeft), cpBool(a->bNested), cpBool(a->bRight),
313  cpShouldBeFalse(a->bCyclic),
314  cpEmpty(a->bEmpty), cpShouldBeTrue(a->bFinite),
315  a->cpRuleName);
316 }
317 static void vPrintOneAttrByType(api_attr* a, FILE* spStream){
318  if(a->uiRecursiveType == ID_ATTR_MR){
319  fprintf(spStream, "%7s |%7s |%7s |%7s |%7s |%7s |%7"PRIuMAX" |%7s | %s\n",
320  cpShouldBeFalse(a->bLeft), cpBool(a->bNested), cpBool(a->bRight),
321  cpShouldBeFalse(a->bCyclic),
322  cpEmpty(a->bEmpty), cpShouldBeTrue(a->bFinite),
324  }else{
325  fprintf(spStream, "%7s |%7s |%7s |%7s |%7s |%7s | |%7s | %s\n",
326  cpShouldBeFalse(a->bLeft), cpBool(a->bNested), cpBool(a->bRight),
327  cpShouldBeFalse(a->bCyclic),
328  cpEmpty(a->bEmpty), cpShouldBeTrue(a->bFinite),
330  }
331 }
337 void vAttrsByType(api_attr* spAttrs, aint uiCount, FILE* spStream){
338  aint ui;
339  api_attr sAttrs[uiCount];
340  for(ui = 0; ui < uiCount; ui++){
341  sAttrs[ui] = spAttrs[ui];
342  }
343  qsort((void*)&sAttrs[0], uiCount, sizeof(api_attr), iCompName);
344  qsort((void*)&sAttrs[0], uiCount, sizeof(api_attr), iCompType);
345  fprintf(spStream, "ATTRIBUTES BY TYPE\n");
346  fprintf(spStream, " left | nested | right | cyclic | empty | finite | group | type | name\n");
347  fprintf(spStream, "--------|--------|--------|--------|--------|--------|--------|--------|--------\n");
348  for(ui = 0; ui < uiCount; ui++){
349  vPrintOneAttrByType(&sAttrs[ui], spStream);
350  }
351  fprintf(spStream, "\n");
352 }
358 void vAttrsByName(api_attr* spAttrs, aint uiCount, FILE* spStream){
359  aint ui;
360  api_attr sAttrs[uiCount];
361  for(ui = 0; ui < uiCount; ui++){
362  sAttrs[ui] = spAttrs[ui];
363  }
364  qsort((void*)&sAttrs[0], uiCount, sizeof(api_attr), iCompName);
365 
366  fprintf(spStream, "ATTRIBUTES BY NAME\n");
367  fprintf(spStream, " left | nested | right | cyclic | empty | finite | name\n");
368  fprintf(spStream, "--------|--------|--------|--------|--------|--------|--------\n");
369  for(ui = 0; ui < uiCount; ui++){
370  vPrintOneAttrByName(&sAttrs[ui], spStream);
371  }
372  fprintf(spStream, "\n");
373 }
379 void vAttrsByIndex(api_attr* spAttrs, aint uiCount, FILE* spStream){
380  aint ui;
381  fprintf(spStream, "ATTRIBUTES BY INDEX\n");
382  fprintf(spStream, " left | nested | right | cyclic | empty | finite | name\n");
383  fprintf(spStream, "--------|--------|--------|--------|--------|--------|--------\n");
384  for(ui = 0; ui < uiCount; ui++){
385  vPrintOneAttrByName(&spAttrs[ui], spStream);
386  }
387  fprintf(spStream, "\n");
388 }
389 
390 static int iCompName(const void* vpL, const void* vpR) {
391  api_attr* spL = (api_attr*) vpL;
392  api_attr* spR = (api_attr*) vpR;
393  aint uiLenL = strlen(spL->cpRuleName);
394  aint uiLenR = strlen(spR->cpRuleName);
395  char l, r;
396  const char* cpL = spL->cpRuleName;
397  const char* cpR = spR->cpRuleName;
398  aint uiLesser = uiLenL < uiLenR ? uiLenL : uiLenR;
399  while (uiLesser--) {
400  l = *cpL;
401  if (l >= 65 && l <= 90) {
402  l += 32;
403  }
404  r = *cpR;
405  if (r >= 65 && r <= 90) {
406  r += 32;
407  }
408  if (l < r) {
409  return -1;
410  }
411  if (l > r) {
412  return 1;
413  }
414  cpL++;
415  cpR++;
416  }
417  if (uiLenL < uiLenR) {
418  return -1;
419  }
420  if (uiLenL > uiLenR) {
421  return 1;
422  }
423  return 0;
424 }
425 static const char * cpBool(abool aTF){
426  if(aTF == APG_TRUE){
427  return s_cpTrue;
428  }
429  if(aTF == APG_FALSE){
430  return s_cpFalse;
431  }
432  return s_cpUndef;
433 }
434 static const char * cpEmpty(abool aTF){
435  if(aTF == APG_TRUE){
436  return s_cpEmpty;
437  }
438  if(aTF == APG_FALSE){
439  return s_cpFalse;
440  }
441  return s_cpUndef;
442 }
443 static const char * cpShouldBeTrue(abool aTF){
444  if(aTF == APG_TRUE){
445  return s_cpTrue;
446  }
447  if(aTF == APG_FALSE){
448  return s_cpFatal;
449  }
450  return s_cpUndef;
451 }
452 static const char * cpShouldBeFalse(abool aTF){
453  if(aTF == APG_TRUE){
454  return s_cpFatal;
455  }
456  if(aTF == APG_FALSE){
457  return s_cpFalse;
458  }
459  return s_cpUndef;
460 }
461 static int iCompType(const void* vpL, const void* vpR) {
462  api_attr* spL = (api_attr*)vpL;
463  api_attr* spR = (api_attr*)vpR;
464  if(spL->uiRecursiveType == ID_ATTR_MR && spR->uiRecursiveType == ID_ATTR_MR){
465  if(spL->uiMRGroup < spR->uiMRGroup){
466  return -1;
467  }
468  if(spL->uiMRGroup > spR->uiMRGroup){
469  return 1;
470  }
471  return 0;
472  }
473  if(spL->uiRecursiveType < spR->uiRecursiveType){
474  return -1;
475  }
476  if(spL->uiRecursiveType > spR->uiRecursiveType){
477  return 1;
478  }
479  return 0;
480 }
484 const char * cpType(aint uiId){
485  char* cpReturn = "UNKNOWN";
486  switch(uiId){
487  case ID_ATTR_N:
488  cpReturn = "N";
489  break;
490  case ID_ATTR_R:
491  cpReturn = "R";
492  break;
493  case ID_ATTR_MR:
494  cpReturn = "MR";
495  break;
496  }
497  return cpReturn;
498 }
499 
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
bApiValidate
abool bApiValidate(void *vpCtx)
Validates an API context pointer.
Definition: api.c:104
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
vRuleAttributes
void vRuleAttributes(attrs_ctx *spAtt)
Computes the attributes of each rule in the grammar.
Definition: rule-attributes.c:112
api_attr_w::bpIsReferencedBy
abool * bpIsReferencedBy
a list of all the rules that refer to this rule
Definition: apip.h:113
api_attr::bFinite
abool bFinite
APG_TRUE if the rule is finite.
Definition: api.h:72
attrs_ctx
The API will construct an attributes object. This is the attribute object's context.
Definition: attributes.h:41
api_attr_w
Working attribute information about a each rule.
Definition: apip.h:99
api_attr::bEmpty
abool bEmpty
APG_TRUE if the rule can be empty.
Definition: api.h:73
vVecDtor
void vVecDtor(void *vpCtx)
The vector component destructor.
Definition: vector.c:161
apip.h
Private header file for the APG API suite of functions.
vExContext
void vExContext()
Handles bad context pointers.
Definition: exception.c:126
attrs_ctx::vpValidate
const void * vpValidate
True if the context is valid.
Definition: attributes.h:42
api::vpAttrsCtx
void * vpAttrsCtx
context handle to the attributes object
Definition: apip.h:130
api_attr::uiMRGroup
aint uiMRGroup
the group number, if this is a member of a mutually-recursive group (there may be multiple groups)
Definition: api.h:77
bApiAttrs
abool bApiAttrs(void *vpCtx)
Computes the grammar's attributes.
Definition: attributes.c:79
api_attr::bNested
abool bNested
APG_TRUE if the rule is nested recursive.
Definition: api.h:69
api_attr
The recursive attributes of a single SABNF grammra rule.
Definition: api.h:67
api_attr::cpRuleName
const char * cpRuleName
the rule name for these attributes
Definition: api.h:74
ID_ATTR_N
#define ID_ATTR_N
rule is non-recursive - never refers to itself
Definition: parser.h:100
XTHROW
#define XTHROW(ctx, msg)
Exception throw macro.
Definition: exception.h:67
cpType
const char * cpType(aint uiId)
Convert an attribute type ID to an ASCII string.
Definition: attributes.c:484
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
spMemException
exception * spMemException(void *vpCtx)
Get a pointer to this memory objects's exception handler.
Definition: memory.c:174
vpMemAlloc
void * vpMemAlloc(void *vpCtx, aint uiBytes)
Allocates memory.
Definition: memory.c:196
vAttrsByType
void vAttrsByType(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by attribute type.
Definition: attributes.c:337
vpVecCtor
void * vpVecCtor(void *vpMem, aint uiElementSize, aint uiInitialAlloc)
The vector object constructor.
Definition: vector.c:118
attrs_ctx::spErrorAttrs
api_attr * spErrorAttrs
An array of all rule attributes that have errors. (i.e. left recursive)
Definition: attributes.h:50
vMemFree
void vMemFree(void *vpCtx, const void *vpData)
Free memory previously allocated with vpMemAlloc().
Definition: memory.c:226
attrs_ctx::spApi
api * spApi
Pointer to the parent API context.
Definition: attributes.h:45
vRuleDependencies
void vRuleDependencies(attrs_ctx *spAtt)
Compute each rule's dependencies on the other rules, and possibly on itself if the rule is recursive.
Definition: rule-dependencies.c:58
vApiAttrsErrorsToAscii
void vApiAttrsErrorsToAscii(void *vpCtx, const char *cpMode, const char *cpFileName)
Display all rule attributes with errors.
Definition: attributes.c:268
api
The API context.
Definition: apip.h:123
attrs_ctx::vpMem
void * vpMem
Pointer to the memory context inherited from the parent API.
Definition: attributes.h:44
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition: apg.h:133
api_attr::uiRecursiveType
aint uiRecursiveType
ID_ATTR_N, ID_ATTR_R, ID_ATTR_MR, ID_ATTR_NMR, or ID_ATTR_RMR.
Definition: api.h:76
attrs_ctx::vpVecGroupNumbers
void * vpVecGroupNumbers
A vector for the discovery of groups of mutually recursive rules.
Definition: attributes.h:53
attributes.h
Header file for the attributes functions.
api::bAttributesComputed
abool bAttributesComputed
APG_TRUE if attributes have been computed (even is there are attribute errors), APG_FALSE otherwise.
Definition: apip.h:188
ID_ATTR_MR
#define ID_ATTR_MR
rule is one of a mutually-recursive group (each rule in the group refers to itself and all others)
Definition: parser.h:102
api_attr::bLeft
abool bLeft
APG_TRUE if the rule is left recursive.
Definition: api.h:68
api_attr::bRight
abool bRight
APG_TRUE if the rule is right recursive.
Definition: api.h:70
api_attr::bCyclic
abool bCyclic
APG_TRUE if the rule is cyclic.
Definition: api.h:71
api_attr_w::bpRefersTo
abool * bpRefersTo
a list of all the rules that this rule refers to
Definition: apip.h:112
vApiAttrsToAscii
void vApiAttrsToAscii(void *vpCtx, const char *cpMode, const char *cpFileName)
Display all rule attributes.
Definition: attributes.c:220
APG_TRUE
#define APG_TRUE
Definition: apg.h:291
api::bAttributesValid
abool bAttributesValid
APG_TRUE if there the rule attributes have been computed and have no fatal errors,...
Definition: apip.h:186
attrs_ctx::spWorkingAttrs
api_attr_w * spWorkingAttrs
An array of private attribute structures.
Definition: attributes.h:46
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
api_rule::cpName
char * cpName
pointer to null-terminated string in the string table
Definition: apip.h:56
api::vpMem
void * vpMem
Pointer to the memory context used for all memory allocations and exceptions thrown.
Definition: apip.h:126
ID_ATTR_R
#define ID_ATTR_R
rule is recursive - refers to itself, directly or indirectly, one or more times
Definition: parser.h:101
attrs_ctx::spAttrs
api_attr_w * spAttrs
An array of private attribute structures used in their construction.
Definition: attributes.h:48
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
vAttrsByIndex
void vAttrsByIndex(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by rule index.
Definition: attributes.c:379
vAttrsByName
void vAttrsByName(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by rule name.
Definition: attributes.c:358
vAttrsDtor
void vAttrsDtor(void *vpCtx)
The API object destructor.
Definition: attributes.c:184
attrs_ctx::spPublicAttrs
api_attr * spPublicAttrs
When attributes a complete, the public version strips some of the unneeded variables used only in con...
Definition: attributes.h:49
attrs_ctx::uiErrorCount
aint uiErrorCount
The number of rules that have attribute errors.
Definition: attributes.h:52
api.h
Public header file for the APG API suite of functions.
APG_FALSE
#define APG_FALSE
Definition: apg.h:292
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.