Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
library
apg.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
* *************************************************************************************/
30
#ifndef APG_H_7_0_
31
#define APG_H_7_0_
32
61
#include <inttypes.h>
62
64
#define APG_VERSION "7.0"
66
#define APG_COPYRIGHT "Copyright (c) 2021 Lowell D. Thomas, all rights reserved"
67
#define APG_LICENSE "BSD 2-Clause"
68
70
#if defined APG_AINT && APG_AINT == 8
71
typedef
uint8_t
aint
;
72
#elif defined APG_AINT && APG_AINT == 16
73
typedef
uint16_t
aint
;
74
#elif defined APG_AINT && APG_AINT == 32
75
typedef
uint32_t
aint
;
76
#elif defined APG_AINT && APG_AINT == 64
77
typedef
uint64_t
aint
;
78
#else
79
typedef
uint_fast32_t
aint
;
80
#endif
81
82
#if defined APG_ACHAR && APG_ACHAR == 8
83
typedef
uint8_t
achar
;
84
#elif defined APG_ACHAR && APG_ACHAR == 16
85
typedef
uint16_t
achar
;
86
#elif defined APG_ACHAR && APG_ACHAR == 32
87
typedef
uint32_t
achar
;
88
#elif defined APG_ACHAR && APG_ACHAR == 64
89
typedef
uint64_t
achar
;
90
#else
91
typedef
uint_fast8_t
achar
;
92
#endif
93
133
typedef
uintmax_t
luint
;
134
140
typedef
uint8_t
abool
;
141
147
#ifdef APG_DEBUG
149
#define APG_MEM_STATS 1
150
#define APG_VEC_STATS 1
151
#define APG_STATS 1
152
#define APG_TRACE 1
153
#define APG_AST 1
154
#define APG_BKR 1
155
#endif
/* APG_DEBUG */
156
165
#ifdef APG_TRACE
167
#define TRACE_DOWN(x, o, f) if((x))vTraceDown((x), (o), (f))
168
#define TRACE_UP(x, o, s, f, p) if((x))vTraceUp((x), (o), (s), (f), (p));
169
#define TRACE_BEGIN(x) if((x))vTraceBegin((x))
170
#define TRACE_END(x) if((x))vTraceEnd((x))
171
#define TRACE_DTOR(x) if((x))vTraceDtor((x))
172
#else
173
#define TRACE_DOWN(x, o, f)
174
#define TRACE_UP(x, o, s, f, p)
175
#define TRACE_BEGIN(x)
176
#define TRACE_END(x)
177
#define TRACE_DTOR(v)
178
#endif
/* APG_TRACE */
179
188
#ifdef APG_STATS
190
#define STATS_HIT(x, o, s) if((x))vStatsHit((x), (o), (s))
191
#else
192
#define STATS_HIT(x, o, s)
193
#endif
/* APG_STATS */
194
196
// ABNF strict implies that no super set expressions are present in the grammar */
197
#ifdef APG_STRICT_ABNF
198
#undef APG_BKR
199
#endif
/* APG_STRICT_ABNF */
200
211
#ifdef APG_BKR
213
#define BKR_APGEX_CHECK(e)
214
#define BKRU_CTOR(x) vpBkruCtor((x))
215
#define BKRU_RULE_OPEN(x, i) if((x)) vBkruRuleOpen((x), (i))
216
#define BKRU_RULE_CLOSE(x, i, s, o, p) if((x)) vBkruRuleClose((x), (i), (s), (o), (p))
217
#define BKRU_UDT_CLOSE(x, i, s, o, p) if((x)) vBkruUdtClose((x), (i), (s), (o), (p))
218
#define BKRU_OP_OPEN(x) if((x)) vBkruOpOpen((x))
219
#define BKRU_OP_CLOSE(x, s) if((x)) vBkruOpClose((x), (s))
220
#define BKRP_CTOR(x) vpBkrpCtor((x))
221
#define BKRP_RULE_OPEN(x, i) if((x)) vBkrpRuleOpen((x), (i))
222
#define BKRP_RULE_CLOSE(x, i, s, o, p) if((x)) vBkrpRuleClose((x), (i), (s), (o), (p))
223
#define BKRP_UDT_CLOSE(x, i, s, o, p) if((x)) vBkrpUdtClose((x), (i), (s), (o), (p))
224
#define BKRP_OP_OPEN(x) if((x)) vBkrpOpOpen((x))
225
#define BKRP_OP_CLOSE(x, s) if((x)) vBkrpOpClose((x), (s))
226
#else
227
#define BKR_APGEX_CHECK(e) vApgexBkrCheck((e))
228
#define BKRU_CTOR(x) NULL
229
#define BKRU_RULE_OPEN(x, i)
230
#define BKRU_RULE_CLOSE(x, i, s, o, p)
231
#define BKRU_UDT_CLOSE(x, i, s, o, p)
232
#define BKRU_OP_OPEN(x)
233
#define BKRU_OP_CLOSE(x, s)
234
#define BKRP_CTOR(x) NULL
235
#define BKRP_RULE_OPEN(x, i)
236
#define BKRP_RULE_CLOSE(x, i, s, o, p)
237
#define BKRP_UDT_CLOSE(x, i, s, o, p)
238
#define BKRP_OP_OPEN(x)
239
#define BKRP_OP_CLOSE(x, s)
240
#endif
/* APG_BKR */
241
250
#ifdef APG_AST
252
#define AST_CLEAR(v) if(v)vAstClear(v)
253
#define AST_RULE_OPEN(x, l, i, o) if((x) && !(l)) vAstRuleOpen((x), (i), (o))
254
#define AST_RULE_CLOSE(x, l, i, s, o, p) if((x) && !(l)) vAstRuleClose((x), (i), (s), (o), (p))
255
#define AST_OP_OPEN(x, l) if((x)) if((x) && !(l)) vAstOpOpen((x))
256
#define AST_OP_CLOSE(x, l, s) if((x) && !(l)) vAstOpClose((x), (s))
257
#else
258
#define AST_CLEAR(v)
259
#define AST_RULE_OPEN(x, l, i, o)
260
#define AST_RULE_CLOSE(x, l, i, s, o, p)
261
#define AST_OP_OPEN(x, l)
262
#define AST_OP_CLOSE(x, l, s)
263
#endif
/* APG_AST */
264
273
#ifdef APG_NO_PPPT
275
#define PPPT_OPEN(x, o, f)
276
#define PPPT_CLOSE
277
#define PPPT_DEFINED 0
278
#else
279
#define PPPT_OPEN(x, o, f) if(bPpptEval((x), (o), (f))) goto done
280
#define PPPT_CLOSE done:
281
#define PPPT_DEFINED 1
282
#endif
/* APG_NO_PPPT */
283
288
#undef APG_TRUE
290
#undef APG_FALSE
291
#define APG_TRUE 1
292
#define APG_FALSE 0
293
304
#undef APG_SUCCESS
306
#undef APG_FAULURE
307
#define APG_SUCCESS 1
308
#define APG_FAILURE 0
309
316
#undef APG_UNDEFINED
318
#define APG_UNDEFINED ((aint)-1)
319
#undef APG_INFINITE
320
#define APG_INFINITE ((aint)-1)
321
325
#undef APG_MAX_AINT
327
329
#define APG_MAX_AINT ((aint)-2)
330
#undef APG_MAX_ACHAR
331
#define APG_MAX_ACHAR ((achar)-1)
332
334
#endif
/* APG_H_7_0_ */
335
achar
uint_fast8_t achar
achar is the type for the parser's alphabet characters.
Definition:
apg.h:91
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition:
apg.h:79
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition:
apg.h:133
abool
uint8_t abool
abool is the APG bool type.
Definition:
apg.h:140
Generated on Sun Jun 13 2021 14:32:59 for APG by
1.8.17
APG Version 7.0 is licensed under the
2-Clause BSD License
,
an Open Source Initiative Approved License.