Add uuid test to configure.ac
[babeltrace.git] / formats / ctf / metadata / ctf-ast.h
... / ...
CommitLineData
1#ifndef _CTF_PARSER_H
2#define _CTF_PARSER_H
3
4#include <stdint.h>
5#include <stdio.h>
6#include <glib.h>
7#include <babeltrace/list.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
16struct ctf_node;
17struct ctf_parser;
18
19enum node_type {
20 NODE_UNKNOWN = 0,
21 NODE_ROOT,
22
23 NODE_EVENT,
24 NODE_STREAM,
25 NODE_TRACE,
26
27 NODE_CTF_EXPRESSION,
28 NODE_UNARY_EXPRESSION,
29
30 NODE_TYPEDEF,
31 NODE_TYPEALIAS_TARGET,
32 NODE_TYPEALIAS_ALIAS,
33 NODE_TYPEALIAS,
34
35 NODE_TYPE_SPECIFIER,
36 NODE_POINTER,
37 NODE_TYPE_DECLARATOR,
38
39 NODE_FLOATING_POINT,
40 NODE_INTEGER,
41 NODE_STRING,
42 NODE_ENUMERATOR,
43 NODE_ENUM,
44 NODE_STRUCT_OR_VARIANT_DECLARATION,
45 NODE_VARIANT,
46 NODE_STRUCT,
47
48 NR_NODE_TYPES,
49};
50
51struct ctf_node {
52 /*
53 * Parent node is only set on demand by specific visitor.
54 */
55 struct ctf_node *parent;
56 struct cds_list_head siblings;
57 struct cds_list_head tmp_head;
58 struct cds_list_head gc;
59
60 enum node_type type;
61 union {
62 struct {
63 } unknown;
64 struct {
65 struct cds_list_head _typedef;
66 struct cds_list_head typealias;
67 struct cds_list_head declaration_specifier;
68 struct cds_list_head trace;
69 struct cds_list_head stream;
70 struct cds_list_head event;
71 } root;
72 struct {
73 /*
74 * Children nodes are ctf_expression, typedef,
75 * typealias and declaration specifiers.
76 */
77 struct cds_list_head declaration_list;
78 } event;
79 struct {
80 /*
81 * Children nodes are ctf_expression, typedef,
82 * typealias and declaration specifiers.
83 */
84 struct cds_list_head declaration_list;
85 } stream;
86 struct {
87 /*
88 * Children nodes are ctf_expression, typedef,
89 * typealias and declaration specifiers.
90 */
91 struct cds_list_head declaration_list;
92 } trace;
93 struct {
94 struct cds_list_head left; /* Should be string */
95 struct cds_list_head right; /* Unary exp. or type */
96 } ctf_expression;
97 struct {
98 enum {
99 UNARY_UNKNOWN = 0,
100 UNARY_STRING,
101 UNARY_SIGNED_CONSTANT,
102 UNARY_UNSIGNED_CONSTANT,
103 UNARY_SBRAC,
104 UNARY_NESTED,
105 } type;
106 union {
107 /*
108 * string for identifier, id_type, keywords,
109 * string literals and character constants.
110 */
111 char *string;
112 int64_t signed_constant;
113 uint64_t unsigned_constant;
114 struct ctf_node *sbrac_exp;
115 struct ctf_node *nested_exp;
116 } u;
117 enum {
118 UNARY_LINK_UNKNOWN = 0,
119 UNARY_DOTLINK,
120 UNARY_ARROWLINK,
121 UNARY_DOTDOTDOT,
122 } link;
123 } unary_expression;
124 struct {
125 struct cds_list_head declaration_specifier;
126 struct cds_list_head type_declarators;
127 } _typedef;
128 /* new type is "alias", existing type "target" */
129 struct {
130 struct cds_list_head declaration_specifier;
131 struct cds_list_head type_declarators;
132 } typealias_target;
133 struct {
134 struct cds_list_head declaration_specifier;
135 struct cds_list_head type_declarators;
136 } typealias_alias;
137 struct {
138 struct ctf_node *target;
139 struct ctf_node *alias;
140 } typealias;
141 struct {
142 enum {
143 TYPESPEC_UNKNOWN = 0,
144 TYPESPEC_VOID,
145 TYPESPEC_CHAR,
146 TYPESPEC_SHORT,
147 TYPESPEC_INT,
148 TYPESPEC_LONG,
149 TYPESPEC_FLOAT,
150 TYPESPEC_DOUBLE,
151 TYPESPEC_SIGNED,
152 TYPESPEC_UNSIGNED,
153 TYPESPEC_BOOL,
154 TYPESPEC_COMPLEX,
155 TYPESPEC_IMAGINARY,
156 TYPESPEC_CONST,
157 TYPESPEC_ID_TYPE,
158 } type;
159 const char *id_type;
160 } type_specifier;
161 struct {
162 unsigned int const_qualifier;
163 } pointer;
164 struct {
165 struct cds_list_head pointers;
166 enum {
167 TYPEDEC_UNKNOWN = 0,
168 TYPEDEC_ID, /* identifier */
169 TYPEDEC_NESTED, /* (), array or sequence */
170 } type;
171 union {
172 char *id;
173 struct {
174 /* typedec has no pointer list */
175 struct ctf_node *type_declarator;
176 /* value or first node of declaration specifier list */
177 struct ctf_node *length;
178 /* for abstract type declarator */
179 unsigned int abstract_array;
180 } nested;
181 } u;
182 struct ctf_node *bitfield_len;
183 } type_declarator;
184 struct {
185 /* Children nodes are ctf_expression. */
186 struct cds_list_head expressions;
187 } floating_point;
188 struct {
189 /* Children nodes are ctf_expression. */
190 struct cds_list_head expressions;
191 } integer;
192 struct {
193 /* Children nodes are ctf_expression. */
194 struct cds_list_head expressions;
195 } string;
196 struct {
197 char *id;
198 /*
199 * Range list or single value node. Contains unary
200 * expressions.
201 */
202 struct cds_list_head values;
203 } enumerator;
204 struct {
205 char *enum_id;
206 /* NULL, value or declaration specifier */
207 struct ctf_node *container_type;
208 struct cds_list_head enumerator_list;
209 int has_body;
210 } _enum;
211 struct {
212 struct cds_list_head declaration_specifier;
213 struct cds_list_head type_declarators;
214 } struct_or_variant_declaration;
215 struct {
216 char *name;
217 char *choice;
218 /* list of typedef, typealias and declarations */
219 struct cds_list_head declaration_list;
220 int has_body;
221 } variant;
222 struct {
223 char *name;
224 /* list of typedef, typealias and declarations */
225 struct cds_list_head declaration_list;
226 int has_body;
227 } _struct;
228 } u;
229};
230
231struct ctf_ast {
232 struct ctf_node root;
233 struct cds_list_head allocated_nodes;
234};
235
236const char *node_type(struct ctf_node *node);
237
238struct ctf_trace;
239
240int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node);
241int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node);
242int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node);
243int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
244 struct ctf_trace *trace, int byte_order);
245
246#endif /* _CTF_PARSER_H */
This page took 0.024274 seconds and 4 git commands to generate.