Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
attributes.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 * *************************************************************************************/
32 
33 #ifndef ATTRIBUTES_H_
34 #define ATTRIBUTES_H_
35 
36 #define BOOL_UNDEFINED ((abool)-1)
37 
41 typedef struct{
42  const void* vpValidate;
44  void* vpMem;
47  api_attr_w* spAttrs;
54 } attrs_ctx;
55 
56 // private prototypes
57 void vAttrsDtor(void* vpCtx);
58 void vRuleDependencies(attrs_ctx* spAtt);
59 void vRuleAttributes(attrs_ctx* spAtt);
60 void vAttrsByName(api_attr* spAttrs, aint uiCount, FILE* spStream);
61 void vAttrsByIndex(api_attr* spAttrs, aint uiCount, FILE* spStream);
62 void vAttrsByType(api_attr* spAttrs, aint uiCount, FILE* spStream);
63 const char * cpType(aint uiId);
64 
432 #endif /* ATTRIBUTES_H_ */
vRuleAttributes
void vRuleAttributes(attrs_ctx *spAtt)
Computes the attributes of each rule in the grammar.
Definition: rule-attributes.c:112
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
attrs_ctx::uiStartRule
aint uiStartRule
The grammar start rule.
Definition: attributes.h:51
attrs_ctx::vpValidate
const void * vpValidate
True if the context is valid.
Definition: attributes.h:42
api_attr
The recursive attributes of a single SABNF grammra rule.
Definition: api.h:67
vAttrsByName
void vAttrsByName(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by rule name.
Definition: attributes.c:358
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
cpType
const char * cpType(aint uiId)
Convert an attribute type ID to an ASCII string.
Definition: attributes.c:484
vAttrsByType
void vAttrsByType(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by attribute type.
Definition: attributes.c:337
exception
A structure to describe the type and location of a caught exception.
Definition: exception.h:47
attrs_ctx::spErrorAttrs
api_attr * spErrorAttrs
An array of all rule attributes that have errors. (i.e. left recursive)
Definition: attributes.h:50
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
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
attrs_ctx::vpVecGroupNumbers
void * vpVecGroupNumbers
A vector for the discovery of groups of mutually recursive rules.
Definition: attributes.h:53
attrs_ctx::spException
exception * spException
Pointer to the exception context inherited from the parent API.
Definition: attributes.h:43
vAttrsDtor
void vAttrsDtor(void *vpCtx)
The API object destructor.
Definition: attributes.c:184
attrs_ctx::spWorkingAttrs
api_attr_w * spWorkingAttrs
An array of private attribute structures.
Definition: attributes.h:46
vAttrsByIndex
void vAttrsByIndex(api_attr *spAttrs, aint uiCount, FILE *spStream)
Display the attributes sorted by rule index.
Definition: attributes.c:379
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
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.