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
;
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
,
153 * string for identifier, id_type, keywords,
154 * string literals and character constants.
157 int64_t signed_constant
;
158 uint64_t unsigned_constant
;
159 struct ctf_node
*sbrac_exp
;
162 UNARY_LINK_UNKNOWN
= 0,
169 struct ctf_node
*type_specifier_list
;
170 struct bt_list_head type_declarators
;
172 /* new type is "alias", existing type "target" */
174 struct ctf_node
*type_specifier_list
;
175 struct bt_list_head type_declarators
;
178 struct ctf_node
*type_specifier_list
;
179 struct bt_list_head type_declarators
;
182 struct ctf_node
*target
;
183 struct ctf_node
*alias
;
187 TYPESPEC_UNKNOWN
= 0,
202 TYPESPEC_FLOATING_POINT
,
209 /* For struct, variant and enum */
210 struct ctf_node
*node
;
214 /* list of type_specifier */
215 struct bt_list_head head
;
216 } type_specifier_list
;
218 unsigned int const_qualifier
;
221 struct bt_list_head pointers
;
224 TYPEDEC_ID
, /* identifier */
225 TYPEDEC_NESTED
, /* (), array or sequence */
230 /* typedec has no pointer list */
231 struct ctf_node
*type_declarator
;
233 * unary expression (value) or
234 * type_specifier_list.
236 struct bt_list_head length
;
237 /* for abstract type declarator */
238 unsigned int abstract_array
;
241 struct ctf_node
*bitfield_len
;
244 /* Children nodes are ctf_expression. */
245 struct bt_list_head expressions
;
248 /* Children nodes are ctf_expression. */
249 struct bt_list_head expressions
;
252 /* Children nodes are ctf_expression. */
253 struct bt_list_head expressions
;
258 * Range list or single value node. Contains unary
261 struct bt_list_head values
;
266 * Either NULL, or points to unary expression or
267 * type_specifier_list.
269 struct ctf_node
*container_type
;
270 struct bt_list_head enumerator_list
;
274 struct ctf_node
*type_specifier_list
;
275 struct bt_list_head type_declarators
;
276 } struct_or_variant_declaration
;
280 /* list of typedef, typealias and declarations */
281 struct bt_list_head declaration_list
;
286 /* list of typedef, typealias and declarations */
287 struct bt_list_head declaration_list
;
289 struct bt_list_head min_align
; /* align() attribute */
295 struct ctf_node root
;
298 const char *node_type(struct ctf_node
*node
);
303 int ctf_visitor_print_xml(FILE *fd
, int depth
, struct ctf_node
*node
);
305 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
);
309 int ctf_visitor_construct_metadata(FILE *fd
, int depth
, struct ctf_node
*node
,
310 struct ctf_trace
*trace
, int byte_order
);
312 int ctf_destroy_metadata(struct ctf_trace
*trace
);
314 #endif /* _CTF_AST_H */