Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
semantics.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 SEMANTICS_H_
34 #define SEMANTICS_H_
35 
37 #define RULENAME_MAX 256
38 
41 typedef struct{
42  char* cpName;
46 } semantic_udt;
47 
50 typedef struct{
60  char* cpName;
64 } semantic_op;
65 
68 typedef struct{
69  char* cpName;
70 // aint uiNameOffset; /**< Offset to the rule name in the string table. Points to a null-term string. */
76  void* vpVecAltStack;
77  void* vpVecCatStack;
78  void* vpVecOps;
80 
83 typedef struct {
85  void* vpMem;
91  char* cpName;
99  void* vpVecRules;
100  void* vpVecUdts;
101 } semantic_data;
102 
103 // prototypes
104 void vSabnfGrammarAstCallbacks(void* vpParserCtx);
105 //void vSabnfGrammarAstCallbacks2(void* vpParserCtx);
106 aint uiFindRule(semantic_rule* spRules, aint uiRuleCount, const char* cpName, aint uiNameLength);
107 aint uiFindUdt(semantic_udt* spUdts, aint uiUdtCount, const char* cpName, aint uiNameLength);
108 
109 #endif /* SEMANTICS_H_ */
semantic_udt::uiIndex
aint uiIndex
Definition: semantics.h:44
semantic_udt::uiEmpty
aint uiEmpty
Definition: semantics.h:45
semantic_op::uiSeq
aint uiSeq
Definition: semantics.h:63
semantic_data::uiNameLength
aint uiNameLength
Definition: semantics.h:93
vSabnfGrammarAstCallbacks
void vSabnfGrammarAstCallbacks(void *vpParserCtx)
Set the callback functions for the AST translation of the semantic phase parse to opcodes.
Definition: semantic-callbacks.c:740
semantic_rule::uiIndex
aint uiIndex
Definition: semantics.h:72
semantic_op::uiNameLength
aint uiNameLength
Definition: semantics.h:61
semantic_op::luiMin
luint luiMin
Definition: semantics.h:53
semantic_op::vpVecChildList
void * vpVecChildList
Definition: semantics.h:52
semantic_udt
Generalized UDT for first-pass semantic processing.
Definition: semantics.h:41
semantic_data
User data passed to the AST translator for use by the AST callback functions.
Definition: semantics.h:83
semantic_rule::vpVecOps
void * vpVecOps
Definition: semantics.h:78
semantic_data::uiNameOffset
aint uiNameOffset
Definition: semantics.h:92
semantic_op::cpName
char * cpName
Definition: semantics.h:60
semantic_data::luiNum
luint luiNum
Definition: semantics.h:89
semantic_rule::uiCurrentCat
aint uiCurrentCat
Definition: semantics.h:74
semantic_data::vpVecRules
void * vpVecRules
Definition: semantics.h:99
uiFindRule
aint uiFindRule(semantic_rule *spRules, aint uiRuleCount, const char *cpName, aint uiNameLength)
Find the index of the named rule in the rule list.
Definition: semantics.c:160
semantic_rule::uiCurrentAlt
aint uiCurrentAlt
Definition: semantics.h:73
semantic_op::uiMode
aint uiMode
Definition: semantics.h:57
semantic_rule::vpVecAltStack
void * vpVecAltStack
Definition: semantics.h:76
semantic_rule::spCurrentOp
semantic_op * spCurrentOp
Definition: semantics.h:75
uiFindUdt
aint uiFindUdt(semantic_udt *spUdts, aint uiUdtCount, const char *cpName, aint uiNameLength)
Definition: semantics.c:172
semantic_op::uiCase
aint uiCase
Definition: semantics.h:56
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
semantic_data::vpVecAcharsTable
void * vpVecAcharsTable
Definition: semantics.h:96
semantic_rule::vpVecCatStack
void * vpVecCatStack
Definition: semantics.h:77
semantic_data::uiRuleIndex
aint uiRuleIndex
Definition: semantics.h:94
semantic_op::uiId
aint uiId
Definition: semantics.h:51
semantic_data::uiIncAlt
aint uiIncAlt
Definition: semantics.h:87
semantic_udt::cpName
char * cpName
Definition: semantics.h:42
api
The API context.
Definition: apip.h:123
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition: apg.h:133
semantic_op::uiBkrIndex
aint uiBkrIndex
Definition: semantics.h:62
semantic_op
Generalized opcode for first-pass semantic processing.
Definition: semantics.h:50
semantic_rule::uiNameLength
aint uiNameLength
Definition: semantics.h:71
semantic_data::spApi
api * spApi
Definition: semantics.h:84
semantic_rule::cpName
char * cpName
Definition: semantics.h:69
semantic_data::vpVecStringTable
void * vpVecStringTable
Definition: semantics.h:98
semantic_op::luiMax
luint luiMax
Definition: semantics.h:54
semantic_udt::uiNameLength
aint uiNameLength
Definition: semantics.h:43
semantic_data::uiUdtIndex
aint uiUdtIndex
Definition: semantics.h:95
semantic_data::spCurrentRule
semantic_rule * spCurrentRule
Definition: semantics.h:90
semantic_op::uiStringIndex
int uiStringIndex
Definition: semantics.h:58
semantic_data::cpName
char * cpName
Definition: semantics.h:91
semantic_rule
Generalized rule for first-pass semantic processing.
Definition: semantics.h:68
semantic_op::uiStringLength
aint uiStringLength
Definition: semantics.h:59
semantic_data::vpVecUdts
void * vpVecUdts
Definition: semantics.h:100
semantic_data::vpVecChildIndexTable
void * vpVecChildIndexTable
Definition: semantics.h:97
semantic_op::uiEmpty
aint uiEmpty
Definition: semantics.h:55
semantic_data::vpMem
void * vpMem
Definition: semantics.h:85
semantic_data::uiErrorsFound
aint uiErrorsFound
Definition: semantics.h:88
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.