Commit | Line | Data |
---|---|---|
8b9d5b5e MD |
1 | #ifndef _CTF_PARSER_H |
2 | #define _CTF_PARSER_H | |
3 | ||
ae5193a6 | 4 | #include <stdint.h> |
8b9d5b5e | 5 | #include <helpers/list.h> |
34d3acc4 MD |
6 | #include <stdio.h> |
7 | #include <glib.h> | |
8 | ||
9 | // the parameter name (of the reentrant 'yyparse' function) | |
10 | // data is a pointer to a 'SParserParam' structure | |
11 | //#define YYPARSE_PARAM scanner | |
12 | ||
13 | // the argument for the 'yylex' function | |
14 | #define YYLEX_PARAM ((struct ctf_scanner *) scanner)->scanner | |
15 | ||
16 | struct ctf_node; | |
17 | struct ctf_parser; | |
8b9d5b5e MD |
18 | |
19 | enum node_type { | |
02b234c4 | 20 | NODE_UNKNOWN = 0, |
8b9d5b5e | 21 | NODE_ROOT, |
fce8006d | 22 | |
8b9d5b5e MD |
23 | NODE_EVENT, |
24 | NODE_STREAM, | |
8b9d5b5e MD |
25 | NODE_TRACE, |
26 | ||
fce8006d MD |
27 | NODE_CTF_EXPRESSION, |
28 | ||
29 | NODE_TYPEDEF, | |
02b234c4 MD |
30 | NODE_TYPEALIAS_TARGET, |
31 | NODE_TYPEALIAS_ALIAS, | |
fce8006d MD |
32 | NODE_TYPEALIAS, |
33 | ||
ae5193a6 | 34 | NODE_TYPE_SPECIFIER, |
fce8006d | 35 | NODE_DECLARATION_SPECIFIER, |
ae5193a6 | 36 | NODE_POINTER, |
fce8006d MD |
37 | NODE_TYPE_DECLARATOR, |
38 | ||
39 | NODE_FLOATING_POINT, | |
40 | NODE_INTEGER, | |
41 | NODE_STRING, | |
ae5193a6 | 42 | NODE_ENUMERATOR, |
fce8006d | 43 | NODE_ENUM, |
ae5193a6 | 44 | NODE_STRUCT_OR_VARIANT_DECLARATION, |
fce8006d MD |
45 | NODE_VARIANT, |
46 | NODE_STRUCT, | |
47 | ||
8b9d5b5e MD |
48 | NR_NODE_TYPES, |
49 | }; | |
50 | ||
8b9d5b5e | 51 | struct ctf_node { |
8b9d5b5e | 52 | struct ctf_node *parent; |
8b9d5b5e | 53 | struct cds_list_head siblings; |
8b9d5b5e | 54 | struct cds_list_head gc; |
ae5193a6 MD |
55 | |
56 | enum node_type type; | |
57 | union { | |
58 | struct { | |
59 | } unknown; | |
60 | struct { | |
02b234c4 MD |
61 | struct cds_list_head _typedef; |
62 | struct cds_list_head typealias; | |
63 | struct cds_list_head declaration_specifier; | |
64 | struct cds_list_head trace; | |
65 | struct cds_list_head stream; | |
66 | struct cds_list_head event; | |
ae5193a6 MD |
67 | } root; |
68 | struct { | |
69 | /* | |
70 | * Children nodes are ctf_expression, typedef or | |
71 | * typealias. | |
72 | */ | |
73 | struct cds_list_head _typedef; | |
74 | struct cds_list_head typealias; | |
75 | struct cds_list_head ctf_expression; | |
02b234c4 | 76 | struct cds_list_head declaration_specifier; |
ae5193a6 MD |
77 | } event; |
78 | struct { | |
79 | /* | |
80 | * Children nodes are ctf_expression, typedef or | |
81 | * typealias. | |
82 | */ | |
83 | struct cds_list_head _typedef; | |
84 | struct cds_list_head typealias; | |
85 | struct cds_list_head ctf_expression; | |
02b234c4 | 86 | struct cds_list_head declaration_specifier; |
ae5193a6 MD |
87 | } stream; |
88 | struct { | |
89 | /* | |
90 | * Children nodes are ctf_expression, typedef or | |
91 | * typealias. | |
92 | */ | |
93 | struct cds_list_head _typedef; | |
94 | struct cds_list_head typealias; | |
95 | struct cds_list_head ctf_expression; | |
02b234c4 | 96 | struct cds_list_head declaration_specifier; |
ae5193a6 MD |
97 | } trace; |
98 | struct { | |
99 | char *left_id; | |
100 | enum { | |
02b234c4 | 101 | EXP_UNKNOWN = 0, |
ae5193a6 MD |
102 | EXP_ID, |
103 | EXP_TYPE, | |
104 | } type; | |
105 | union { | |
106 | char *id; | |
107 | struct ctf_node *type; | |
108 | } right; | |
109 | } ctf_expression; | |
110 | struct { | |
111 | struct ctf_node *declaration_specifier; | |
02b234c4 | 112 | struct cds_list_head type_declarators; |
ae5193a6 | 113 | } _typedef; |
02b234c4 MD |
114 | /* new type is "alias", existing type "target" */ |
115 | struct { | |
116 | struct ctf_node *declaration_specifier; | |
117 | struct cds_list_head type_declarators; | |
118 | } typealias_target; | |
119 | struct { | |
120 | struct ctf_node *declaration_specifier; | |
121 | struct cds_list_head type_declarators; | |
122 | } typealias_alias; | |
ae5193a6 | 123 | struct { |
02b234c4 MD |
124 | struct ctf_node *target; |
125 | struct ctf_node *alias; | |
ae5193a6 MD |
126 | } typealias; |
127 | struct { | |
128 | enum { | |
02b234c4 | 129 | TYPESPEC_UNKNOWN = 0, |
ae5193a6 MD |
130 | TYPESPEC_VOID, |
131 | TYPESPEC_CHAR, | |
132 | TYPESPEC_SHORT, | |
133 | TYPESPEC_INT, | |
134 | TYPESPEC_LONG, | |
135 | TYPESPEC_FLOAT, | |
136 | TYPESPEC_DOUBLE, | |
137 | TYPESPEC_SIGNED, | |
138 | TYPESPEC_UNSIGNED, | |
139 | TYPESPEC_BOOL, | |
140 | TYPESPEC_COMPLEX, | |
141 | TYPESPEC_ID_TYPE, | |
142 | ||
143 | TYPESPEC_FLOATING_POINT, | |
144 | TYPESPEC_INTEGER, | |
145 | TYPESPEC_STRING, | |
146 | TYPESPEC_ENUM, | |
147 | TYPESPEC_VARIANT, | |
148 | TYPESPEC_STRUCT, | |
149 | } type; | |
150 | union { | |
151 | struct ctf_node *floating_point; | |
152 | struct ctf_node *integer; | |
153 | struct ctf_node *string; | |
154 | struct ctf_node *_enum; | |
155 | struct ctf_node *variant; | |
156 | struct ctf_node *_struct; | |
157 | } u; | |
158 | } type_specifier; | |
159 | struct { | |
160 | /* drop "const" specifier */ | |
161 | /* Children nodes are type_specifiers */ | |
162 | struct cds_list_head type_specifiers; | |
163 | } declaration_specifier; | |
164 | struct { | |
165 | } pointer; | |
166 | struct { | |
167 | struct cds_list_head pointers; | |
168 | enum { | |
02b234c4 | 169 | TYPEDEC_UNKNOWN = 0, |
ae5193a6 | 170 | TYPEDEC_ID, /* identifier */ |
02b234c4 | 171 | TYPEDEC_NESTED, /* (), array or sequence */ |
ae5193a6 MD |
172 | } type; |
173 | union { | |
174 | char *id; | |
ae5193a6 MD |
175 | struct { |
176 | /* typedec has no pointer list */ | |
02b234c4 | 177 | struct ctf_node *type_declarator; |
ae5193a6 MD |
178 | struct { |
179 | enum { | |
02b234c4 | 180 | TYPEDEC_TYPE_UNKNOWN = 0, |
ae5193a6 MD |
181 | TYPEDEC_TYPE_VALUE, /* must be > 0 */ |
182 | TYPEDEC_TYPE_TYPE, | |
183 | } type; | |
184 | union { | |
185 | uint64_t value; | |
186 | struct ctf_node *declaration_specifier; | |
187 | } u; | |
188 | } length; | |
02b234c4 | 189 | } nested; |
ae5193a6 MD |
190 | } u; |
191 | } type_declarator; | |
192 | struct { | |
193 | /* Children nodes are ctf_expression. */ | |
194 | struct cds_list_head expressions; | |
195 | } floating_point; | |
196 | struct { | |
197 | /* Children nodes are ctf_expression. */ | |
198 | struct cds_list_head expressions; | |
199 | } integer; | |
200 | struct { | |
201 | /* Children nodes are ctf_expression. */ | |
202 | struct cds_list_head expressions; | |
203 | } string; | |
204 | struct { | |
205 | char *id; | |
206 | union { /* inclusive start/end of range */ | |
207 | struct { | |
208 | int64_t start, end; | |
209 | } _signed; | |
210 | struct { | |
211 | uint64_t start, end; | |
212 | } _unsigned; | |
213 | } u; | |
214 | } enumerator; | |
215 | struct { | |
216 | char *enum_id; | |
217 | struct { | |
218 | enum { | |
02b234c4 | 219 | ENUM_TYPE_UNKNOWN = 0, |
ae5193a6 MD |
220 | ENUM_TYPE_VALUE, /* must be > 0 */ |
221 | ENUM_TYPE_TYPE, | |
222 | } type; | |
223 | union { | |
224 | uint64_t value; | |
225 | struct ctf_node *declaration_specifier; | |
226 | } u; | |
227 | } container_type; | |
228 | struct cds_list_head enumerator_list; | |
229 | } _enum; | |
230 | struct { | |
231 | struct ctf_node *declaration_specifier; | |
02b234c4 | 232 | struct cds_list_head type_declarators; |
ae5193a6 MD |
233 | } struct_or_variant_declaration; |
234 | struct { | |
235 | struct cds_list_head _typedef; | |
236 | struct cds_list_head typealias; | |
237 | struct cds_list_head declaration_list; | |
238 | } variant; | |
239 | struct { | |
240 | struct cds_list_head _typedef; | |
241 | struct cds_list_head typealias; | |
242 | struct cds_list_head declaration_list; | |
243 | } _struct; | |
244 | } u; | |
8b9d5b5e MD |
245 | }; |
246 | ||
34d3acc4 MD |
247 | struct ctf_ast { |
248 | struct ctf_node root; | |
02b234c4 | 249 | struct cds_list_head allocated_nodes; |
34d3acc4 | 250 | }; |
8b9d5b5e MD |
251 | |
252 | #endif /* _CTF_PARSER_H */ |