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
47 NODE_UNARY_EXPRESSION
,
50 NODE_TYPEALIAS_TARGET
,
55 NODE_TYPE_SPECIFIER_LIST
,
64 NODE_STRUCT_OR_VARIANT_DECLARATION
,
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
;
86 * Children nodes are ctf_expression, typedef,
87 * typealias and type_specifier_list.
89 struct bt_list_head declaration_list
;
90 struct bt_list_head trace
;
91 struct bt_list_head env
;
92 struct bt_list_head stream
;
93 struct bt_list_head event
;
94 struct bt_list_head clock
;
95 struct bt_list_head callsite
;
99 * Children nodes are ctf_expression, typedef,
100 * typealias and type_specifier_list.
102 struct bt_list_head declaration_list
;
106 * Children nodes are ctf_expression, typedef,
107 * typealias and type_specifier_list.
109 struct bt_list_head declaration_list
;
113 * Children nodes are ctf_expression, typedef,
114 * typealias and type_specifier_list.
116 struct bt_list_head declaration_list
;
120 * Children nodes are ctf_expression, typedef,
121 * typealias and type_specifier_list.
123 struct bt_list_head declaration_list
;
127 * Children nodes are ctf_expression, typedef,
128 * typealias and type_specifier_list.
130 struct bt_list_head declaration_list
;
134 * Children nodes are ctf_expression, typedef,
135 * typealias and type_specifier_list.
137 struct bt_list_head declaration_list
;
140 struct bt_list_head left
; /* Should be string */
141 struct bt_list_head right
; /* Unary exp. or type */
147 UNARY_SIGNED_CONSTANT
,
148 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
;
161 struct ctf_node
*nested_exp
;
164 UNARY_LINK_UNKNOWN
= 0,
171 struct ctf_node
*type_specifier_list
;
172 struct bt_list_head type_declarators
;
174 /* new type is "alias", existing type "target" */
176 struct ctf_node
*type_specifier_list
;
177 struct bt_list_head type_declarators
;
180 struct ctf_node
*type_specifier_list
;
181 struct bt_list_head type_declarators
;
184 struct ctf_node
*target
;
185 struct ctf_node
*alias
;
189 TYPESPEC_UNKNOWN
= 0,
204 TYPESPEC_FLOATING_POINT
,
211 /* For struct, variant and enum */
212 struct ctf_node
*node
;
216 /* list of type_specifier */
217 struct bt_list_head head
;
218 } type_specifier_list
;
220 unsigned int const_qualifier
;
223 struct bt_list_head pointers
;
226 TYPEDEC_ID
, /* identifier */
227 TYPEDEC_NESTED
, /* (), array or sequence */
232 /* typedec has no pointer list */
233 struct ctf_node
*type_declarator
;
235 * unary expression (value) or
236 * type_specifier_list.
238 struct bt_list_head length
;
239 /* for abstract type declarator */
240 unsigned int abstract_array
;
243 struct ctf_node
*bitfield_len
;
246 /* Children nodes are ctf_expression. */
247 struct bt_list_head expressions
;
250 /* Children nodes are ctf_expression. */
251 struct bt_list_head expressions
;
254 /* Children nodes are ctf_expression. */
255 struct bt_list_head expressions
;
260 * Range list or single value node. Contains unary
263 struct bt_list_head values
;
268 * Either NULL, or points to unary expression or
269 * type_specifier_list.
271 struct ctf_node
*container_type
;
272 struct bt_list_head enumerator_list
;
276 struct ctf_node
*type_specifier_list
;
277 struct bt_list_head type_declarators
;
278 } struct_or_variant_declaration
;
282 /* list of typedef, typealias and declarations */
283 struct bt_list_head declaration_list
;
288 /* list of typedef, typealias and declarations */
289 struct bt_list_head declaration_list
;
291 struct bt_list_head min_align
; /* align() attribute */
297 struct ctf_node root
;
298 struct bt_list_head allocated_nodes
;
301 const char *node_type(struct ctf_node
*node
);
305 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
306 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
307 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
308 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
309 struct ctf_trace
*trace
, int byte_order
);
310 int ctf_destroy_metadata(struct ctf_trace
*trace
);
312 #endif /* _CTF_AST_H */