7 * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
23 #include <babeltrace/list.h>
25 // the parameter name (of the reentrant 'yyparse' function)
26 // data is a pointer to a 'SParserParam' structure
27 //#define YYPARSE_PARAM scanner
29 // the argument for the 'yylex' function
30 #define YYLEX_PARAM ((struct ctf_scanner *) scanner)->scanner
35 #define FOREACH_CTF_NODES(F) \
45 F(NODE_CTF_EXPRESSION) \
46 F(NODE_UNARY_EXPRESSION) \
48 F(NODE_TYPEALIAS_TARGET) \
49 F(NODE_TYPEALIAS_ALIAS) \
51 F(NODE_TYPE_SPECIFIER) \
52 F(NODE_TYPE_SPECIFIER_LIST) \
54 F(NODE_TYPE_DECLARATOR) \
55 F(NODE_FLOATING_POINT) \
60 F(NODE_STRUCT_OR_VARIANT_DECLARATION) \
66 FOREACH_CTF_NODES(ENTRY
)
73 * Parent node is only set on demand by specific visitor.
75 struct ctf_node
*parent
;
76 struct bt_list_head siblings
;
77 struct bt_list_head tmp_head
;
78 struct bt_list_head gc
;
87 * Children nodes are ctf_expression, typedef,
88 * typealias and type_specifier_list.
90 struct bt_list_head declaration_list
;
91 struct bt_list_head trace
;
92 struct bt_list_head env
;
93 struct bt_list_head stream
;
94 struct bt_list_head event
;
95 struct bt_list_head clock
;
96 struct bt_list_head callsite
;
100 * Children nodes are ctf_expression, typedef,
101 * typealias and type_specifier_list.
103 struct bt_list_head declaration_list
;
107 * Children nodes are ctf_expression, typedef,
108 * typealias and type_specifier_list.
110 struct bt_list_head declaration_list
;
114 * Children nodes are ctf_expression, typedef,
115 * typealias and type_specifier_list.
117 struct bt_list_head declaration_list
;
121 * Children nodes are ctf_expression, typedef,
122 * typealias and type_specifier_list.
124 struct bt_list_head declaration_list
;
128 * Children nodes are ctf_expression, typedef,
129 * typealias and type_specifier_list.
131 struct bt_list_head declaration_list
;
135 * Children nodes are ctf_expression, typedef,
136 * typealias and type_specifier_list.
138 struct bt_list_head declaration_list
;
141 struct bt_list_head left
; /* Should be string */
142 struct bt_list_head right
; /* Unary exp. or type */
148 UNARY_SIGNED_CONSTANT
,
149 UNARY_UNSIGNED_CONSTANT
,
154 * string for identifier, id_type, keywords,
155 * string literals and character constants.
158 int64_t signed_constant
;
159 uint64_t unsigned_constant
;
160 struct ctf_node
*sbrac_exp
;
163 UNARY_LINK_UNKNOWN
= 0,
170 struct ctf_node
*type_specifier_list
;
171 struct bt_list_head type_declarators
;
173 /* new type is "alias", existing type "target" */
175 struct ctf_node
*type_specifier_list
;
176 struct bt_list_head type_declarators
;
179 struct ctf_node
*type_specifier_list
;
180 struct bt_list_head type_declarators
;
183 struct ctf_node
*target
;
184 struct ctf_node
*alias
;
188 TYPESPEC_UNKNOWN
= 0,
203 TYPESPEC_FLOATING_POINT
,
210 /* For struct, variant and enum */
211 struct ctf_node
*node
;
215 /* list of type_specifier */
216 struct bt_list_head head
;
217 } type_specifier_list
;
219 unsigned int const_qualifier
;
222 struct bt_list_head pointers
;
225 TYPEDEC_ID
, /* identifier */
226 TYPEDEC_NESTED
, /* (), array or sequence */
231 /* typedec has no pointer list */
232 struct ctf_node
*type_declarator
;
234 * unary expression (value) or
235 * type_specifier_list.
237 struct bt_list_head length
;
238 /* for abstract type declarator */
239 unsigned int abstract_array
;
242 struct ctf_node
*bitfield_len
;
245 /* Children nodes are ctf_expression. */
246 struct bt_list_head expressions
;
249 /* Children nodes are ctf_expression. */
250 struct bt_list_head expressions
;
253 /* Children nodes are ctf_expression. */
254 struct bt_list_head expressions
;
259 * Range list or single value node. Contains unary
262 struct bt_list_head values
;
267 * Either NULL, or points to unary expression or
268 * type_specifier_list.
270 struct ctf_node
*container_type
;
271 struct bt_list_head enumerator_list
;
275 struct ctf_node
*type_specifier_list
;
276 struct bt_list_head type_declarators
;
277 } struct_or_variant_declaration
;
281 /* list of typedef, typealias and declarations */
282 struct bt_list_head declaration_list
;
287 /* list of typedef, typealias and declarations */
288 struct bt_list_head declaration_list
;
290 struct bt_list_head min_align
; /* align() attribute */
296 struct ctf_node root
;
297 struct bt_list_head allocated_nodes
;
300 const char *node_type(struct ctf_node
*node
);
305 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
307 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
309 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
311 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
312 struct ctf_trace
*trace
, int byte_order
);
314 int ctf_destroy_metadata(struct ctf_trace
*trace
);
316 #endif /* _CTF_AST_H */