DyLP
1.10.4
Toggle main menu visibility
Loading...
Searching...
No Matches
src
DylpStdLib
dylib_bnfrdr.h
Go to the documentation of this file.
1
#ifndef _DYLIB_BNFRDR_H
2
#define _DYLIB_BNFRDR_H
3
4
/*
5
This file is part of the support library for the Dylp LP distribution.
6
7
Copyright (C) 2005 -- 2007 Lou Hafer
8
9
School of Computing Science
10
Simon Fraser University
11
Burnaby, B.C., V5A 1S6, Canada
12
lou@cs.sfu.ca
13
14
This code is licensed under the terms of the Eclipse Public License (EPL).
15
*/
16
17
#include "
dylib_io.h
"
18
19
/*
20
sccs: @(#)bnfrdr.h 3.5 09/01/99
21
svn/cvs: "$Id: dylib_bnfrdr.h 407 2010-12-31 20:48:48Z lou $" ;
22
23
This file contains the structure definitions required to use the bnf reader
24
package. The bnf reader depends heavily on the following two assumptions:
25
26
* There is some pointer type into which any other pointer can be cast and
27
recovered.
28
29
* An int can be cast into a pointer and recovered. This is used to prevent
30
the complexity of the bnf data structure from getting out of hand, but
31
could be avoided at the expense of a substantial increase in its size and
32
awkwardness of use.
33
34
The basic scheme is something like this. At the bottom, we have a number of
35
terminal constructs: immediates, literals, terminals, and labels of various
36
flavours. Above these are the three non-terminal constructs: primitives,
37
non-primitives, and generators. The non-terminals have bodies which are made
38
up of references to other terminal or non-terminal constructs. Generator
39
bodies have only one parse; primitive and non-primitive bodies can have a
40
number of alternative parses. A picture is probably in order here:
41
42
definition body
43
44
---------- ---------- ---------- ----------
45
| | ---> | | ---> | ref | ---> | defn |
46
---------- ---------- ---------- ----------
47
| .... |
48
---------- ---------- ----------
49
| | ---> | ref | ---> | defn |
50
---------- ---------- ----------
51
52
A definition contains a pointer to its body, which is an array of pointers to
53
references. Each reference points to a definition. Essentially, a reference
54
specifies how the second definition is to be used in the context of the body
55
of the first definition.
56
57
The bnf reader has the capability to create arbitrary links in the data
58
structure it's building. Some terminology will make things easier:
59
60
| .... |
61
---------- ----------
62
socket -->| label -+----->| |
63
---------- ----------
64
| .... | | .... |
65
66
The value of a label is the address of something. To make a link, the
67
value of the label has to be stored. The place where it is stored is
68
called a socket. The value of a socket is the address of the field where
69
the value of the label is stored. When it defines a socket, the bnf reader
70
associates a name with an address; similarly for a label. Both socket and
71
label references cause a label to be stored in a socket; the difference
72
between the two lies in which of the socket or label can be undefined when
73
the reference is processed.
74
75
When it's not important to distinguish between sockets and labels, the
76
documentation uses label to include both.
77
78
To write a bnf, you use the set of macros defined at the end of
79
the file. For a detailed explanation of the sorts of things that can be
80
specified with the bnf, the user should take a look at the supplementary
81
documentation. The structures and code will make a lot more sense afterward.
82
*/
83
84
␌
85
86
/*
87
Definitions of enum types used as codes in the bnf structures which follow.
88
*/
89
90
/*
91
bnftype_enum codes the type of the bnf definition.
92
93
Value Description
94
----- -----------
95
bnfG Generator definition
96
bnfNP Non-primitive definition
97
bnfP Primitive definition
98
bnfT Terminal definition
99
bnfDS Socket definition definition
100
bnfDL Label definition definition
101
bnfRS Socket reference definition
102
bnfRL Label reference definition
103
bnfI Immediate value definition
104
bnfL Literal definition
105
*/
106
107
typedef
enum
{
bnfG
,
bnfNP
,
bnfP
,
bnfT
,
bnfDS
,
108
bnfDL
,
bnfRS
,
bnfRL
,
bnfI
,
bnfL
}
bnftype_enum
;
109
110
111
/*
112
bnfttype_enum codes the type of lexeme expected by a terminal.
113
114
Value Description
115
----- -----------
116
bnfttNIL the null lexeme
117
bnfttN number
118
bnfttID identifier
119
bnfttD delimiter
120
bnfttF fixed-length string
121
bnfttQ quoted string
122
*/
123
124
typedef
enum
{
bnfttNIL
,
bnfttN
,
bnfttID
,
bnfttD
,
bnfttF
,
bnfttQ
}
bnfttype_enum
;
125
126
127
/*
128
bnflblsrc_enum codes the way in which text strings used for label names
129
are obtained.
130
131
Value Description
132
----- -----------
133
bnfncBNF A bnf is supplied which will produce a text string. If this
134
code appears in the context of a name, the string will be the
135
name of the label. If it appears in the context of a value,
136
the string will be used as a label name and the value
137
associated with the name will become the value of the label
138
being defined.
139
bnfncS An index in the saved text array is supplied. The string
140
retrieved is interpreted as for bnfncBNF.
141
bnfncC The value of curnde is used as the socket/label value. This
142
code is not valid in the context of a name.
143
bnfncN The value of newnde is used as the socket/label value. This
144
code is not valid in the context of a name.
145
*/
146
147
typedef
enum
{
bnfncBNF
,
bnfncS
,
bnfncC
,
bnfncN
}
bnflblsrc_enum
;
148
149
␌
150
151
/*
152
Flag definitions used in bnf definitions.
153
154
Flag Description
155
---- -----------
156
bnfadv Indicates the redefinition of a previously defined label. The
157
usual context for use is to redefine (advance) a label which
158
is the link in a linked list.
159
bnfsvnd Save the text string developed by the nd part of a label
160
definition definition or label reference definition.
161
bnfsvnm Save the text string developed by the nm part of a label
162
definition definition or label reference definition. This
163
flag is also used in literal definitions to indicate that text
164
should be retrieved from the saved text array.
165
*/
166
167
#define bnfadv 1<<0
168
#define bnfsvnd 1<<1
169
#define bnfsvnm 1<<2
170
171
172
/*
173
Flag definitions used in bnf references.
174
175
Flag Description
176
---- -----------
177
bnflst The definition referenced describes one element of a list of
178
indefinite length.
179
bnfstore The value produced by the referenced bnf will be stored
180
somehow, and the offset field should be valid.
181
bnfatsgn Store a pointer to the character string produced by the
182
referenced bnf, rather than the string itself.
183
bnfstbg The bnf referenced as the separator between list elements is
184
really the beginning of the next list element. (Hence we'll
185
have to back up over it once we recognize it.)
186
bnfflt A float number is expected here.
187
bnfdbl A double number is expected here.
188
bnfcs Forces a case-sensitive comparison of the string read for a
189
terminal with the value specified in the terminal definition.
190
bnfmin Requests a minimum-length comparison - as long as the string
191
parsed for the terminal matches the value specified in the
192
terminal definition up to the end of the parsed string, the
193
comparison succeeds.
194
bnfsv Used in primitives to indicate that the string is to be stored
195
in the savedtxt array. The offset should be a valid savedtxt
196
index in this case.
197
bnfexact (bnfttF only) used to prevent the addition of the null
198
terminator at the end of a character string when the string
199
is stored directly in a field (must be specified to store a
200
single char in a field of size sizeof(char))
201
bnfdebug Debugging should be activated for this reference and all
202
bnf rules nested within it.
203
*/
204
205
#define bnflst 1<<0
206
#define bnfstore 1<<1
207
#define bnfatsgn 1<<2
208
#define bnfstbg 1<<3
209
#define bnfflt 1<<4
210
#define bnfcs 1<<5
211
#define bnfmin 1<<6
212
#define bnfsv 1<<7
213
#define bnfexact 1<<8
214
#define bnfdebug 1<<9
215
#define bnfdbl 1<<10
216
217
␌
218
219
/*
220
Bnfrdr regularly uses the first ([0]) entry of an array of addresses to hold
221
the number of addresses in the array. In order to convert this back to an
222
integer without triggering compiler warnings, the code uses this macro.
223
*/
224
225
# define addrToInt(zz_addr_zz) \
226
((int) (((char *)(zz_addr_zz)) - ((char *)(0))))
227
228
/*
229
Data structures used for bnf definitions. There are three types of things
230
here: individual structures for the various definition types, a common
231
structure which consists only of the fields common to all of the individual
232
structures, and a pointer union which is handy when walking around in a bnf.
233
234
For C++ fans: really, what we're doing here is faking a base class and
235
derived classes, with early 1980's technology.
236
237
Just to keep the explanation in hand a bit, let's define components and
238
alternatives. The body of a bnf definition consists of alternatives
239
(alternative parses), each of which has a number of components. A component
240
array is an array of pointers to bnf reference structures, each of which in
241
turn references a bnf definition structure. An alternative array is an array
242
of pointers to component arrays. I know this is ugly and involves a lot of
243
dereferencing but it seems to be the only way to handle the variable lengths
244
involved.
245
246
NOTE: To keep things from getting completely out of hand, the first entry
247
in a component or alternative array specifies the number of pointers
248
that follow. This is an abuse of type and casting. Bad when the world
249
was 32-bit architectures. Worse now that it's a mix of 32- and 64-bit
250
architectures. See the addrToInt macro above.
251
*/
252
253
/*
254
The common portion.
255
256
Field Description
257
----- -----------
258
type Type code identifying what sort of definition this is.
259
name The name of the rule (derived from the C variable name;
260
see the macros gdef, npdef, etc.)
261
*/
262
263
#define bnfdef_common bnftype_enum type ; \
264
const char *name ;
265
266
typedef
struct
{
bnfdef_common
}
bnfdef_struct
;
267
268
269
/*
270
Data structure for a generator definition. Generators cause the creation of a
271
node in the data structure being built for the user. For simplicity, they may
272
not have alternative parses, but since they can reference non-primitives no
273
flexibility is lost.
274
275
Field Description
276
----- -----------
277
bnfdef_common As above.
278
size Size (in bytes) of the node to be created.
279
link Offset (in bytes) from the base of the node created by the
280
generator to the field used as a link field when this node is
281
in a linked list.
282
comps Pointer to a component array.
283
*/
284
285
typedef
struct
{
bnfdef_common
286
int
size
;
287
int
link
;
288
struct
bnfref_struct_tag
**
comps
; }
bnfGdef_struct
;
289
290
291
/*
292
Data structure for a non-primitive definition. Non-primitives are simply a
293
device for defining alternative parses. They don't directly create anything.
294
295
Field Description
296
----- -----------
297
bnfdef_common As above.
298
alts Pointer to an alternative array.
299
*/
300
301
typedef
struct
{
bnfdef_common
302
struct
bnfref_struct_tag
***
alts
; }
bnfNPdef_struct
;
303
304
305
306
/*
307
Data structure for a primitive definition. The distinction between a
308
primitive and a non-primitive is that a primitive constructs a string which
309
is the concatenation of the strings returned by the bnf's referenced in the
310
primitive's body. The data structure is identical to that for non-primitives.
311
*/
312
313
typedef
bnfNPdef_struct
bnfPdef_struct
;
314
315
316
/*
317
Data structure for a terminal. Terminals are used to specify specific things
318
to be obtained from the input stream. The various parameters required to
319
describe a terminal should really be mushed into a union, but then the bnf
320
data structure would have to be built dynamically, since unions can't be
321
initialized.
322
323
Field Description
324
----- -----------
325
bnfdef_common As above.
326
ttype Code identifying the type of terminal to be obtained.
327
qschr Starting character for a quoted string.
328
qechr Ending character for a quoted string.
329
parm1 Overloaded field, interpreted as follows:
330
numbers: specifies the radix
331
fixed-length strings: specifies the string length
332
val Expected value of the string obtained from the input stream.
333
(This test is applied before the string is converted to the
334
internal form appropriate for whatever is specified in ttype.)
335
*/
336
337
typedef
struct
{
bnfdef_common
338
bnfttype_enum
ttype
;
339
char
qschr
;
340
char
qechr
;
341
int
parm1
;
342
const
char
*
val
; }
bnfTdef_struct
;
343
344
345
/*
346
Data structure for an immediate value. Immediates are used to jam a code into
347
the data structure being built.
348
349
Field Description
350
----- -----------
351
bnfdef_common As above.
352
ival Integer value.
353
*/
354
355
typedef
struct
{
bnfdef_common
356
int
ival
; }
bnfIdef_struct
;
357
358
359
/*
360
Data structure for a literal. Literals are used to insert characters into the
361
input stream. (Handy for generating label names, for instance.)
362
363
Field Description
364
----- -----------
365
bnfdef_common As above.
366
dflgs Flags.
367
txt The string to be inserted. This field is also used to index
368
into the saved text array by casting it to an int.
369
*/
370
371
typedef
struct
{
bnfdef_common
372
flags
dflgs
;
373
char
*
txt
; }
bnfLdef_struct
;
374
375
376
/*
377
Last but not least, the data structure used to define socket/label
378
definitions and references. (Definitions, mind you - there is another
379
structure to reference socket/label definitions and references.) A
380
socket/label definition associates of a name (a text string) with a value
381
(almost always an address). A socket/label reference specifies a socket
382
and a label. The label is inserted into the socket. Fields prefixed by nm
383
are the name in a socket/label definition and the socket in a socket/label
384
reference. Fields prefixed by nd are the value in a socket/label definition
385
and the label in a socket/label reference.
386
387
Field Description
388
----- -----------
389
bnfdef_common As above.
390
dflgs Flags.
391
nmcd Specifies how name/socket will be obtained.
392
ndcd Specifies how value/label will be obtained.
393
savnm Specifies location in saved text array where string associated
394
with nm will be stored.
395
nmsrc Pointer to bnf which will produce string for nm, or cast into
396
an int and used as a location in the saved text array.
397
savnd Specifies location in saved text array where string associated
398
with nd will be stored.
399
ndsrc Pointer to bnf which will produce string for nd, or cast into
400
an int and used as a location in the saved text array.
401
offset Correction (in bytes) to socket/label value (socket/label
402
definitions) or socket (socket/label references).
403
offset2 Correction (in bytes) to label (socket/label references).
404
*/
405
406
typedef
struct
{
bnfdef_common
407
flags
dflgs
;
408
bnflblsrc_enum
nmcd
;
409
bnflblsrc_enum
ndcd
;
410
int
savnm
;
411
struct
bnfref_struct_tag
*
nmsrc
;
412
int
savnd
;
413
struct
bnfref_struct_tag
*
ndsrc
;
414
int
offset
;
415
int
offset2
; }
bnfLBdef_struct
;
416
417
418
/*
419
And finally, the handy union of pointers promised back at the start. We
420
really should be using this in the bnf reference structure declarations,
421
rather than (bnfdef_struct *), but since references and definitions are
422
mutually recursive we get into ugliness. There's also the point that we
423
want to be able to create bnfs at compile time and you can't initialize
424
unions.
425
*/
426
427
typedef
union
{
bnfdef_struct
*
com
;
428
bnfGdef_struct
*
G
;
429
bnfNPdef_struct
*
NP
;
430
bnfPdef_struct
*
P
;
431
bnfTdef_struct
*
T
;
432
bnfIdef_struct
*
I
;
433
bnfLdef_struct
*
L
;
434
bnfLBdef_struct
*
LB
; }
bnfdef_any
;
435
436
␌
437
438
/*
439
Now, on to the data structures used to reference bnf definitions. Recall if
440
you will the introductory comments about component and alternative arrays and
441
the general setup of the bnf data structure. We have the same three types of
442
data structures here as for bnf definitions.
443
*/
444
445
/*
446
The common portion. It includes a type code, a name, usage flags, and a
447
pointer to the bnf definition.
448
449
Field Description
450
----- -----------
451
type Type code identifying what sort of definition this reference
452
points to.
453
name The name of the reference (derived from the C variable name;
454
see the macros qref, npref, pref, etc.)
455
uflgs Usage flags.
456
defn Pointer to a bnf definition structure.
457
*/
458
459
#define bnfref_common bnftype_enum type ; \
460
const char *name ; \
461
bnfdef_struct *defn ; \
462
flags uflgs ;
463
464
typedef
struct
bnfref_struct_tag
{
bnfref_common
}
bnfref_struct
;
465
466
467
/*
468
References to labels of all flavours and to literals require only the
469
common fields. The only reason we need the uflgs field is for the bnfdebug
470
flag.
471
*/
472
473
typedef
bnfref_struct
bnfLBref_struct
;
474
typedef
bnfref_struct
bnfLref_struct
;
475
476
477
/*
478
References to terminals and immediates require an offset for storage.
479
480
Field Description
481
----- -----------
482
bnfref_common As above.
483
offset Offset (in bytes) into current node to the field where the
484
value produced by the referenced bnf will be stored.
485
*/
486
487
struct
bnfref_type2
{
bnfref_common
488
int
offset
; } ;
489
490
typedef
struct
bnfref_type2
bnfTref_struct
;
491
typedef
struct
bnfref_type2
bnfIref_struct
;
492
493
494
/*
495
References to generators, non-primitives, and primitives can be in lists and
496
require a separator specification in addition to the offset. Non-primitives
497
do not make use of the offset field.
498
499
Field Description
500
----- -----------
501
bnfref_common As above.
502
offset Offset (in bytes) into current node to the field where the
503
value produced by the referenced bnf will be stored.
504
sep A reference to a bnf definition describing the separator
505
between list elements in the input stream.
506
*/
507
508
struct
bnfref_type3
{
bnfref_common
509
int
offset
;
510
bnfref_struct
*
sep
; } ;
511
512
typedef
struct
bnfref_type3
bnfGref_struct
;
513
typedef
struct
bnfref_type3
bnfNPref_struct
;
514
typedef
struct
bnfref_type3
bnfPref_struct
;
515
516
517
/*
518
And the handy union pointer type. Same general comments as for the
519
declaration of bnfdef_any.
520
*/
521
522
typedef
union
{
bnfref_struct
*
com
;
523
struct
bnfref_type1 *
t1
;
524
struct
bnfref_type2
*
t2
;
525
struct
bnfref_type3
*
t3
;
526
bnfGref_struct
*
G
;
527
bnfNPref_struct
*
NP
;
528
bnfPref_struct
*
P
;
529
bnfTref_struct
*
T
;
530
bnfIref_struct
*
I
;
531
bnfLref_struct
*
L
;
532
bnfLBref_struct
*
LB
; }
bnfref_any
;
533
534
␌
535
536
/*
537
The macros that make defining the bnf data structures marginally
538
less painful.
539
*/
540
541
/*
542
Macros to help with constructing field offsets. NULLP is specially designed
543
to produce a NULL value when used as &NULLP. This is required for some
544
of the macros where one must fill the field with either the address of a
545
bnfref_struct or the value NULL. By this device we avoid having to make
546
the user aware of when and when not to use &.
547
548
mkoff simply produces the offset of a given field in a structure type. But
549
it's not quite that simple in the world of mixed 64- and 32-bit platforms.
550
The cast to size_t leaves us with either a 64- or 32-bit int, depending
551
on the size of addresses, but at least it's an int instead of a pointer,
552
and that's sufficient to suppress warnings in other places when the result
553
is converted to an int. And the result here should always be a small
554
integer.
555
*/
556
557
#define NULLP (*((char *) 0))
558
#define mksav(qqoff) (*((char *) qqoff))
559
#define mkoff(qqtype,qqfield) ((size_t) (&((qqtype *) 0)->qqfield))
560
561
/*
562
Macros for alternative and component lists. These just generate the headers;
563
the actual lists have to be typed out, as:
564
565
althd(arule_alts) = { altcnt(3),
566
mkaref(arule_alt1), mkaref(arule_alt2),
567
mkaref(arule_alt3) } ;
568
569
comphd(arule_alt1) = { compcnt(2),
570
mkcref(brule_ref), mkcref(crule_ref) } ;
571
572
where brule_ref and crule_ref are bnf references (most likely constructed
573
using the gref, npref, etc. macros).
574
*/
575
576
#define althd(qqnme) bnfref_struct **qqnme[]
577
#define altcnt(qqcnt) (bnfref_struct **) (qqcnt)
578
#define mkaref(qqref) (bnfref_struct **) (qqref)
579
580
#define comphd(qqnme) bnfref_struct *qqnme[]
581
#define compcnt(qqcnt) (bnfref_struct *) (qqcnt)
582
#define mkcref(qqref) (bnfref_struct *) (&qqref)
583
584
/*
585
Macros to initialise bnf definitions. Note the use of the ANSI C
586
'stringisation' operator, '#', to get a text string for the name. For
587
non-ANSI implementations, replacing #qqnme with "qqnme" usually works (but
588
not all non-ANSI preprocessor implementations will see the macro parameter
589
inside a string, and ANSI C explicitly disallows it).
590
*/
591
592
#define gdef(qqnme,qqsze,qqlnk,qqcomps) \
593
bnfGdef_struct qqnme = { bnfG, #qqnme, (int) (qqsze), (int) (qqlnk), \
594
(bnfref_struct **) qqcomps }
595
596
#define npdef(qqnme,qqalts) \
597
bnfNPdef_struct qqnme = { bnfNP, #qqnme, (bnfref_struct ***) qqalts }
598
599
#define pdef(qqnme,qqalts) \
600
bnfPdef_struct qqnme = { bnfP, #qqnme, (bnfref_struct ***) qqalts }
601
602
#define tdef(qqnme,qqttype,qqparm,qqval) \
603
bnfTdef_struct qqnme = { bnfT, #qqnme, qqttype, '\0', '\0', \
604
(int) (qqparm), (const char *) (qqval) }
605
606
#define tqdef(qqnme,qqschr,qqechr,qqval) \
607
bnfTdef_struct qqnme = { bnfT, #qqnme, bnfttQ, (char) qqschr, (char) qqechr,\
608
0, (char *) (qqval) }
609
610
#define dfdef(qqnme,qqdflgs,qqnmcd,qqnm,qqsavnm,qqndcd,qqnd,qqsavnd,qqoff) \
611
bnfLBdef_struct qqnme = { bnfDS, #qqnme, (flags) (qqdflgs), qqnmcd, qqndcd, \
612
(int) (qqsavnm), (bnfref_struct *) &qqnm, \
613
(int) (qqsavnd), (bnfref_struct *) &qqnd, \
614
(int) (qqoff), 0 }
615
616
#define dbdef(qqnme,qqdflgs,qqnmcd,qqnm,qqsavnm,qqndcd,qqnd,qqsavnd,qqoff) \
617
bnfLBdef_struct qqnme = { bnfDL, #qqnme, (flags) (qqdflgs), qqnmcd, qqndcd, \
618
(int) (qqsavnm), (bnfref_struct *) &qqnm, \
619
(int) (qqsavnd), (bnfref_struct *) &qqnd, \
620
(int) (qqoff), 0 }
621
622
#define rfdef(qqnme,qqdflgs,qqnmcd,qqnm,qqsavnm,qqoff,qqndcd,qqnd,qqsavnd,qqoff2) \
623
bnfLBdef_struct qqnme = { bnfRS, #qqnme, (flags) (qqdflgs), qqnmcd, qqndcd, \
624
(int) (qqsavnm), (bnfref_struct *) &qqnm, \
625
(int) (qqsavnd), (bnfref_struct *) &qqnd, \
626
(int) (qqoff), (int) (qqoff2) }
627
628
#define rbdef(qqnme,qqdflgs,qqnmcd,qqnm,qqsavnm,qqoff,qqndcd,qqnd,qqsavnd,qqoff2) \
629
bnfLBdef_struct qqnme = { bnfRL, #qqnme, (flags) (qqdflgs), qqnmcd, qqndcd, \
630
(int) (qqsavnm), (bnfref_struct *) &qqnm, \
631
(int) (qqsavnd), (bnfref_struct *) &qqnd, \
632
(int) (qqoff), (int) (qqoff2) }
633
634
#define idef(qqnme,qqval) \
635
bnfIdef_struct qqnme = { bnfI, #qqnme, (int) (qqval) }
636
637
#define ldef(qqnme,qqdflgs,qqtxt) \
638
bnfLdef_struct qqnme = { bnfL, #qqnme, (flags) (qqdflgs), (char *) (qqtxt) }
639
640
␌
641
642
#define gref(qqnme,qqref,qquflgs,qqoff,qqsep) \
643
bnfGref_struct qqnme = { bnfG, #qqnme, (bnfdef_struct *) &qqref, \
644
(flags) (qquflgs), (int) (qqoff), \
645
(bnfref_struct *) &qqsep }
646
647
#define npref(qqnme,qqref,qquflgs,qqsep) \
648
bnfNPref_struct qqnme = { bnfNP, #qqnme, (bnfdef_struct *) &qqref, \
649
(flags) (qquflgs), (int) 0, (bnfref_struct *) &qqsep }
650
651
#define pref(qqnme,qqref,qquflgs,qqoff,qqsep) \
652
bnfPref_struct qqnme = { bnfP, #qqnme, (bnfdef_struct *) &qqref, \
653
(flags) (qquflgs), (int) (qqoff), \
654
(bnfref_struct *) &qqsep }
655
656
#define tref(qqnme,qqref,qquflgs,qqoff) \
657
bnfTref_struct qqnme = { bnfT, #qqnme, (bnfdef_struct *) &qqref, \
658
(flags) qquflgs, (int) qqoff }
659
660
#define dfref(qqnme,qqref) \
661
bnfLBref_struct qqnme = { bnfDS, #qqnme, (bnfdef_struct *) &qqref, (flags) 0 }
662
663
#define dbref(qqnme,qqref) \
664
bnfLBref_struct qqnme = { bnfDL, #qqnme, (bnfdef_struct *) &qqref, (flags) 0 }
665
666
#define rfref(qqnme,qqref) \
667
bnfLBref_struct qqnme = { bnfRS, #qqnme, (bnfdef_struct *) &qqref, (flags) 0 }
668
669
#define rbref(qqnme,qqref) \
670
bnfLBref_struct qqnme = { bnfRL, #qqnme, (bnfdef_struct *) &qqref, (flags) 0 }
671
672
#define iref(qqnme,qqref,qqoff) \
673
bnfIref_struct qqnme = { bnfI, #qqnme, (bnfdef_struct *) &qqref, \
674
(flags) 0, (int) qqoff }
675
676
#define lref(qqnme,qqref) \
677
bnfLref_struct qqnme = { bnfL, #qqnme, (bnfdef_struct *) &qqref, (flags) 0 }
678
679
#ifndef DYLP_NDEBUG
680
681
/*
682
This set of definitions sets the bnfdebug flag, but doesn't add a separate
683
uflgs parameter (we don't want to lead the user to think any of the others
684
are valid).
685
*/
686
687
#define dfrefdbg(qqnme,qqref) \
688
bnfLBref_struct qqnme = { bnfDS, #qqnme, (bnfdef_struct *) &qqref, \
689
(flags) bnfdebug }
690
691
#define dbrefdbg(qqnme,qqref) \
692
bnfLBref_struct qqnme = { bnfDL, #qqnme, (bnfdef_struct *) &qqref, \
693
(flags) bnfdebug }
694
695
#define rfrefdbg(qqnme,qqref) \
696
bnfLBref_struct qqnme = { bnfRS, #qqnme, (bnfdef_struct *) &qqref, \
697
(flags) bnfdebug }
698
699
#define rbrefdbg(qqnme,qqref) \
700
bnfLBref_struct qqnme = { bnfRL, #qqnme, (bnfdef_struct *) &qqref, \
701
(flags) bnfdebug }
702
703
#define lrefdbg(qqnme,qqref) \
704
bnfLref_struct qqnme = { bnfL, #qqnme, (bnfdef_struct *) &qqref, \
705
(flags) bnfdebug }
706
707
#endif
/* DYLP_NDEBUG */
708
709
␌
710
711
/*
712
Last, but not least, some declarations to allow the use of the bnf reader.
713
rdrinit and rdrclear initialize and clear the reader; they should bracket
714
related groups of calls. parse is the main parsing routine. The union type
715
parse_any is the appropriate thing to hold the result.
716
*/
717
718
typedef
union
{
void
*
g
;
719
char
*
c
; }
parse_any
;
720
721
extern
void
rdrinit
(
void
),
rdrclear
(
void
) ;
722
extern
bool
parse
(
ioid
chn,
struct
bnfref_type3
*bnfid,
parse_any
*result) ;
723
724
#ifndef DYLP_NDEBUG
725
/*
726
The control routine for the bnf debugging trace output. See the comments
727
in bnfrdr.c for the proper use of the parameters.
728
*/
729
730
extern
void
bnfdbgctl
(
ioid
dbgchn,
bool
dbgecho,
bool
warnzlbl,
bool
numlvl,
731
bool
tablvl) ;
732
#else
733
#define bnfdbgctl(dgbchn,dbgecho,warnzlbl,numlvl,tablvl)
734
#endif
735
736
/*
737
Utility print routines from bnfrdrio.c.
738
*/
739
740
extern
void
prtbnfref
(
ioid
chn,
bool
echo,
bnfref_struct
*ref),
741
prtbnfdef
(
ioid
chn,
bool
echo,
bnfdef_struct
*def) ;
742
743
#endif
/* _DYLIB_BNFRDR_H */
bnfref_struct
struct bnfref_struct_tag bnfref_struct
bnfref_common
#define bnfref_common
Definition
dylib_bnfrdr.h:459
prtbnfref
void prtbnfref(ioid chn, bool echo, bnfref_struct *ref)
bnfdef_common
#define bnfdef_common
Definition
dylib_bnfrdr.h:263
bnftype_enum
bnftype_enum
Definition
dylib_bnfrdr.h:107
bnfP
@ bnfP
Definition
dylib_bnfrdr.h:107
bnfG
@ bnfG
Definition
dylib_bnfrdr.h:107
bnfT
@ bnfT
Definition
dylib_bnfrdr.h:107
bnfL
@ bnfL
Definition
dylib_bnfrdr.h:108
bnfRS
@ bnfRS
Definition
dylib_bnfrdr.h:108
bnfDL
@ bnfDL
Definition
dylib_bnfrdr.h:108
bnfRL
@ bnfRL
Definition
dylib_bnfrdr.h:108
bnfI
@ bnfI
Definition
dylib_bnfrdr.h:108
bnfNP
@ bnfNP
Definition
dylib_bnfrdr.h:107
bnfDS
@ bnfDS
Definition
dylib_bnfrdr.h:107
bnfGref_struct
struct bnfref_type3 bnfGref_struct
Definition
dylib_bnfrdr.h:512
bnfdbgctl
void bnfdbgctl(ioid dbgchn, bool dbgecho, bool warnzlbl, bool numlvl, bool tablvl)
rdrinit
void rdrinit(void)
bnfLBref_struct
bnfref_struct bnfLBref_struct
Definition
dylib_bnfrdr.h:473
bnfttype_enum
bnfttype_enum
Definition
dylib_bnfrdr.h:124
bnfttNIL
@ bnfttNIL
Definition
dylib_bnfrdr.h:124
bnfttQ
@ bnfttQ
Definition
dylib_bnfrdr.h:124
bnfttF
@ bnfttF
Definition
dylib_bnfrdr.h:124
bnfttID
@ bnfttID
Definition
dylib_bnfrdr.h:124
bnfttN
@ bnfttN
Definition
dylib_bnfrdr.h:124
bnfttD
@ bnfttD
Definition
dylib_bnfrdr.h:124
bnfIref_struct
struct bnfref_type2 bnfIref_struct
Definition
dylib_bnfrdr.h:491
parse
bool parse(ioid chn, struct bnfref_type3 *bnfid, parse_any *result)
rdrclear
void rdrclear(void)
bnfPdef_struct
bnfNPdef_struct bnfPdef_struct
Definition
dylib_bnfrdr.h:313
bnflblsrc_enum
bnflblsrc_enum
Definition
dylib_bnfrdr.h:147
bnfncBNF
@ bnfncBNF
Definition
dylib_bnfrdr.h:147
bnfncN
@ bnfncN
Definition
dylib_bnfrdr.h:147
bnfncS
@ bnfncS
Definition
dylib_bnfrdr.h:147
bnfncC
@ bnfncC
Definition
dylib_bnfrdr.h:147
bnfPref_struct
struct bnfref_type3 bnfPref_struct
Definition
dylib_bnfrdr.h:514
bnfTref_struct
struct bnfref_type2 bnfTref_struct
Definition
dylib_bnfrdr.h:490
bnfLref_struct
bnfref_struct bnfLref_struct
Definition
dylib_bnfrdr.h:474
prtbnfdef
void prtbnfdef(ioid chn, bool echo, bnfdef_struct *def)
bnfNPref_struct
struct bnfref_type3 bnfNPref_struct
Definition
dylib_bnfrdr.h:513
dylib_io.h
ioid
int ioid
Definition
dylib_io.h:39
flags
unsigned int flags
Definition
dylib_std.h:96
bnfGdef_struct
Definition
dylib_bnfrdr.h:285
bnfGdef_struct::size
bnfdef_common int size
Definition
dylib_bnfrdr.h:286
bnfGdef_struct::comps
struct bnfref_struct_tag ** comps
Definition
dylib_bnfrdr.h:288
bnfGdef_struct::link
int link
Definition
dylib_bnfrdr.h:287
bnfIdef_struct
Definition
dylib_bnfrdr.h:355
bnfIdef_struct::ival
bnfdef_common int ival
Definition
dylib_bnfrdr.h:356
bnfLBdef_struct
Definition
dylib_bnfrdr.h:406
bnfLBdef_struct::ndsrc
struct bnfref_struct_tag * ndsrc
Definition
dylib_bnfrdr.h:413
bnfLBdef_struct::offset
int offset
Definition
dylib_bnfrdr.h:414
bnfLBdef_struct::nmcd
bnflblsrc_enum nmcd
Definition
dylib_bnfrdr.h:408
bnfLBdef_struct::savnd
int savnd
Definition
dylib_bnfrdr.h:412
bnfLBdef_struct::savnm
int savnm
Definition
dylib_bnfrdr.h:410
bnfLBdef_struct::offset2
int offset2
Definition
dylib_bnfrdr.h:415
bnfLBdef_struct::dflgs
bnfdef_common flags dflgs
Definition
dylib_bnfrdr.h:407
bnfLBdef_struct::ndcd
bnflblsrc_enum ndcd
Definition
dylib_bnfrdr.h:409
bnfLBdef_struct::nmsrc
struct bnfref_struct_tag * nmsrc
Definition
dylib_bnfrdr.h:411
bnfLdef_struct
Definition
dylib_bnfrdr.h:371
bnfLdef_struct::txt
char * txt
Definition
dylib_bnfrdr.h:373
bnfLdef_struct::dflgs
bnfdef_common flags dflgs
Definition
dylib_bnfrdr.h:372
bnfNPdef_struct
Definition
dylib_bnfrdr.h:301
bnfNPdef_struct::alts
bnfdef_common struct bnfref_struct_tag *** alts
Definition
dylib_bnfrdr.h:302
bnfTdef_struct
Definition
dylib_bnfrdr.h:337
bnfTdef_struct::ttype
bnfdef_common bnfttype_enum ttype
Definition
dylib_bnfrdr.h:338
bnfTdef_struct::qschr
char qschr
Definition
dylib_bnfrdr.h:339
bnfTdef_struct::qechr
char qechr
Definition
dylib_bnfrdr.h:340
bnfTdef_struct::val
const char * val
Definition
dylib_bnfrdr.h:342
bnfTdef_struct::parm1
int parm1
Definition
dylib_bnfrdr.h:341
bnfdef_struct
Definition
dylib_bnfrdr.h:266
bnfref_struct_tag
Definition
dylib_bnfrdr.h:464
bnfref_type2
Definition
dylib_bnfrdr.h:487
bnfref_type2::offset
bnfref_common int offset
Definition
dylib_bnfrdr.h:488
bnfref_type3
Definition
dylib_bnfrdr.h:508
bnfref_type3::offset
bnfref_common int offset
Definition
dylib_bnfrdr.h:509
bnfref_type3::sep
bnfref_struct * sep
Definition
dylib_bnfrdr.h:510
bnfdef_any
Definition
dylib_bnfrdr.h:427
bnfdef_any::T
bnfTdef_struct * T
Definition
dylib_bnfrdr.h:431
bnfdef_any::NP
bnfNPdef_struct * NP
Definition
dylib_bnfrdr.h:429
bnfdef_any::L
bnfLdef_struct * L
Definition
dylib_bnfrdr.h:433
bnfdef_any::LB
bnfLBdef_struct * LB
Definition
dylib_bnfrdr.h:434
bnfdef_any::G
bnfGdef_struct * G
Definition
dylib_bnfrdr.h:428
bnfdef_any::I
bnfIdef_struct * I
Definition
dylib_bnfrdr.h:432
bnfdef_any::P
bnfPdef_struct * P
Definition
dylib_bnfrdr.h:430
bnfdef_any::com
bnfdef_struct * com
Definition
dylib_bnfrdr.h:427
bnfref_any
Definition
dylib_bnfrdr.h:522
bnfref_any::I
bnfIref_struct * I
Definition
dylib_bnfrdr.h:530
bnfref_any::t3
struct bnfref_type3 * t3
Definition
dylib_bnfrdr.h:525
bnfref_any::L
bnfLref_struct * L
Definition
dylib_bnfrdr.h:531
bnfref_any::G
bnfGref_struct * G
Definition
dylib_bnfrdr.h:526
bnfref_any::T
bnfTref_struct * T
Definition
dylib_bnfrdr.h:529
bnfref_any::LB
bnfLBref_struct * LB
Definition
dylib_bnfrdr.h:532
bnfref_any::t1
struct bnfref_type1 * t1
Definition
dylib_bnfrdr.h:523
bnfref_any::NP
bnfNPref_struct * NP
Definition
dylib_bnfrdr.h:527
bnfref_any::t2
struct bnfref_type2 * t2
Definition
dylib_bnfrdr.h:524
bnfref_any::com
bnfref_struct * com
Definition
dylib_bnfrdr.h:522
bnfref_any::P
bnfPref_struct * P
Definition
dylib_bnfrdr.h:528
parse_any
Definition
dylib_bnfrdr.h:718
parse_any::c
char * c
Definition
dylib_bnfrdr.h:719
parse_any::g
void * g
Definition
dylib_bnfrdr.h:718
Generated by
1.17.0