-
Notifications
You must be signed in to change notification settings - Fork 0
/
attrib.h
112 lines (91 loc) · 3.13 KB
/
attrib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
*
* attrib.h
*
*
*
*
* 08/10/01
*/
#ifndef ATTRIB_H
#define ATTRIB_H
#include "dfa.h"
/* Attribute type */
#define AT_CDATA 1
#define AT_ID 2
#define AT_IDREF 3
#define AT_IDREFS 4
#define AT_ENTITY 5
#define AT_ENTITIES 6
#define AT_NMTOKEN 7
#define AT_NMTOKENS 8
#define AT_NOTATION 9
#define AT_ENUM 10
/* Attribute of the attribute */
#define AX_REQUIRED 0x100
#define AX_IMPLIED 0x200
#define AX_FIXED 0x400
#define AX_DEFAULT 0x800
/* element type */
#define EL_PCDATA 0x0001 /* 普通のデータですね */
#define EL_EMPTY 0x0002 /* 空エレメント宣言 <.../> */
#define EL_ANY 0x0004 /* なんでもよしなんですが、基本的にはほとんど使われない */
#define EL_DFA 0x0008 /* 子供エレメントのDFAあり */
/* Nink is the name for Name Link
*/
typedef struct _Nink {
char* name;
struct _Nink *next;
} Nink;
#define NameOfNink(n) ((n)->name)
#define NextOfNink(n) ((n)->next)
/* Fixed Attribute
*/
typedef struct {
int n_fixed; /* number of enum names */
Nink* fixed_candidates; /* enum names list */
Nink* last_candidate;
} Fixed;
/* Attribute
*/
typedef struct _Attribute {
unsigned type; /* AT_? | (AX_REQUIRED|AX_IMPLIED|AX_FIXED) */
char* name; /* name of the attribute */
char* default_value; /* default value for implied attribute */
Fixed* fixed; /* Has meaning only if type is AT_ENUM */
struct _Attribute *next; /* list */
} Attribute;
#define TypeOfAttribute(a) ((a)->type)
#define ATTypeOfAttribute(a) (((a)->type)&0xFF)
#define NameOfAttribute(a) ((a)->name)
#define FixedOfAttribute(a) ((a)->fixed)
/* Element attributes
*/
typedef struct {
int stateWork; /* work variable to sav current dfa transition state */
char* element; /* name of the element */
unsigned elemtype; /* PCDATA | DFA | EMPTY | ANY */
Dfa* dfa;
int n_attributes; /* number of attributes */
Attribute* attrib_list;
Attribute* attrib_last;
} Element;
#define NameOfElement(s) (s->element)
#define TypeOfElement(s) (s->elemtype)
Fixed* newFixedStruct (void);
void releaseFixedStruct (Fixed* fixed);
Attribute* newAttributeStruct (char* name);
Attribute* setAttributeType (Attribute* attr, int type, int attrib);
void releaseAttribute (Attribute* attr);
Attribute* addEnumNameToAttribute (Attribute* attr, char* name);
Attribute* setDefaultToAttribute (Attribute* attr, char* defname);
Element* newElementStruct (char* elemname);
void releaseElementStruct (Element* sa);
Element* setDfaToElement (Element* syma, Dfa* dfa);
Element* addAttributeToElement (Element* syma, Attribute* attrib);
Element* setTypeToElement (Element* syma, unsigned type);
Attribute* findAttributeFromElement (Element* syma, char* name);
int getNextStateOnSymbol (Element* parent, char* elem);
int checkAttributesForElement (Element* element, StrTreeNode attribRoot, char* vec[]);
int checkAttributesForFixed (Element* element, StrTreeNode attribRoot, char* vec[]);
#endif /* ATTRIB_H */