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
46 NODE_UNARY_EXPRESSION
,
49 NODE_TYPEALIAS_TARGET
,
54 NODE_TYPE_SPECIFIER_LIST
,
63 NODE_STRUCT_OR_VARIANT_DECLARATION
,
72 * Parent node is only set on demand by specific visitor.
74 struct ctf_node
*parent
;
75 struct bt_list_head siblings
;
76 struct bt_list_head tmp_head
;
77 struct bt_list_head gc
;
85 * Children nodes are ctf_expression, typedef,
86 * typealias and type_specifier_list.
88 struct bt_list_head declaration_list
;
89 struct bt_list_head trace
;
90 struct bt_list_head env
;
91 struct bt_list_head stream
;
92 struct bt_list_head event
;
93 struct bt_list_head clock
;
97 * Children nodes are ctf_expression, typedef,
98 * typealias and type_specifier_list.
100 struct bt_list_head declaration_list
;
104 * Children nodes are ctf_expression, typedef,
105 * typealias and type_specifier_list.
107 struct bt_list_head declaration_list
;
111 * Children nodes are ctf_expression, typedef,
112 * typealias and type_specifier_list.
114 struct bt_list_head declaration_list
;
118 * Children nodes are ctf_expression, typedef,
119 * typealias and type_specifier_list.
121 struct bt_list_head declaration_list
;
125 * Children nodes are ctf_expression, typedef,
126 * typealias and type_specifier_list.
128 struct bt_list_head declaration_list
;
131 struct bt_list_head left
; /* Should be string */
132 struct bt_list_head right
; /* Unary exp. or type */
138 UNARY_SIGNED_CONSTANT
,
139 UNARY_UNSIGNED_CONSTANT
,
145 * string for identifier, id_type, keywords,
146 * string literals and character constants.
149 int64_t signed_constant
;
150 uint64_t unsigned_constant
;
151 struct ctf_node
*sbrac_exp
;
152 struct ctf_node
*nested_exp
;
155 UNARY_LINK_UNKNOWN
= 0,
162 struct ctf_node
*type_specifier_list
;
163 struct bt_list_head type_declarators
;
165 /* new type is "alias", existing type "target" */
167 struct ctf_node
*type_specifier_list
;
168 struct bt_list_head type_declarators
;
171 struct ctf_node
*type_specifier_list
;
172 struct bt_list_head type_declarators
;
175 struct ctf_node
*target
;
176 struct ctf_node
*alias
;
180 TYPESPEC_UNKNOWN
= 0,
195 TYPESPEC_FLOATING_POINT
,
202 /* For struct, variant and enum */
203 struct ctf_node
*node
;
207 /* list of type_specifier */
208 struct bt_list_head head
;
209 } type_specifier_list
;
211 unsigned int const_qualifier
;
214 struct bt_list_head pointers
;
217 TYPEDEC_ID
, /* identifier */
218 TYPEDEC_NESTED
, /* (), array or sequence */
223 /* typedec has no pointer list */
224 struct ctf_node
*type_declarator
;
226 * unary expression (value) or
227 * type_specifier_list.
229 struct bt_list_head length
;
230 /* for abstract type declarator */
231 unsigned int abstract_array
;
234 struct ctf_node
*bitfield_len
;
237 /* Children nodes are ctf_expression. */
238 struct bt_list_head expressions
;
241 /* Children nodes are ctf_expression. */
242 struct bt_list_head expressions
;
245 /* Children nodes are ctf_expression. */
246 struct bt_list_head expressions
;
251 * Range list or single value node. Contains unary
254 struct bt_list_head values
;
259 * Either NULL, or points to unary expression or
260 * type_specifier_list.
262 struct ctf_node
*container_type
;
263 struct bt_list_head enumerator_list
;
267 struct ctf_node
*type_specifier_list
;
268 struct bt_list_head type_declarators
;
269 } struct_or_variant_declaration
;
273 /* list of typedef, typealias and declarations */
274 struct bt_list_head declaration_list
;
279 /* list of typedef, typealias and declarations */
280 struct bt_list_head declaration_list
;
282 struct bt_list_head min_align
; /* align() attribute */
288 struct ctf_node root
;
289 struct bt_list_head allocated_nodes
;
292 const char *node_type(struct ctf_node
*node
);
296 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
297 int ctf_visitor_semantic_check(FILE *fd
, int depth
, struct ctf_node
*node
);
298 int ctf_visitor_parent_links(FILE *fd
, int depth
, struct ctf_node
*node
);
299 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
300 struct ctf_trace
*trace
, int byte_order
);
302 #endif /* _CTF_AST_H */