Add embedded metadata examples
[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 /*
177 * unary expression (value) or
178 * declaration specifiers.
179 */
180 struct cds_list_head length;
181 /* for abstract type declarator */
182 unsigned int abstract_array;
183 } nested;
184 } u;
185 struct ctf_node *bitfield_len;
186 } type_declarator;
187 struct {
188 /* Children nodes are ctf_expression. */
189 struct cds_list_head expressions;
190 } floating_point;
191 struct {
192 /* Children nodes are ctf_expression. */
193 struct cds_list_head expressions;
194 } integer;
195 struct {
196 /* Children nodes are ctf_expression. */
197 struct cds_list_head expressions;
198 } string;
199 struct {
200 char *id;
201 /*
202 * Range list or single value node. Contains unary
203 * expressions.
204 */
205 struct cds_list_head values;
206 } enumerator;
207 struct {
208 char *enum_id;
209 /*
210 * Either empty, contains unary expression or
211 * declaration specifiers.
212 */
213 struct cds_list_head container_type;
214 struct cds_list_head enumerator_list;
215 int has_body;
216 } _enum;
217 struct {
218 struct cds_list_head declaration_specifier;
219 struct cds_list_head type_declarators;
220 } struct_or_variant_declaration;
221 struct {
222 char *name;
223 char *choice;
224 /* list of typedef, typealias and declarations */
225 struct cds_list_head declaration_list;
226 int has_body;
227 } variant;
228 struct {
229 char *name;
230 /* list of typedef, typealias and declarations */
231 struct cds_list_head declaration_list;
232 int has_body;
233 } _struct;
234 } u;
235};
236
237struct ctf_ast {
238 struct ctf_node root;
239 struct cds_list_head allocated_nodes;
240};
241
242const char *node_type(struct ctf_node *node);
243
244struct ctf_trace;
245
246int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node);
247int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node);
248int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node);
249int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
250 struct ctf_trace *trace, int byte_order);
251
252#endif /* _CTF_PARSER_H */
This page took 0.023508 seconds and 4 git commands to generate.