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