source: abnfparser/bap/common.h @ 510

Last change on this file since 510 was 407, checked in by ylafon@…, 14 years ago

unixism

File size: 1.8 KB
Line 
1/*
2 * Bill's ABNF Parser
3 * $Id: common.h,v 1.1 2008-05-28 12:01:58 jre Exp $
4 */
5
6struct range {
7        unsigned int lo;
8        unsigned int hi;
9};
10
11struct rule {
12        char *name;             /* as defined or used */
13        char *lowername;        /* for hash key */
14        char *file;             /* filename of definition */
15        int line;               /* line of definition */
16        struct object *rule;    /* definition */
17        int used;               /* was it referenced? */
18        int predefined; /* abnf core rule? */
19        struct rule *next;      /* doubly */
20        struct rule *prev;      /* linked list */
21};
22
23/*
24 * Types:
25 * - Alternation
26 *   - left + right
27 * - Rule
28 *   - repetition
29 *   - concatenation
30 * - Terminal string
31 *   - case sensitive or not
32 *   - repetition
33 *   - concatenation
34 * - Terminal character range
35 *   - repetition
36 *   - concatenation
37 * - List
38 *   (list construct from RFC2616, Section 2.1)
39 */
40#define T_ALTERNATION   1
41#define T_RULE          2
42#define T_GROUP         3
43#define T_TERMSTR       4
44#define T_TERMRANGE     5
45#define T_PROSE         6
46
47typedef struct object {
48        int type;
49        struct object *next;
50        union {
51                struct {
52                        struct object *left;
53                        struct object *right;
54                } alternation;
55                struct {
56                        struct range repetition;
57      int   islist; /* jre */
58                        union {
59                            struct {
60                                    char *name; /* for forward ref. */
61                                    struct rule *rule;
62                            } rule;
63                            struct object *group;
64                            struct {
65                                    char *str;
66                                    int flags;
67                            } termstr;
68                            struct {
69                                    unsigned int lo;
70                                    unsigned int hi;
71                            } termrange;
72                            char *proseval;
73                        } e;
74                } e;
75        } u;
76} object;
77
78typedef struct input_file {
79        char *filename;
80        struct input_file *next;
81} fn_list;
82
83#define F_CASESENSITIVE         1       /* termstr.str is case sensitive */
84
85struct rule *findrule(char *);
86
87void mywarn(int, const char *, ...);
88#define MYERROR         1
89#define MYWARNING       2
90#define MYFYI           3
91
92void printobj(object *, int);
93void scanreset(void);
Note: See TracBrowser for help on using the repository browser.