Cleanup: YYPARSE_PARAM and YYLEX_PARAM are deprecated in bison 2.6
[babeltrace.git] / formats / ctf / metadata / ctf-ast.h
1 #ifndef _CTF_AST_H
2 #define _CTF_AST_H
3
4 /*
5 * ctf-ast.h
6 *
7 * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 */
19
20 #include <stdint.h>
21 #include <stdio.h>
22 #include <glib.h>
23 #include <babeltrace/list.h>
24
25 struct ctf_node;
26 struct ctf_parser;
27
28 enum node_type {
29 NODE_UNKNOWN = 0,
30 NODE_ROOT,
31
32 NODE_EVENT,
33 NODE_STREAM,
34 NODE_ENV,
35 NODE_TRACE,
36 NODE_CLOCK,
37
38 NODE_CTF_EXPRESSION,
39 NODE_UNARY_EXPRESSION,
40
41 NODE_TYPEDEF,
42 NODE_TYPEALIAS_TARGET,
43 NODE_TYPEALIAS_ALIAS,
44 NODE_TYPEALIAS,
45
46 NODE_TYPE_SPECIFIER,
47 NODE_TYPE_SPECIFIER_LIST,
48 NODE_POINTER,
49 NODE_TYPE_DECLARATOR,
50
51 NODE_FLOATING_POINT,
52 NODE_INTEGER,
53 NODE_STRING,
54 NODE_ENUMERATOR,
55 NODE_ENUM,
56 NODE_STRUCT_OR_VARIANT_DECLARATION,
57 NODE_VARIANT,
58 NODE_STRUCT,
59
60 NR_NODE_TYPES,
61 };
62
63 struct ctf_node {
64 /*
65 * Parent node is only set on demand by specific visitor.
66 */
67 struct ctf_node *parent;
68 struct bt_list_head siblings;
69 struct bt_list_head tmp_head;
70 struct bt_list_head gc;
71
72 enum node_type type;
73 union {
74 struct {
75 } unknown;
76 struct {
77 /*
78 * Children nodes are ctf_expression, typedef,
79 * typealias and type_specifier_list.
80 */
81 struct bt_list_head declaration_list;
82 struct bt_list_head trace;
83 struct bt_list_head env;
84 struct bt_list_head stream;
85 struct bt_list_head event;
86 struct bt_list_head clock;
87 } root;
88 struct {
89 /*
90 * Children nodes are ctf_expression, typedef,
91 * typealias and type_specifier_list.
92 */
93 struct bt_list_head declaration_list;
94 } event;
95 struct {
96 /*
97 * Children nodes are ctf_expression, typedef,
98 * typealias and type_specifier_list.
99 */
100 struct bt_list_head declaration_list;
101 } stream;
102 struct {
103 /*
104 * Children nodes are ctf_expression, typedef,
105 * typealias and type_specifier_list.
106 */
107 struct bt_list_head declaration_list;
108 } env;
109 struct {
110 /*
111 * Children nodes are ctf_expression, typedef,
112 * typealias and type_specifier_list.
113 */
114 struct bt_list_head declaration_list;
115 } trace;
116 struct {
117 /*
118 * Children nodes are ctf_expression, typedef,
119 * typealias and type_specifier_list.
120 */
121 struct bt_list_head declaration_list;
122 } clock;
123 struct {
124 struct bt_list_head left; /* Should be string */
125 struct bt_list_head right; /* Unary exp. or type */
126 } ctf_expression;
127 struct {
128 enum {
129 UNARY_UNKNOWN = 0,
130 UNARY_STRING,
131 UNARY_SIGNED_CONSTANT,
132 UNARY_UNSIGNED_CONSTANT,
133 UNARY_SBRAC,
134 UNARY_NESTED,
135 } type;
136 union {
137 /*
138 * string for identifier, id_type, keywords,
139 * string literals and character constants.
140 */
141 char *string;
142 int64_t signed_constant;
143 uint64_t unsigned_constant;
144 struct ctf_node *sbrac_exp;
145 struct ctf_node *nested_exp;
146 } u;
147 enum {
148 UNARY_LINK_UNKNOWN = 0,
149 UNARY_DOTLINK,
150 UNARY_ARROWLINK,
151 UNARY_DOTDOTDOT,
152 } link;
153 } unary_expression;
154 struct {
155 struct ctf_node *type_specifier_list;
156 struct bt_list_head type_declarators;
157 } _typedef;
158 /* new type is "alias", existing type "target" */
159 struct {
160 struct ctf_node *type_specifier_list;
161 struct bt_list_head type_declarators;
162 } typealias_target;
163 struct {
164 struct ctf_node *type_specifier_list;
165 struct bt_list_head type_declarators;
166 } typealias_alias;
167 struct {
168 struct ctf_node *target;
169 struct ctf_node *alias;
170 } typealias;
171 struct {
172 enum {
173 TYPESPEC_UNKNOWN = 0,
174 TYPESPEC_VOID,
175 TYPESPEC_CHAR,
176 TYPESPEC_SHORT,
177 TYPESPEC_INT,
178 TYPESPEC_LONG,
179 TYPESPEC_FLOAT,
180 TYPESPEC_DOUBLE,
181 TYPESPEC_SIGNED,
182 TYPESPEC_UNSIGNED,
183 TYPESPEC_BOOL,
184 TYPESPEC_COMPLEX,
185 TYPESPEC_IMAGINARY,
186 TYPESPEC_CONST,
187 TYPESPEC_ID_TYPE,
188 TYPESPEC_FLOATING_POINT,
189 TYPESPEC_INTEGER,
190 TYPESPEC_STRING,
191 TYPESPEC_STRUCT,
192 TYPESPEC_VARIANT,
193 TYPESPEC_ENUM,
194 } type;
195 /* For struct, variant and enum */
196 struct ctf_node *node;
197 const char *id_type;
198 } type_specifier;
199 struct {
200 /* list of type_specifier */
201 struct bt_list_head head;
202 } type_specifier_list;
203 struct {
204 unsigned int const_qualifier;
205 } pointer;
206 struct {
207 struct bt_list_head pointers;
208 enum {
209 TYPEDEC_UNKNOWN = 0,
210 TYPEDEC_ID, /* identifier */
211 TYPEDEC_NESTED, /* (), array or sequence */
212 } type;
213 union {
214 char *id;
215 struct {
216 /* typedec has no pointer list */
217 struct ctf_node *type_declarator;
218 /*
219 * unary expression (value) or
220 * type_specifier_list.
221 */
222 struct bt_list_head length;
223 /* for abstract type declarator */
224 unsigned int abstract_array;
225 } nested;
226 } u;
227 struct ctf_node *bitfield_len;
228 } type_declarator;
229 struct {
230 /* Children nodes are ctf_expression. */
231 struct bt_list_head expressions;
232 } floating_point;
233 struct {
234 /* Children nodes are ctf_expression. */
235 struct bt_list_head expressions;
236 } integer;
237 struct {
238 /* Children nodes are ctf_expression. */
239 struct bt_list_head expressions;
240 } string;
241 struct {
242 char *id;
243 /*
244 * Range list or single value node. Contains unary
245 * expressions.
246 */
247 struct bt_list_head values;
248 } enumerator;
249 struct {
250 char *enum_id;
251 /*
252 * Either NULL, or points to unary expression or
253 * type_specifier_list.
254 */
255 struct ctf_node *container_type;
256 struct bt_list_head enumerator_list;
257 int has_body;
258 } _enum;
259 struct {
260 struct ctf_node *type_specifier_list;
261 struct bt_list_head type_declarators;
262 } struct_or_variant_declaration;
263 struct {
264 char *name;
265 char *choice;
266 /* list of typedef, typealias and declarations */
267 struct bt_list_head declaration_list;
268 int has_body;
269 } variant;
270 struct {
271 char *name;
272 /* list of typedef, typealias and declarations */
273 struct bt_list_head declaration_list;
274 int has_body;
275 struct bt_list_head min_align; /* align() attribute */
276 } _struct;
277 } u;
278 };
279
280 struct ctf_ast {
281 struct ctf_node root;
282 struct bt_list_head allocated_nodes;
283 };
284
285 const char *node_type(struct ctf_node *node);
286
287 struct ctf_trace;
288
289 int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node);
290 int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node);
291 int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node);
292 int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
293 struct ctf_trace *trace, int byte_order);
294
295 #endif /* _CTF_AST_H */
This page took 0.034689 seconds and 4 git commands to generate.