Commit | Line | Data |
---|---|---|
8b9d5b5e MD |
1 | #ifndef _CTF_PARSER_H |
2 | #define _CTF_PARSER_H | |
3 | ||
ae5193a6 | 4 | #include <stdint.h> |
8b9d5b5e | 5 | #include <helpers/list.h> |
34d3acc4 MD |
6 | #include <stdio.h> |
7 | #include <glib.h> | |
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 | ||
16 | struct ctf_node; | |
17 | struct ctf_parser; | |
8b9d5b5e MD |
18 | |
19 | enum node_type { | |
20 | NODE_UNKNOWN, | |
21 | NODE_ROOT, | |
fce8006d | 22 | |
8b9d5b5e MD |
23 | NODE_EVENT, |
24 | NODE_STREAM, | |
8b9d5b5e MD |
25 | NODE_TRACE, |
26 | ||
fce8006d MD |
27 | NODE_CTF_EXPRESSION, |
28 | ||
29 | NODE_TYPEDEF, | |
30 | NODE_TYPEALIAS, | |
31 | ||
ae5193a6 | 32 | NODE_TYPE_SPECIFIER, |
fce8006d | 33 | NODE_DECLARATION_SPECIFIER, |
ae5193a6 | 34 | NODE_POINTER, |
fce8006d MD |
35 | NODE_TYPE_DECLARATOR, |
36 | ||
37 | NODE_FLOATING_POINT, | |
38 | NODE_INTEGER, | |
39 | NODE_STRING, | |
ae5193a6 | 40 | NODE_ENUMERATOR, |
fce8006d | 41 | NODE_ENUM, |
ae5193a6 | 42 | NODE_STRUCT_OR_VARIANT_DECLARATION, |
fce8006d MD |
43 | NODE_VARIANT, |
44 | NODE_STRUCT, | |
45 | ||
8b9d5b5e MD |
46 | NR_NODE_TYPES, |
47 | }; | |
48 | ||
8b9d5b5e | 49 | struct ctf_node { |
8b9d5b5e | 50 | struct ctf_node *parent; |
8b9d5b5e | 51 | struct cds_list_head siblings; |
8b9d5b5e | 52 | struct cds_list_head gc; |
ae5193a6 MD |
53 | |
54 | enum node_type type; | |
55 | union { | |
56 | struct { | |
57 | } unknown; | |
58 | struct { | |
59 | } root; | |
60 | struct { | |
61 | /* | |
62 | * Children nodes are ctf_expression, typedef or | |
63 | * typealias. | |
64 | */ | |
65 | struct cds_list_head _typedef; | |
66 | struct cds_list_head typealias; | |
67 | struct cds_list_head ctf_expression; | |
68 | } event; | |
69 | struct { | |
70 | /* | |
71 | * Children nodes are ctf_expression, typedef or | |
72 | * typealias. | |
73 | */ | |
74 | struct cds_list_head _typedef; | |
75 | struct cds_list_head typealias; | |
76 | struct cds_list_head ctf_expression; | |
77 | } stream; | |
78 | struct { | |
79 | /* | |
80 | * Children nodes are ctf_expression, typedef or | |
81 | * typealias. | |
82 | */ | |
83 | struct cds_list_head _typedef; | |
84 | struct cds_list_head typealias; | |
85 | struct cds_list_head ctf_expression; | |
86 | } trace; | |
87 | struct { | |
88 | char *left_id; | |
89 | enum { | |
90 | EXP_ID, | |
91 | EXP_TYPE, | |
92 | } type; | |
93 | union { | |
94 | char *id; | |
95 | struct ctf_node *type; | |
96 | } right; | |
97 | } ctf_expression; | |
98 | struct { | |
99 | struct ctf_node *declaration_specifier; | |
100 | struct cds_list_head type_declarator; | |
101 | } _typedef; | |
102 | struct { | |
103 | /* new type is "alias", existing type "target" */ | |
104 | struct ctf_node *target_declaration_specifier; | |
105 | struct cds_list_head target_type_declarator; | |
106 | struct ctf_node *alias_declaration_specifier; | |
107 | struct cds_list_head alias_type_declarator; | |
108 | } typealias; | |
109 | struct { | |
110 | enum { | |
111 | TYPESPEC_VOID, | |
112 | TYPESPEC_CHAR, | |
113 | TYPESPEC_SHORT, | |
114 | TYPESPEC_INT, | |
115 | TYPESPEC_LONG, | |
116 | TYPESPEC_FLOAT, | |
117 | TYPESPEC_DOUBLE, | |
118 | TYPESPEC_SIGNED, | |
119 | TYPESPEC_UNSIGNED, | |
120 | TYPESPEC_BOOL, | |
121 | TYPESPEC_COMPLEX, | |
122 | TYPESPEC_ID_TYPE, | |
123 | ||
124 | TYPESPEC_FLOATING_POINT, | |
125 | TYPESPEC_INTEGER, | |
126 | TYPESPEC_STRING, | |
127 | TYPESPEC_ENUM, | |
128 | TYPESPEC_VARIANT, | |
129 | TYPESPEC_STRUCT, | |
130 | } type; | |
131 | union { | |
132 | struct ctf_node *floating_point; | |
133 | struct ctf_node *integer; | |
134 | struct ctf_node *string; | |
135 | struct ctf_node *_enum; | |
136 | struct ctf_node *variant; | |
137 | struct ctf_node *_struct; | |
138 | } u; | |
139 | } type_specifier; | |
140 | struct { | |
141 | /* drop "const" specifier */ | |
142 | /* Children nodes are type_specifiers */ | |
143 | struct cds_list_head type_specifiers; | |
144 | } declaration_specifier; | |
145 | struct { | |
146 | } pointer; | |
147 | struct { | |
148 | struct cds_list_head pointers; | |
149 | enum { | |
150 | TYPEDEC_ID, /* identifier */ | |
151 | TYPEDEC_TYPEDEC,/* nested with () */ | |
152 | TYPEDEC_DIRECT, /* array or sequence */ | |
153 | } type; | |
154 | union { | |
155 | char *id; | |
156 | struct ctf_node *typedec; | |
157 | struct { | |
158 | /* typedec has no pointer list */ | |
159 | struct ctf_node *typedec; | |
160 | struct { | |
161 | enum { | |
162 | TYPEDEC_TYPE_VALUE, /* must be > 0 */ | |
163 | TYPEDEC_TYPE_TYPE, | |
164 | } type; | |
165 | union { | |
166 | uint64_t value; | |
167 | struct ctf_node *declaration_specifier; | |
168 | } u; | |
169 | } length; | |
170 | } direct; | |
171 | } u; | |
172 | } type_declarator; | |
173 | struct { | |
174 | /* Children nodes are ctf_expression. */ | |
175 | struct cds_list_head expressions; | |
176 | } floating_point; | |
177 | struct { | |
178 | /* Children nodes are ctf_expression. */ | |
179 | struct cds_list_head expressions; | |
180 | } integer; | |
181 | struct { | |
182 | /* Children nodes are ctf_expression. */ | |
183 | struct cds_list_head expressions; | |
184 | } string; | |
185 | struct { | |
186 | char *id; | |
187 | union { /* inclusive start/end of range */ | |
188 | struct { | |
189 | int64_t start, end; | |
190 | } _signed; | |
191 | struct { | |
192 | uint64_t start, end; | |
193 | } _unsigned; | |
194 | } u; | |
195 | } enumerator; | |
196 | struct { | |
197 | char *enum_id; | |
198 | struct { | |
199 | enum { | |
200 | ENUM_TYPE_VALUE, /* must be > 0 */ | |
201 | ENUM_TYPE_TYPE, | |
202 | } type; | |
203 | union { | |
204 | uint64_t value; | |
205 | struct ctf_node *declaration_specifier; | |
206 | } u; | |
207 | } container_type; | |
208 | struct cds_list_head enumerator_list; | |
209 | } _enum; | |
210 | struct { | |
211 | struct ctf_node *declaration_specifier; | |
212 | } struct_or_variant_declaration; | |
213 | struct { | |
214 | struct cds_list_head _typedef; | |
215 | struct cds_list_head typealias; | |
216 | struct cds_list_head declaration_list; | |
217 | } variant; | |
218 | struct { | |
219 | struct cds_list_head _typedef; | |
220 | struct cds_list_head typealias; | |
221 | struct cds_list_head declaration_list; | |
222 | } _struct; | |
223 | } u; | |
8b9d5b5e MD |
224 | }; |
225 | ||
34d3acc4 MD |
226 | struct ctf_ast { |
227 | struct ctf_node root; | |
228 | }; | |
8b9d5b5e MD |
229 | |
230 | #endif /* _CTF_PARSER_H */ |