Commit | Line | Data |
---|---|---|
8b9d5b5e MD |
1 | %{ |
2 | /* | |
c59a87f5 | 3 | * ctf-parser.y |
8b9d5b5e MD |
4 | * |
5 | * Common Trace Format Metadata Grammar. | |
c59a87f5 MD |
6 | * |
7 | * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * | |
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: | |
15 | * | |
16 | * The above copyright notice and this permission notice shall be included in | |
17 | * all copies or substantial portions of the Software. | |
c462e188 MD |
18 | * |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
25 | * SOFTWARE. | |
8b9d5b5e MD |
26 | */ |
27 | ||
28 | #include <stdio.h> | |
d876a5ba | 29 | #include <ctype.h> |
8b9d5b5e MD |
30 | #include <unistd.h> |
31 | #include <string.h> | |
32 | #include <stdlib.h> | |
33 | #include <assert.h> | |
8b9d5b5e | 34 | #include <glib.h> |
02b234c4 | 35 | #include <errno.h> |
380d60b1 | 36 | #include <inttypes.h> |
fe41395a | 37 | #include <babeltrace/list.h> |
70bd0a12 | 38 | #include <babeltrace/babeltrace-internal.h> |
34d3acc4 | 39 | #include "ctf-scanner.h" |
8b9d5b5e MD |
40 | #include "ctf-parser.h" |
41 | #include "ctf-ast.h" | |
42 | ||
5d6c80a5 | 43 | BT_HIDDEN |
a3983482 MD |
44 | int yydebug; |
45 | ||
48a01768 MD |
46 | /* Join two lists, put "add" at the end of "head". */ |
47 | static inline void | |
3122e6f0 | 48 | _bt_list_splice_tail (struct bt_list_head *add, struct bt_list_head *head) |
48a01768 MD |
49 | { |
50 | /* Do nothing if the list which gets added is empty. */ | |
51 | if (add != add->next) { | |
52 | add->next->prev = head->prev; | |
53 | add->prev->next = head; | |
54 | head->prev->next = add->next; | |
55 | head->prev = add->prev; | |
56 | } | |
57 | } | |
58 | ||
5d6c80a5 | 59 | BT_HIDDEN |
34d3acc4 | 60 | int yyparse(struct ctf_scanner *scanner); |
5d6c80a5 | 61 | BT_HIDDEN |
34d3acc4 | 62 | int yylex(union YYSTYPE *yyval, struct ctf_scanner *scanner); |
5d6c80a5 | 63 | BT_HIDDEN |
34d3acc4 | 64 | int yylex_init_extra(struct ctf_scanner *scanner, yyscan_t * ptr_yy_globals); |
5d6c80a5 | 65 | BT_HIDDEN |
61e9d0ce | 66 | int yylex_destroy(yyscan_t yyscanner); |
5d6c80a5 | 67 | BT_HIDDEN |
65102a8c | 68 | void yyrestart(FILE * in_str, yyscan_t scanner); |
8c834e5a MD |
69 | BT_HIDDEN |
70 | int yyget_lineno(yyscan_t yyscanner); | |
740aad26 MD |
71 | BT_HIDDEN |
72 | char *yyget_text(yyscan_t yyscanner); | |
8b9d5b5e | 73 | |
8b9d5b5e | 74 | struct gc_string { |
3122e6f0 | 75 | struct bt_list_head gc; |
6dc474b8 | 76 | size_t alloclen; |
8b9d5b5e MD |
77 | char s[]; |
78 | }; | |
79 | ||
34f7b02c | 80 | static const char *node_type_to_str[] = { |
590ca879 EB |
81 | #define ENTRY(S) [S] = #S, |
82 | FOREACH_CTF_NODES(ENTRY) | |
83 | #undef ENTRY | |
34f7b02c MD |
84 | }; |
85 | ||
ff201942 MD |
86 | /* |
87 | * Static node for out of memory errors. Only "type" is used. lineno is | |
88 | * always left at 0. The rest of the node content can be overwritten, | |
89 | * but is never used. | |
90 | */ | |
91 | static struct ctf_node error_node = { | |
bdb55bcb MD |
92 | .type = NODE_ERROR, |
93 | }; | |
94 | ||
5d6c80a5 | 95 | BT_HIDDEN |
34f7b02c MD |
96 | const char *node_type(struct ctf_node *node) |
97 | { | |
98 | if (node->type < NR_NODE_TYPES) | |
99 | return node_type_to_str[node->type]; | |
100 | else | |
101 | return NULL; | |
102 | } | |
103 | ||
6dc474b8 MD |
104 | static struct gc_string *gc_string_alloc(struct ctf_scanner *scanner, |
105 | size_t len) | |
8b9d5b5e | 106 | { |
6dc474b8 MD |
107 | struct gc_string *gstr; |
108 | size_t alloclen; | |
8b9d5b5e | 109 | |
6dc474b8 MD |
110 | /* TODO: could be faster with find first bit or glib Gstring */ |
111 | /* sizeof long to account for malloc header (int or long ?) */ | |
112 | for (alloclen = 8; alloclen < sizeof(long) + sizeof(*gstr) + len; | |
113 | alloclen *= 2); | |
114 | ||
115 | gstr = malloc(alloclen); | |
3122e6f0 | 116 | bt_list_add(&gstr->gc, &scanner->allocated_strings); |
6dc474b8 MD |
117 | gstr->alloclen = alloclen; |
118 | return gstr; | |
8b9d5b5e MD |
119 | } |
120 | ||
34d3acc4 | 121 | void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src) |
8b9d5b5e | 122 | { |
34d3acc4 MD |
123 | lvalp->gs = gc_string_alloc(scanner, strlen(src) + 1); |
124 | strcpy(lvalp->gs->s, src); | |
8b9d5b5e MD |
125 | } |
126 | ||
d876a5ba EB |
127 | static |
128 | int str_check(size_t str_len, size_t offset, size_t len) | |
129 | { | |
130 | /* check overflow */ | |
131 | if (offset + len < offset) | |
132 | return -1; | |
133 | if (offset + len > str_len) | |
134 | return -1; | |
135 | return 0; | |
136 | } | |
137 | ||
697b1050 MD |
138 | static |
139 | int bt_isodigit(int c) | |
140 | { | |
141 | switch (c) { | |
142 | case '0': | |
143 | case '1': | |
144 | case '2': | |
145 | case '3': | |
146 | case '4': | |
147 | case '5': | |
148 | case '6': | |
149 | case '7': | |
150 | return 1; | |
151 | default: | |
152 | return 0; | |
153 | } | |
154 | } | |
155 | ||
156 | static | |
157 | int parse_base_sequence(const char *src, size_t len, size_t pos, | |
158 | char *buffer, size_t *buf_len, int base) | |
159 | { | |
160 | const size_t max_char = 3; | |
161 | int nr_char = 0; | |
162 | ||
163 | while (!str_check(len, pos, 1) && nr_char < max_char) { | |
164 | char c = src[pos++]; | |
165 | ||
166 | if (base == 8) { | |
167 | if (bt_isodigit(c)) | |
168 | buffer[nr_char++] = c; | |
169 | else | |
170 | break; | |
171 | } else if (base == 16) { | |
172 | if (isxdigit(c)) | |
173 | buffer[nr_char++] = c; | |
174 | else | |
175 | break; | |
176 | ||
177 | } else { | |
178 | /* Unsupported base */ | |
179 | return -1; | |
180 | } | |
181 | } | |
182 | assert(nr_char > 0); | |
183 | buffer[nr_char] = '\0'; | |
184 | *buf_len = nr_char; | |
185 | return 0; | |
186 | } | |
187 | ||
d876a5ba EB |
188 | static |
189 | int import_basic_string(struct ctf_scanner *scanner, YYSTYPE *lvalp, | |
190 | size_t len, const char *src, char delim) | |
191 | { | |
192 | size_t pos = 0, dpos = 0; | |
193 | ||
194 | if (str_check(len, pos, 1)) | |
195 | return -1; | |
196 | if (src[pos++] != delim) | |
197 | return -1; | |
198 | ||
199 | while (src[pos] != delim) { | |
200 | char c; | |
201 | ||
202 | if (str_check(len, pos, 1)) | |
203 | return -1; | |
204 | c = src[pos++]; | |
205 | if (c == '\\') { | |
206 | if (str_check(len, pos, 1)) | |
207 | return -1; | |
208 | c = src[pos++]; | |
209 | ||
210 | switch (c) { | |
d876a5ba EB |
211 | case 'a': |
212 | c = '\a'; | |
213 | break; | |
214 | case 'b': | |
215 | c = '\b'; | |
216 | break; | |
217 | case 'f': | |
218 | c = '\f'; | |
219 | break; | |
220 | case 'n': | |
221 | c = '\n'; | |
222 | break; | |
223 | case 'r': | |
224 | c = '\r'; | |
225 | break; | |
226 | case 't': | |
227 | c = '\t'; | |
228 | break; | |
229 | case 'v': | |
230 | c = '\v'; | |
231 | break; | |
232 | case '\\': | |
233 | c = '\\'; | |
234 | break; | |
235 | case '\'': | |
236 | c = '\''; | |
237 | break; | |
238 | case '\"': | |
239 | c = '\"'; | |
240 | break; | |
241 | case '?': | |
242 | c = '?'; | |
243 | break; | |
697b1050 MD |
244 | case '0': |
245 | case '1': | |
246 | case '2': | |
247 | case '3': | |
248 | case '4': | |
249 | case '5': | |
250 | case '6': | |
251 | case '7': | |
d876a5ba | 252 | { |
697b1050 MD |
253 | char oct_buffer[4]; |
254 | size_t oct_len; | |
d876a5ba | 255 | |
697b1050 MD |
256 | if (parse_base_sequence(src, len, pos - 1, |
257 | oct_buffer, &oct_len, 8)) | |
d876a5ba | 258 | return -1; |
d876a5ba | 259 | c = strtoul(&oct_buffer[0], NULL, 8); |
697b1050 | 260 | pos += oct_len - 1; |
d876a5ba EB |
261 | break; |
262 | } | |
263 | case 'x': | |
264 | { | |
697b1050 MD |
265 | char hex_buffer[4]; |
266 | size_t hex_len; | |
d876a5ba | 267 | |
697b1050 MD |
268 | if (parse_base_sequence(src, len, pos, |
269 | hex_buffer, &hex_len, 16)) | |
d876a5ba | 270 | return -1; |
d876a5ba EB |
271 | c = strtoul(&hex_buffer[0], NULL, 16); |
272 | pos += hex_len; | |
273 | break; | |
274 | } | |
275 | default: | |
276 | return -1; | |
277 | } | |
278 | } | |
279 | if (str_check(len, dpos, 1)) | |
280 | return -1; | |
281 | lvalp->gs->s[dpos++] = c; | |
282 | } | |
283 | ||
284 | if (str_check(len, dpos, 1)) | |
285 | return -1; | |
286 | lvalp->gs->s[dpos++] = '\0'; | |
287 | ||
288 | if (str_check(len, pos, 1)) | |
289 | return -1; | |
290 | if (src[pos++] != delim) | |
291 | return -1; | |
292 | ||
293 | if (str_check(len, pos, 1)) | |
294 | return -1; | |
295 | if (src[pos] != '\0') | |
296 | return -1; | |
297 | return 0; | |
298 | } | |
299 | ||
300 | int import_string(struct ctf_scanner *scanner, YYSTYPE *lvalp, | |
301 | const char *src, char delim) | |
302 | { | |
303 | size_t len; | |
304 | ||
305 | len = strlen(src) + 1; | |
306 | lvalp->gs = gc_string_alloc(scanner, len); | |
307 | if (src[0] == 'L') { | |
308 | // TODO: import wide string | |
309 | printfl_error(yyget_lineno(scanner), | |
310 | "Wide string not supported yet."); | |
311 | return -1; | |
312 | } else { | |
313 | return import_basic_string(scanner, lvalp, len, src, delim); | |
314 | } | |
315 | } | |
316 | ||
609bd1bf MD |
317 | static void init_scope(struct ctf_scanner_scope *scope, |
318 | struct ctf_scanner_scope *parent) | |
8b9d5b5e MD |
319 | { |
320 | scope->parent = parent; | |
321 | scope->types = g_hash_table_new_full(g_str_hash, g_str_equal, | |
6dc474b8 | 322 | NULL, NULL); |
8b9d5b5e MD |
323 | } |
324 | ||
609bd1bf | 325 | static void finalize_scope(struct ctf_scanner_scope *scope) |
8b9d5b5e MD |
326 | { |
327 | g_hash_table_destroy(scope->types); | |
328 | } | |
329 | ||
34d3acc4 | 330 | static void push_scope(struct ctf_scanner *scanner) |
8b9d5b5e | 331 | { |
609bd1bf | 332 | struct ctf_scanner_scope *ns; |
8b9d5b5e | 333 | |
a3983482 | 334 | printf_debug("push scope\n"); |
609bd1bf | 335 | ns = malloc(sizeof(struct ctf_scanner_scope)); |
34d3acc4 MD |
336 | init_scope(ns, scanner->cs); |
337 | scanner->cs = ns; | |
8b9d5b5e MD |
338 | } |
339 | ||
34d3acc4 | 340 | static void pop_scope(struct ctf_scanner *scanner) |
8b9d5b5e | 341 | { |
609bd1bf | 342 | struct ctf_scanner_scope *os; |
8b9d5b5e | 343 | |
a3983482 | 344 | printf_debug("pop scope\n"); |
34d3acc4 MD |
345 | os = scanner->cs; |
346 | scanner->cs = os->parent; | |
8b9d5b5e MD |
347 | finalize_scope(os); |
348 | free(os); | |
349 | } | |
350 | ||
609bd1bf | 351 | static int lookup_type(struct ctf_scanner_scope *s, const char *id) |
8b9d5b5e MD |
352 | { |
353 | int ret; | |
354 | ||
380d60b1 | 355 | ret = (int) (long) g_hash_table_lookup(s->types, id); |
a3983482 | 356 | printf_debug("lookup %p %s %d\n", s, id, ret); |
8b9d5b5e MD |
357 | return ret; |
358 | } | |
359 | ||
5d6c80a5 | 360 | BT_HIDDEN |
34d3acc4 | 361 | int is_type(struct ctf_scanner *scanner, const char *id) |
8b9d5b5e | 362 | { |
609bd1bf | 363 | struct ctf_scanner_scope *it; |
8b9d5b5e MD |
364 | int ret = 0; |
365 | ||
34d3acc4 | 366 | for (it = scanner->cs; it != NULL; it = it->parent) { |
8b9d5b5e MD |
367 | if (lookup_type(it, id)) { |
368 | ret = 1; | |
369 | break; | |
370 | } | |
371 | } | |
a3983482 | 372 | printf_debug("is type %s %d\n", id, ret); |
8b9d5b5e MD |
373 | return ret; |
374 | } | |
375 | ||
6dc474b8 | 376 | static void add_type(struct ctf_scanner *scanner, struct gc_string *id) |
8b9d5b5e | 377 | { |
a3983482 | 378 | printf_debug("add type %s\n", id->s); |
6dc474b8 | 379 | if (lookup_type(scanner->cs, id->s)) |
8b9d5b5e | 380 | return; |
6dc474b8 | 381 | g_hash_table_insert(scanner->cs->types, id->s, id->s); |
8b9d5b5e MD |
382 | } |
383 | ||
02b234c4 MD |
384 | static struct ctf_node *make_node(struct ctf_scanner *scanner, |
385 | enum node_type type) | |
386 | { | |
387 | struct ctf_ast *ast = ctf_scanner_get_ast(scanner); | |
388 | struct ctf_node *node; | |
389 | ||
390 | node = malloc(sizeof(*node)); | |
bdb55bcb | 391 | if (!node) { |
ff201942 | 392 | printfl_fatal(yyget_lineno(scanner->scanner), "out of memory"); |
bdb55bcb MD |
393 | return &error_node; |
394 | } | |
02b234c4 MD |
395 | memset(node, 0, sizeof(*node)); |
396 | node->type = type; | |
5c5c3455 | 397 | node->lineno = yyget_lineno(scanner->scanner); |
3122e6f0 JD |
398 | BT_INIT_LIST_HEAD(&node->tmp_head); |
399 | bt_list_add(&node->gc, &ast->allocated_nodes); | |
400 | bt_list_add(&node->siblings, &node->tmp_head); | |
02b234c4 MD |
401 | |
402 | switch (type) { | |
403 | case NODE_ROOT: | |
bdb55bcb | 404 | node->type = NODE_ERROR; |
c55adfb9 | 405 | printfn_fatal(node, "trying to create root node"); |
02b234c4 MD |
406 | break; |
407 | ||
408 | case NODE_EVENT: | |
3122e6f0 | 409 | BT_INIT_LIST_HEAD(&node->u.event.declaration_list); |
02b234c4 MD |
410 | break; |
411 | case NODE_STREAM: | |
3122e6f0 | 412 | BT_INIT_LIST_HEAD(&node->u.stream.declaration_list); |
02b234c4 | 413 | break; |
e2c76a4d | 414 | case NODE_ENV: |
3122e6f0 | 415 | BT_INIT_LIST_HEAD(&node->u.env.declaration_list); |
e2c76a4d | 416 | break; |
02b234c4 | 417 | case NODE_TRACE: |
3122e6f0 | 418 | BT_INIT_LIST_HEAD(&node->u.trace.declaration_list); |
02b234c4 | 419 | break; |
73d15916 | 420 | case NODE_CLOCK: |
3122e6f0 | 421 | BT_INIT_LIST_HEAD(&node->u.clock.declaration_list); |
73d15916 | 422 | break; |
f133896d MD |
423 | case NODE_CALLSITE: |
424 | BT_INIT_LIST_HEAD(&node->u.callsite.declaration_list); | |
425 | break; | |
02b234c4 MD |
426 | |
427 | case NODE_CTF_EXPRESSION: | |
3122e6f0 JD |
428 | BT_INIT_LIST_HEAD(&node->u.ctf_expression.left); |
429 | BT_INIT_LIST_HEAD(&node->u.ctf_expression.right); | |
02b234c4 | 430 | break; |
6dc474b8 MD |
431 | case NODE_UNARY_EXPRESSION: |
432 | break; | |
02b234c4 MD |
433 | |
434 | case NODE_TYPEDEF: | |
3122e6f0 | 435 | BT_INIT_LIST_HEAD(&node->u._typedef.type_declarators); |
02b234c4 MD |
436 | break; |
437 | case NODE_TYPEALIAS_TARGET: | |
3122e6f0 | 438 | BT_INIT_LIST_HEAD(&node->u.typealias_target.type_declarators); |
02b234c4 MD |
439 | break; |
440 | case NODE_TYPEALIAS_ALIAS: | |
3122e6f0 | 441 | BT_INIT_LIST_HEAD(&node->u.typealias_alias.type_declarators); |
02b234c4 MD |
442 | break; |
443 | case NODE_TYPEALIAS: | |
444 | break; | |
445 | ||
446 | case NODE_TYPE_SPECIFIER: | |
447 | break; | |
3e11b713 | 448 | case NODE_TYPE_SPECIFIER_LIST: |
3122e6f0 | 449 | BT_INIT_LIST_HEAD(&node->u.type_specifier_list.head); |
3e11b713 | 450 | break; |
02b234c4 MD |
451 | case NODE_POINTER: |
452 | break; | |
453 | case NODE_TYPE_DECLARATOR: | |
3122e6f0 | 454 | BT_INIT_LIST_HEAD(&node->u.type_declarator.pointers); |
02b234c4 MD |
455 | break; |
456 | ||
457 | case NODE_FLOATING_POINT: | |
3122e6f0 | 458 | BT_INIT_LIST_HEAD(&node->u.floating_point.expressions); |
02b234c4 MD |
459 | break; |
460 | case NODE_INTEGER: | |
3122e6f0 | 461 | BT_INIT_LIST_HEAD(&node->u.integer.expressions); |
02b234c4 MD |
462 | break; |
463 | case NODE_STRING: | |
3122e6f0 | 464 | BT_INIT_LIST_HEAD(&node->u.string.expressions); |
02b234c4 MD |
465 | break; |
466 | case NODE_ENUMERATOR: | |
3122e6f0 | 467 | BT_INIT_LIST_HEAD(&node->u.enumerator.values); |
02b234c4 MD |
468 | break; |
469 | case NODE_ENUM: | |
3122e6f0 | 470 | BT_INIT_LIST_HEAD(&node->u._enum.enumerator_list); |
02b234c4 MD |
471 | break; |
472 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
3122e6f0 | 473 | BT_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.type_declarators); |
02b234c4 MD |
474 | break; |
475 | case NODE_VARIANT: | |
3122e6f0 | 476 | BT_INIT_LIST_HEAD(&node->u.variant.declaration_list); |
02b234c4 MD |
477 | break; |
478 | case NODE_STRUCT: | |
3122e6f0 JD |
479 | BT_INIT_LIST_HEAD(&node->u._struct.declaration_list); |
480 | BT_INIT_LIST_HEAD(&node->u._struct.min_align); | |
02b234c4 MD |
481 | break; |
482 | ||
483 | case NODE_UNKNOWN: | |
484 | default: | |
bdb55bcb | 485 | node->type = NODE_ERROR; |
c55adfb9 | 486 | printfn_fatal(node, "unknown node type '%d'", (int) type); |
02b234c4 MD |
487 | break; |
488 | } | |
489 | ||
490 | return node; | |
491 | } | |
492 | ||
493 | static int reparent_ctf_expression(struct ctf_node *node, | |
494 | struct ctf_node *parent) | |
495 | { | |
496 | switch (parent->type) { | |
497 | case NODE_EVENT: | |
3122e6f0 | 498 | _bt_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list); |
02b234c4 MD |
499 | break; |
500 | case NODE_STREAM: | |
3122e6f0 | 501 | _bt_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list); |
02b234c4 | 502 | break; |
e2c76a4d | 503 | case NODE_ENV: |
3122e6f0 | 504 | _bt_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list); |
e2c76a4d | 505 | break; |
02b234c4 | 506 | case NODE_TRACE: |
3122e6f0 | 507 | _bt_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list); |
02b234c4 | 508 | break; |
73d15916 | 509 | case NODE_CLOCK: |
3122e6f0 | 510 | _bt_list_splice_tail(&node->tmp_head, &parent->u.clock.declaration_list); |
73d15916 | 511 | break; |
f133896d MD |
512 | case NODE_CALLSITE: |
513 | _bt_list_splice_tail(&node->tmp_head, &parent->u.callsite.declaration_list); | |
514 | break; | |
02b234c4 | 515 | case NODE_FLOATING_POINT: |
3122e6f0 | 516 | _bt_list_splice_tail(&node->tmp_head, &parent->u.floating_point.expressions); |
02b234c4 MD |
517 | break; |
518 | case NODE_INTEGER: | |
3122e6f0 | 519 | _bt_list_splice_tail(&node->tmp_head, &parent->u.integer.expressions); |
02b234c4 MD |
520 | break; |
521 | case NODE_STRING: | |
3122e6f0 | 522 | _bt_list_splice_tail(&node->tmp_head, &parent->u.string.expressions); |
02b234c4 MD |
523 | break; |
524 | ||
525 | case NODE_ROOT: | |
526 | case NODE_CTF_EXPRESSION: | |
527 | case NODE_TYPEDEF: | |
528 | case NODE_TYPEALIAS_TARGET: | |
529 | case NODE_TYPEALIAS_ALIAS: | |
530 | case NODE_TYPEALIAS: | |
531 | case NODE_TYPE_SPECIFIER: | |
3e11b713 | 532 | case NODE_TYPE_SPECIFIER_LIST: |
02b234c4 MD |
533 | case NODE_POINTER: |
534 | case NODE_TYPE_DECLARATOR: | |
535 | case NODE_ENUMERATOR: | |
536 | case NODE_ENUM: | |
537 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
538 | case NODE_VARIANT: | |
539 | case NODE_STRUCT: | |
6dc474b8 | 540 | case NODE_UNARY_EXPRESSION: |
02b234c4 MD |
541 | return -EPERM; |
542 | ||
543 | case NODE_UNKNOWN: | |
544 | default: | |
c55adfb9 | 545 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
02b234c4 MD |
546 | return -EINVAL; |
547 | } | |
548 | return 0; | |
549 | } | |
550 | ||
551 | static int reparent_typedef(struct ctf_node *node, struct ctf_node *parent) | |
552 | { | |
553 | switch (parent->type) { | |
554 | case NODE_ROOT: | |
3122e6f0 | 555 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list); |
02b234c4 MD |
556 | break; |
557 | case NODE_EVENT: | |
3122e6f0 | 558 | _bt_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list); |
02b234c4 MD |
559 | break; |
560 | case NODE_STREAM: | |
3122e6f0 | 561 | _bt_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list); |
02b234c4 | 562 | break; |
e2c76a4d | 563 | case NODE_ENV: |
3122e6f0 | 564 | _bt_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list); |
e2c76a4d | 565 | break; |
02b234c4 | 566 | case NODE_TRACE: |
3122e6f0 | 567 | _bt_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list); |
02b234c4 | 568 | break; |
73d15916 | 569 | case NODE_CLOCK: |
3122e6f0 | 570 | _bt_list_splice_tail(&node->tmp_head, &parent->u.clock.declaration_list); |
73d15916 | 571 | break; |
f133896d MD |
572 | case NODE_CALLSITE: |
573 | _bt_list_splice_tail(&node->tmp_head, &parent->u.callsite.declaration_list); | |
574 | break; | |
02b234c4 | 575 | case NODE_VARIANT: |
3122e6f0 | 576 | _bt_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list); |
02b234c4 MD |
577 | break; |
578 | case NODE_STRUCT: | |
3122e6f0 | 579 | _bt_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list); |
02b234c4 MD |
580 | break; |
581 | ||
582 | case NODE_FLOATING_POINT: | |
583 | case NODE_INTEGER: | |
584 | case NODE_STRING: | |
585 | case NODE_CTF_EXPRESSION: | |
586 | case NODE_TYPEDEF: | |
587 | case NODE_TYPEALIAS_TARGET: | |
588 | case NODE_TYPEALIAS_ALIAS: | |
589 | case NODE_TYPEALIAS: | |
590 | case NODE_TYPE_SPECIFIER: | |
3e11b713 | 591 | case NODE_TYPE_SPECIFIER_LIST: |
02b234c4 MD |
592 | case NODE_POINTER: |
593 | case NODE_TYPE_DECLARATOR: | |
594 | case NODE_ENUMERATOR: | |
595 | case NODE_ENUM: | |
596 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
6dc474b8 | 597 | case NODE_UNARY_EXPRESSION: |
02b234c4 MD |
598 | return -EPERM; |
599 | ||
600 | case NODE_UNKNOWN: | |
601 | default: | |
c55adfb9 | 602 | printfn_fatal(node, "unknown node type %d", parent->type); |
02b234c4 MD |
603 | return -EINVAL; |
604 | } | |
605 | return 0; | |
606 | } | |
607 | ||
608 | static int reparent_typealias(struct ctf_node *node, struct ctf_node *parent) | |
609 | { | |
610 | switch (parent->type) { | |
611 | case NODE_ROOT: | |
3122e6f0 | 612 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list); |
02b234c4 MD |
613 | break; |
614 | case NODE_EVENT: | |
3122e6f0 | 615 | _bt_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list); |
02b234c4 MD |
616 | break; |
617 | case NODE_STREAM: | |
3122e6f0 | 618 | _bt_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list); |
02b234c4 | 619 | break; |
e2c76a4d | 620 | case NODE_ENV: |
3122e6f0 | 621 | _bt_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list); |
e2c76a4d | 622 | break; |
02b234c4 | 623 | case NODE_TRACE: |
3122e6f0 | 624 | _bt_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list); |
02b234c4 | 625 | break; |
73d15916 | 626 | case NODE_CLOCK: |
3122e6f0 | 627 | _bt_list_splice_tail(&node->tmp_head, &parent->u.clock.declaration_list); |
73d15916 | 628 | break; |
f133896d MD |
629 | case NODE_CALLSITE: |
630 | _bt_list_splice_tail(&node->tmp_head, &parent->u.callsite.declaration_list); | |
631 | break; | |
02b234c4 | 632 | case NODE_VARIANT: |
3122e6f0 | 633 | _bt_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list); |
02b234c4 MD |
634 | break; |
635 | case NODE_STRUCT: | |
3122e6f0 | 636 | _bt_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list); |
02b234c4 MD |
637 | break; |
638 | ||
639 | case NODE_FLOATING_POINT: | |
640 | case NODE_INTEGER: | |
641 | case NODE_STRING: | |
642 | case NODE_CTF_EXPRESSION: | |
643 | case NODE_TYPEDEF: | |
644 | case NODE_TYPEALIAS_TARGET: | |
645 | case NODE_TYPEALIAS_ALIAS: | |
646 | case NODE_TYPEALIAS: | |
647 | case NODE_TYPE_SPECIFIER: | |
3e11b713 | 648 | case NODE_TYPE_SPECIFIER_LIST: |
02b234c4 MD |
649 | case NODE_POINTER: |
650 | case NODE_TYPE_DECLARATOR: | |
651 | case NODE_ENUMERATOR: | |
652 | case NODE_ENUM: | |
653 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
6dc474b8 | 654 | case NODE_UNARY_EXPRESSION: |
02b234c4 MD |
655 | return -EPERM; |
656 | ||
657 | case NODE_UNKNOWN: | |
658 | default: | |
c55adfb9 | 659 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
02b234c4 MD |
660 | return -EINVAL; |
661 | } | |
662 | return 0; | |
663 | } | |
664 | ||
6dc474b8 MD |
665 | static int reparent_type_specifier(struct ctf_node *node, |
666 | struct ctf_node *parent) | |
3e11b713 MD |
667 | { |
668 | switch (parent->type) { | |
669 | case NODE_TYPE_SPECIFIER_LIST: | |
3122e6f0 | 670 | _bt_list_splice_tail(&node->tmp_head, &parent->u.type_specifier_list.head); |
3e11b713 MD |
671 | break; |
672 | ||
673 | case NODE_TYPE_SPECIFIER: | |
674 | case NODE_EVENT: | |
675 | case NODE_STREAM: | |
e2c76a4d | 676 | case NODE_ENV: |
3e11b713 | 677 | case NODE_TRACE: |
73d15916 | 678 | case NODE_CLOCK: |
f133896d | 679 | case NODE_CALLSITE: |
3e11b713 MD |
680 | case NODE_VARIANT: |
681 | case NODE_STRUCT: | |
682 | case NODE_TYPEDEF: | |
683 | case NODE_TYPEALIAS_TARGET: | |
684 | case NODE_TYPEALIAS_ALIAS: | |
685 | case NODE_TYPE_DECLARATOR: | |
686 | case NODE_ENUM: | |
687 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
688 | case NODE_TYPEALIAS: | |
689 | case NODE_FLOATING_POINT: | |
690 | case NODE_INTEGER: | |
691 | case NODE_STRING: | |
692 | case NODE_CTF_EXPRESSION: | |
693 | case NODE_POINTER: | |
694 | case NODE_ENUMERATOR: | |
695 | case NODE_UNARY_EXPRESSION: | |
696 | return -EPERM; | |
697 | ||
698 | case NODE_UNKNOWN: | |
699 | default: | |
c55adfb9 | 700 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
3e11b713 MD |
701 | return -EINVAL; |
702 | } | |
703 | return 0; | |
704 | } | |
705 | ||
706 | static int reparent_type_specifier_list(struct ctf_node *node, | |
707 | struct ctf_node *parent) | |
02b234c4 MD |
708 | { |
709 | switch (parent->type) { | |
710 | case NODE_ROOT: | |
3122e6f0 | 711 | bt_list_add_tail(&node->siblings, &parent->u.root.declaration_list); |
02b234c4 MD |
712 | break; |
713 | case NODE_EVENT: | |
3122e6f0 | 714 | bt_list_add_tail(&node->siblings, &parent->u.event.declaration_list); |
02b234c4 MD |
715 | break; |
716 | case NODE_STREAM: | |
3122e6f0 | 717 | bt_list_add_tail(&node->siblings, &parent->u.stream.declaration_list); |
02b234c4 | 718 | break; |
e2c76a4d | 719 | case NODE_ENV: |
3122e6f0 | 720 | bt_list_add_tail(&node->siblings, &parent->u.env.declaration_list); |
e2c76a4d | 721 | break; |
02b234c4 | 722 | case NODE_TRACE: |
3122e6f0 | 723 | bt_list_add_tail(&node->siblings, &parent->u.trace.declaration_list); |
02b234c4 | 724 | break; |
73d15916 | 725 | case NODE_CLOCK: |
3122e6f0 | 726 | bt_list_add_tail(&node->siblings, &parent->u.clock.declaration_list); |
73d15916 | 727 | break; |
f133896d MD |
728 | case NODE_CALLSITE: |
729 | bt_list_add_tail(&node->siblings, &parent->u.callsite.declaration_list); | |
730 | break; | |
02b234c4 | 731 | case NODE_VARIANT: |
3122e6f0 | 732 | bt_list_add_tail(&node->siblings, &parent->u.variant.declaration_list); |
02b234c4 MD |
733 | break; |
734 | case NODE_STRUCT: | |
3122e6f0 | 735 | bt_list_add_tail(&node->siblings, &parent->u._struct.declaration_list); |
02b234c4 MD |
736 | break; |
737 | case NODE_TYPEDEF: | |
3e11b713 | 738 | parent->u._typedef.type_specifier_list = node; |
02b234c4 MD |
739 | break; |
740 | case NODE_TYPEALIAS_TARGET: | |
3e11b713 | 741 | parent->u.typealias_target.type_specifier_list = node; |
02b234c4 MD |
742 | break; |
743 | case NODE_TYPEALIAS_ALIAS: | |
3e11b713 | 744 | parent->u.typealias_alias.type_specifier_list = node; |
02b234c4 | 745 | break; |
02b234c4 | 746 | case NODE_ENUM: |
3e11b713 | 747 | parent->u._enum.container_type = node; |
02b234c4 MD |
748 | break; |
749 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
3e11b713 | 750 | parent->u.struct_or_variant_declaration.type_specifier_list = node; |
02b234c4 | 751 | break; |
98df1c9f | 752 | case NODE_TYPE_DECLARATOR: |
3e11b713 | 753 | case NODE_TYPE_SPECIFIER: |
02b234c4 MD |
754 | case NODE_TYPEALIAS: |
755 | case NODE_FLOATING_POINT: | |
756 | case NODE_INTEGER: | |
757 | case NODE_STRING: | |
758 | case NODE_CTF_EXPRESSION: | |
02b234c4 MD |
759 | case NODE_POINTER: |
760 | case NODE_ENUMERATOR: | |
6dc474b8 | 761 | case NODE_UNARY_EXPRESSION: |
02b234c4 MD |
762 | return -EPERM; |
763 | ||
764 | case NODE_UNKNOWN: | |
765 | default: | |
c55adfb9 | 766 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
02b234c4 MD |
767 | return -EINVAL; |
768 | } | |
769 | return 0; | |
770 | } | |
771 | ||
772 | static int reparent_type_declarator(struct ctf_node *node, | |
773 | struct ctf_node *parent) | |
774 | { | |
775 | switch (parent->type) { | |
776 | case NODE_TYPE_DECLARATOR: | |
777 | parent->u.type_declarator.type = TYPEDEC_NESTED; | |
778 | parent->u.type_declarator.u.nested.type_declarator = node; | |
779 | break; | |
780 | case NODE_STRUCT_OR_VARIANT_DECLARATION: | |
3122e6f0 | 781 | _bt_list_splice_tail(&node->tmp_head, &parent->u.struct_or_variant_declaration.type_declarators); |
02b234c4 MD |
782 | break; |
783 | case NODE_TYPEDEF: | |
3122e6f0 | 784 | _bt_list_splice_tail(&node->tmp_head, &parent->u._typedef.type_declarators); |
02b234c4 MD |
785 | break; |
786 | case NODE_TYPEALIAS_TARGET: | |
3122e6f0 | 787 | _bt_list_splice_tail(&node->tmp_head, &parent->u.typealias_target.type_declarators); |
02b234c4 MD |
788 | break; |
789 | case NODE_TYPEALIAS_ALIAS: | |
3122e6f0 | 790 | _bt_list_splice_tail(&node->tmp_head, &parent->u.typealias_alias.type_declarators); |
02b234c4 MD |
791 | break; |
792 | ||
793 | case NODE_ROOT: | |
794 | case NODE_EVENT: | |
795 | case NODE_STREAM: | |
e2c76a4d | 796 | case NODE_ENV: |
02b234c4 | 797 | case NODE_TRACE: |
73d15916 | 798 | case NODE_CLOCK: |
f133896d | 799 | case NODE_CALLSITE: |
02b234c4 MD |
800 | case NODE_VARIANT: |
801 | case NODE_STRUCT: | |
802 | case NODE_TYPEALIAS: | |
803 | case NODE_ENUM: | |
804 | case NODE_FLOATING_POINT: | |
805 | case NODE_INTEGER: | |
806 | case NODE_STRING: | |
807 | case NODE_CTF_EXPRESSION: | |
808 | case NODE_TYPE_SPECIFIER: | |
3e11b713 | 809 | case NODE_TYPE_SPECIFIER_LIST: |
02b234c4 MD |
810 | case NODE_POINTER: |
811 | case NODE_ENUMERATOR: | |
6dc474b8 | 812 | case NODE_UNARY_EXPRESSION: |
02b234c4 MD |
813 | return -EPERM; |
814 | ||
815 | case NODE_UNKNOWN: | |
816 | default: | |
c55adfb9 | 817 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
02b234c4 MD |
818 | return -EINVAL; |
819 | } | |
820 | return 0; | |
821 | } | |
822 | ||
823 | /* | |
48a01768 | 824 | * set_parent_node |
02b234c4 | 825 | * |
48a01768 MD |
826 | * Link node to parent. Returns 0 on success, -EPERM if it is not permitted to |
827 | * create the link declared by the input, -ENOENT if node or parent is NULL, | |
828 | * -EINVAL if there is an internal structure problem. | |
02b234c4 | 829 | */ |
48a01768 | 830 | static int set_parent_node(struct ctf_node *node, |
02b234c4 MD |
831 | struct ctf_node *parent) |
832 | { | |
833 | if (!node || !parent) | |
834 | return -ENOENT; | |
835 | ||
6dc474b8 | 836 | /* Note: Linking to parent will be done only by an external visitor */ |
02b234c4 MD |
837 | |
838 | switch (node->type) { | |
839 | case NODE_ROOT: | |
c55adfb9 | 840 | printfn_fatal(node, "trying to reparent root node"); |
02b234c4 MD |
841 | return -EINVAL; |
842 | ||
843 | case NODE_EVENT: | |
48a01768 | 844 | if (parent->type == NODE_ROOT) { |
3122e6f0 | 845 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.event); |
3e11b713 | 846 | } else { |
02b234c4 | 847 | return -EPERM; |
3e11b713 | 848 | } |
02b234c4 MD |
849 | break; |
850 | case NODE_STREAM: | |
48a01768 | 851 | if (parent->type == NODE_ROOT) { |
3122e6f0 | 852 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.stream); |
3e11b713 | 853 | } else { |
02b234c4 | 854 | return -EPERM; |
3e11b713 | 855 | } |
02b234c4 | 856 | break; |
e2c76a4d MD |
857 | case NODE_ENV: |
858 | if (parent->type == NODE_ROOT) { | |
3122e6f0 | 859 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.env); |
e2c76a4d MD |
860 | } else { |
861 | return -EPERM; | |
862 | } | |
863 | break; | |
02b234c4 | 864 | case NODE_TRACE: |
48a01768 | 865 | if (parent->type == NODE_ROOT) { |
3122e6f0 | 866 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.trace); |
3e11b713 | 867 | } else { |
02b234c4 | 868 | return -EPERM; |
3e11b713 | 869 | } |
02b234c4 | 870 | break; |
73d15916 MD |
871 | case NODE_CLOCK: |
872 | if (parent->type == NODE_ROOT) { | |
3122e6f0 | 873 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.clock); |
73d15916 MD |
874 | } else { |
875 | return -EPERM; | |
876 | } | |
877 | break; | |
f133896d MD |
878 | case NODE_CALLSITE: |
879 | if (parent->type == NODE_ROOT) { | |
880 | _bt_list_splice_tail(&node->tmp_head, &parent->u.root.callsite); | |
881 | } else { | |
882 | return -EPERM; | |
883 | } | |
884 | break; | |
02b234c4 MD |
885 | |
886 | case NODE_CTF_EXPRESSION: | |
887 | return reparent_ctf_expression(node, parent); | |
6dc474b8 MD |
888 | case NODE_UNARY_EXPRESSION: |
889 | if (parent->type == NODE_TYPE_DECLARATOR) | |
890 | parent->u.type_declarator.bitfield_len = node; | |
891 | else | |
892 | return -EPERM; | |
893 | break; | |
02b234c4 MD |
894 | |
895 | case NODE_TYPEDEF: | |
896 | return reparent_typedef(node, parent); | |
897 | case NODE_TYPEALIAS_TARGET: | |
898 | if (parent->type == NODE_TYPEALIAS) | |
899 | parent->u.typealias.target = node; | |
900 | else | |
901 | return -EINVAL; | |
902 | case NODE_TYPEALIAS_ALIAS: | |
903 | if (parent->type == NODE_TYPEALIAS) | |
904 | parent->u.typealias.alias = node; | |
905 | else | |
906 | return -EINVAL; | |
907 | case NODE_TYPEALIAS: | |
908 | return reparent_typealias(node, parent); | |
909 | ||
02b234c4 | 910 | case NODE_POINTER: |
48a01768 | 911 | if (parent->type == NODE_TYPE_DECLARATOR) { |
3122e6f0 | 912 | _bt_list_splice_tail(&node->tmp_head, &parent->u.type_declarator.pointers); |
48a01768 | 913 | } else |
02b234c4 MD |
914 | return -EPERM; |
915 | break; | |
916 | case NODE_TYPE_DECLARATOR: | |
917 | return reparent_type_declarator(node, parent); | |
918 | ||
3e11b713 MD |
919 | case NODE_TYPE_SPECIFIER_LIST: |
920 | return reparent_type_specifier_list(node, parent); | |
921 | ||
6dc474b8 | 922 | case NODE_TYPE_SPECIFIER: |
3e11b713 MD |
923 | return reparent_type_specifier(node, parent); |
924 | ||
02b234c4 | 925 | case NODE_FLOATING_POINT: |
02b234c4 | 926 | case NODE_INTEGER: |
02b234c4 | 927 | case NODE_STRING: |
6dc474b8 MD |
928 | case NODE_ENUM: |
929 | case NODE_VARIANT: | |
930 | case NODE_STRUCT: | |
3e11b713 | 931 | return -EINVAL; /* Dealt with internally within grammar */ |
6dc474b8 | 932 | |
02b234c4 | 933 | case NODE_ENUMERATOR: |
48a01768 | 934 | if (parent->type == NODE_ENUM) { |
3122e6f0 | 935 | _bt_list_splice_tail(&node->tmp_head, &parent->u._enum.enumerator_list); |
3e11b713 | 936 | } else { |
02b234c4 | 937 | return -EPERM; |
3e11b713 | 938 | } |
02b234c4 | 939 | break; |
02b234c4 MD |
940 | case NODE_STRUCT_OR_VARIANT_DECLARATION: |
941 | switch (parent->type) { | |
942 | case NODE_STRUCT: | |
3122e6f0 | 943 | _bt_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list); |
02b234c4 MD |
944 | break; |
945 | case NODE_VARIANT: | |
3122e6f0 | 946 | _bt_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list); |
02b234c4 MD |
947 | break; |
948 | default: | |
949 | return -EINVAL; | |
950 | } | |
951 | break; | |
02b234c4 MD |
952 | |
953 | case NODE_UNKNOWN: | |
954 | default: | |
c55adfb9 | 955 | printfn_fatal(node, "unknown node type '%d'", (int) parent->type); |
02b234c4 MD |
956 | return -EINVAL; |
957 | } | |
958 | return 0; | |
959 | } | |
960 | ||
5d6c80a5 | 961 | BT_HIDDEN |
34d3acc4 | 962 | void yyerror(struct ctf_scanner *scanner, const char *str) |
8b9d5b5e | 963 | { |
c55adfb9 EB |
964 | printfl_error(yyget_lineno(scanner->scanner), |
965 | "token \"%s\": %s\n", | |
740aad26 | 966 | yyget_text(scanner->scanner), str); |
8b9d5b5e MD |
967 | } |
968 | ||
5d6c80a5 | 969 | BT_HIDDEN |
8b9d5b5e MD |
970 | int yywrap(void) |
971 | { | |
972 | return 1; | |
973 | } | |
974 | ||
6dc474b8 MD |
975 | #define reparent_error(scanner, str) \ |
976 | do { \ | |
c55adfb9 | 977 | yyerror(scanner, YY_("reparent_error: " str)); \ |
6dc474b8 MD |
978 | YYERROR; \ |
979 | } while (0) | |
980 | ||
3122e6f0 | 981 | static void free_strings(struct bt_list_head *list) |
8b9d5b5e MD |
982 | { |
983 | struct gc_string *gstr, *tmp; | |
984 | ||
3122e6f0 | 985 | bt_list_for_each_entry_safe(gstr, tmp, list, gc) |
8b9d5b5e MD |
986 | free(gstr); |
987 | } | |
988 | ||
34d3acc4 | 989 | static struct ctf_ast *ctf_ast_alloc(void) |
8b9d5b5e | 990 | { |
34d3acc4 MD |
991 | struct ctf_ast *ast; |
992 | ||
993 | ast = malloc(sizeof(*ast)); | |
994 | if (!ast) | |
995 | return NULL; | |
996 | memset(ast, 0, sizeof(*ast)); | |
3122e6f0 | 997 | BT_INIT_LIST_HEAD(&ast->allocated_nodes); |
02b234c4 | 998 | ast->root.type = NODE_ROOT; |
3122e6f0 JD |
999 | BT_INIT_LIST_HEAD(&ast->root.tmp_head); |
1000 | BT_INIT_LIST_HEAD(&ast->root.u.root.declaration_list); | |
1001 | BT_INIT_LIST_HEAD(&ast->root.u.root.trace); | |
1002 | BT_INIT_LIST_HEAD(&ast->root.u.root.env); | |
1003 | BT_INIT_LIST_HEAD(&ast->root.u.root.stream); | |
1004 | BT_INIT_LIST_HEAD(&ast->root.u.root.event); | |
1005 | BT_INIT_LIST_HEAD(&ast->root.u.root.clock); | |
f133896d | 1006 | BT_INIT_LIST_HEAD(&ast->root.u.root.callsite); |
34d3acc4 MD |
1007 | return ast; |
1008 | } | |
1009 | ||
1010 | static void ctf_ast_free(struct ctf_ast *ast) | |
1011 | { | |
02b234c4 MD |
1012 | struct ctf_node *node, *tmp; |
1013 | ||
3122e6f0 | 1014 | bt_list_for_each_entry_safe(node, tmp, &ast->allocated_nodes, gc) |
02b234c4 | 1015 | free(node); |
15d4fe3c | 1016 | free(ast); |
34d3acc4 MD |
1017 | } |
1018 | ||
1019 | int ctf_scanner_append_ast(struct ctf_scanner *scanner) | |
1020 | { | |
1021 | return yyparse(scanner); | |
1022 | } | |
1023 | ||
1024 | struct ctf_scanner *ctf_scanner_alloc(FILE *input) | |
1025 | { | |
1026 | struct ctf_scanner *scanner; | |
1027 | int ret; | |
1028 | ||
a3983482 MD |
1029 | yydebug = babeltrace_debug; |
1030 | ||
34d3acc4 MD |
1031 | scanner = malloc(sizeof(*scanner)); |
1032 | if (!scanner) | |
1033 | return NULL; | |
1034 | memset(scanner, 0, sizeof(*scanner)); | |
1035 | ||
1036 | ret = yylex_init_extra(scanner, &scanner->scanner); | |
1037 | if (ret) { | |
c55adfb9 | 1038 | printf_fatal("yylex_init error"); |
34d3acc4 MD |
1039 | goto cleanup_scanner; |
1040 | } | |
65102a8c MD |
1041 | /* Start processing new stream */ |
1042 | yyrestart(input, scanner->scanner); | |
34d3acc4 MD |
1043 | |
1044 | scanner->ast = ctf_ast_alloc(); | |
1045 | if (!scanner->ast) | |
1046 | goto cleanup_lexer; | |
1047 | init_scope(&scanner->root_scope, NULL); | |
19d96da7 | 1048 | scanner->cs = &scanner->root_scope; |
3122e6f0 | 1049 | BT_INIT_LIST_HEAD(&scanner->allocated_strings); |
34d3acc4 | 1050 | |
65102a8c MD |
1051 | if (yydebug) |
1052 | fprintf(stdout, "Scanner input is a%s.\n", | |
1053 | isatty(fileno(input)) ? "n interactive tty" : | |
1054 | " noninteractive file"); | |
1055 | ||
34d3acc4 MD |
1056 | return scanner; |
1057 | ||
1058 | cleanup_lexer: | |
1059 | ret = yylex_destroy(scanner->scanner); | |
1060 | if (!ret) | |
c55adfb9 | 1061 | printf_fatal("yylex_destroy error"); |
34d3acc4 MD |
1062 | cleanup_scanner: |
1063 | free(scanner); | |
1064 | return NULL; | |
1065 | } | |
1066 | ||
1067 | void ctf_scanner_free(struct ctf_scanner *scanner) | |
1068 | { | |
1069 | int ret; | |
1070 | ||
1071 | finalize_scope(&scanner->root_scope); | |
1072 | free_strings(&scanner->allocated_strings); | |
1073 | ctf_ast_free(scanner->ast); | |
1074 | ret = yylex_destroy(scanner->scanner); | |
1075 | if (ret) | |
c55adfb9 | 1076 | printf_error("yylex_destroy error"); |
34d3acc4 MD |
1077 | free(scanner); |
1078 | } | |
8b9d5b5e MD |
1079 | |
1080 | %} | |
1081 | ||
34d3acc4 MD |
1082 | %define api.pure |
1083 | /* %locations */ | |
8c834e5a | 1084 | %error-verbose |
34d3acc4 MD |
1085 | %parse-param {struct ctf_scanner *scanner} |
1086 | %lex-param {struct ctf_scanner *scanner} | |
0fbb34a5 MD |
1087 | /* |
1088 | * Expect two shift-reduce conflicts. Caused by enum name-opt : type {} | |
1089 | * vs struct { int :value; } (unnamed bit-field). The default is to | |
1090 | * shift, so whenever we encounter an enumeration, we are doing the | |
1091 | * proper thing (shift). It is illegal to declare an enumeration | |
1092 | * "bit-field", so it is OK if this situation ends up in a parsing | |
1093 | * error. | |
1094 | */ | |
1095 | %expect 2 | |
8b9d5b5e | 1096 | %start file |
80b07bd7 | 1097 | %token INTEGER_LITERAL STRING_LITERAL CHARACTER_LITERAL LSBRAC RSBRAC LPAREN RPAREN LBRAC RBRAC RARROW STAR PLUS MINUS LT GT TYPEASSIGN COLON SEMICOLON DOTDOTDOT DOT EQUAL COMMA CONST CHAR DOUBLE ENUM ENV EVENT FLOATING_POINT FLOAT INTEGER INT LONG SHORT SIGNED STREAM STRING STRUCT TRACE CALLSITE CLOCK TYPEALIAS TYPEDEF UNSIGNED VARIANT VOID _BOOL _COMPLEX _IMAGINARY TOK_ALIGN |
8b9d5b5e MD |
1098 | %token <gs> IDENTIFIER ID_TYPE |
1099 | %token ERROR | |
1100 | %union | |
1101 | { | |
1102 | long long ll; | |
80b07bd7 | 1103 | unsigned long long ull; |
8b9d5b5e MD |
1104 | char c; |
1105 | struct gc_string *gs; | |
1106 | struct ctf_node *n; | |
1107 | } | |
1108 | ||
d876a5ba EB |
1109 | %type <gs> STRING_LITERAL CHARACTER_LITERAL |
1110 | ||
6dc474b8 | 1111 | %type <gs> keywords |
6dc474b8 | 1112 | |
80b07bd7 | 1113 | %type <ull> INTEGER_LITERAL |
6dc474b8 MD |
1114 | %type <n> postfix_expression unary_expression unary_expression_or_range |
1115 | ||
1116 | %type <n> declaration | |
02b234c4 | 1117 | %type <n> event_declaration |
6dc474b8 | 1118 | %type <n> stream_declaration |
e2c76a4d | 1119 | %type <n> env_declaration |
6dc474b8 | 1120 | %type <n> trace_declaration |
73d15916 | 1121 | %type <n> clock_declaration |
f133896d | 1122 | %type <n> callsite_declaration |
0fbb34a5 | 1123 | %type <n> integer_declaration_specifiers |
6dc474b8 | 1124 | %type <n> declaration_specifiers |
1ee8e81d | 1125 | %type <n> alias_declaration_specifiers |
6dc474b8 MD |
1126 | |
1127 | %type <n> type_declarator_list | |
0fbb34a5 | 1128 | %type <n> integer_type_specifier |
6dc474b8 MD |
1129 | %type <n> type_specifier |
1130 | %type <n> struct_type_specifier | |
1131 | %type <n> variant_type_specifier | |
6dc474b8 MD |
1132 | %type <n> enum_type_specifier |
1133 | %type <n> struct_or_variant_declaration_list | |
1134 | %type <n> struct_or_variant_declaration | |
6dc474b8 MD |
1135 | %type <n> struct_or_variant_declarator_list |
1136 | %type <n> struct_or_variant_declarator | |
1137 | %type <n> enumerator_list | |
1138 | %type <n> enumerator | |
1139 | %type <n> abstract_declarator_list | |
1140 | %type <n> abstract_declarator | |
1141 | %type <n> direct_abstract_declarator | |
e0c14875 MD |
1142 | %type <n> alias_abstract_declarator_list |
1143 | %type <n> alias_abstract_declarator | |
1144 | %type <n> direct_alias_abstract_declarator | |
6dc474b8 MD |
1145 | %type <n> declarator |
1146 | %type <n> direct_declarator | |
1147 | %type <n> type_declarator | |
1148 | %type <n> direct_type_declarator | |
6dc474b8 | 1149 | %type <n> pointer |
02b234c4 MD |
1150 | %type <n> ctf_assignment_expression_list |
1151 | %type <n> ctf_assignment_expression | |
1152 | ||
8b9d5b5e MD |
1153 | %% |
1154 | ||
1155 | file: | |
1156 | declaration | |
6dc474b8 | 1157 | { |
48a01768 | 1158 | if (set_parent_node($1, &ctf_scanner_get_ast(scanner)->root)) |
6dc474b8 MD |
1159 | reparent_error(scanner, "error reparenting to root"); |
1160 | } | |
8b9d5b5e | 1161 | | file declaration |
6dc474b8 | 1162 | { |
48a01768 | 1163 | if (set_parent_node($2, &ctf_scanner_get_ast(scanner)->root)) |
6dc474b8 MD |
1164 | reparent_error(scanner, "error reparenting to root"); |
1165 | } | |
8b9d5b5e MD |
1166 | ; |
1167 | ||
1168 | keywords: | |
1169 | VOID | |
6dc474b8 | 1170 | { $$ = yylval.gs; } |
8b9d5b5e | 1171 | | CHAR |
6dc474b8 | 1172 | { $$ = yylval.gs; } |
8b9d5b5e | 1173 | | SHORT |
6dc474b8 | 1174 | { $$ = yylval.gs; } |
8b9d5b5e | 1175 | | INT |
6dc474b8 | 1176 | { $$ = yylval.gs; } |
8b9d5b5e | 1177 | | LONG |
6dc474b8 | 1178 | { $$ = yylval.gs; } |
8b9d5b5e | 1179 | | FLOAT |
6dc474b8 | 1180 | { $$ = yylval.gs; } |
8b9d5b5e | 1181 | | DOUBLE |
6dc474b8 | 1182 | { $$ = yylval.gs; } |
8b9d5b5e | 1183 | | SIGNED |
6dc474b8 | 1184 | { $$ = yylval.gs; } |
8b9d5b5e | 1185 | | UNSIGNED |
6dc474b8 | 1186 | { $$ = yylval.gs; } |
8b9d5b5e | 1187 | | _BOOL |
6dc474b8 | 1188 | { $$ = yylval.gs; } |
8b9d5b5e | 1189 | | _COMPLEX |
6dc474b8 | 1190 | { $$ = yylval.gs; } |
3888a159 MD |
1191 | | _IMAGINARY |
1192 | { $$ = yylval.gs; } | |
8b9d5b5e | 1193 | | FLOATING_POINT |
6dc474b8 | 1194 | { $$ = yylval.gs; } |
8b9d5b5e | 1195 | | INTEGER |
6dc474b8 | 1196 | { $$ = yylval.gs; } |
8b9d5b5e | 1197 | | STRING |
6dc474b8 | 1198 | { $$ = yylval.gs; } |
8b9d5b5e | 1199 | | ENUM |
6dc474b8 | 1200 | { $$ = yylval.gs; } |
8b9d5b5e | 1201 | | VARIANT |
6dc474b8 | 1202 | { $$ = yylval.gs; } |
8b9d5b5e | 1203 | | STRUCT |
6dc474b8 | 1204 | { $$ = yylval.gs; } |
8b9d5b5e | 1205 | | CONST |
6dc474b8 | 1206 | { $$ = yylval.gs; } |
8b9d5b5e | 1207 | | TYPEDEF |
6dc474b8 | 1208 | { $$ = yylval.gs; } |
8b9d5b5e | 1209 | | EVENT |
6dc474b8 | 1210 | { $$ = yylval.gs; } |
8b9d5b5e | 1211 | | STREAM |
6dc474b8 | 1212 | { $$ = yylval.gs; } |
d2ea163b MD |
1213 | | ENV |
1214 | { $$ = yylval.gs; } | |
8b9d5b5e | 1215 | | TRACE |
6dc474b8 | 1216 | { $$ = yylval.gs; } |
73d15916 MD |
1217 | | CLOCK |
1218 | { $$ = yylval.gs; } | |
f133896d MD |
1219 | | CALLSITE |
1220 | { $$ = yylval.gs; } | |
b7e35bad MD |
1221 | | TOK_ALIGN |
1222 | { $$ = yylval.gs; } | |
8b9d5b5e MD |
1223 | ; |
1224 | ||
8b9d5b5e MD |
1225 | |
1226 | /* 2: Phrase structure grammar */ | |
1227 | ||
1228 | postfix_expression: | |
1229 | IDENTIFIER | |
6dc474b8 MD |
1230 | { |
1231 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1232 | $$->u.unary_expression.type = UNARY_STRING; | |
1233 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1234 | } | |
8b9d5b5e | 1235 | | ID_TYPE |
6dc474b8 MD |
1236 | { |
1237 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1238 | $$->u.unary_expression.type = UNARY_STRING; | |
1239 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1240 | } | |
8b9d5b5e | 1241 | | keywords |
6dc474b8 MD |
1242 | { |
1243 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1244 | $$->u.unary_expression.type = UNARY_STRING; | |
1245 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1246 | } | |
80b07bd7 | 1247 | | INTEGER_LITERAL |
6dc474b8 MD |
1248 | { |
1249 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1250 | $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; | |
80b07bd7 | 1251 | $$->u.unary_expression.u.unsigned_constant = $1; |
6dc474b8 | 1252 | } |
d876a5ba | 1253 | | STRING_LITERAL |
6dc474b8 MD |
1254 | { |
1255 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1256 | $$->u.unary_expression.type = UNARY_STRING; | |
d876a5ba | 1257 | $$->u.unary_expression.u.string = $1->s; |
6dc474b8 | 1258 | } |
d876a5ba | 1259 | | CHARACTER_LITERAL |
6dc474b8 MD |
1260 | { |
1261 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1262 | $$->u.unary_expression.type = UNARY_STRING; | |
d876a5ba | 1263 | $$->u.unary_expression.u.string = $1->s; |
6dc474b8 | 1264 | } |
8b9d5b5e | 1265 | | LPAREN unary_expression RPAREN |
6dc474b8 | 1266 | { |
104147cd | 1267 | $$ = $2; |
6dc474b8 | 1268 | } |
8b9d5b5e | 1269 | | postfix_expression LSBRAC unary_expression RSBRAC |
6dc474b8 MD |
1270 | { |
1271 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1272 | $$->u.unary_expression.type = UNARY_SBRAC; | |
1273 | $$->u.unary_expression.u.sbrac_exp = $3; | |
3122e6f0 JD |
1274 | bt_list_splice(&($1)->tmp_head, &($$)->tmp_head); |
1275 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); | |
6dc474b8 | 1276 | } |
8b9d5b5e | 1277 | | postfix_expression DOT IDENTIFIER |
6dc474b8 MD |
1278 | { |
1279 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1280 | $$->u.unary_expression.type = UNARY_STRING; | |
1281 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1282 | $$->u.unary_expression.link = UNARY_DOTLINK; | |
3122e6f0 JD |
1283 | bt_list_splice(&($1)->tmp_head, &($$)->tmp_head); |
1284 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); | |
6dc474b8 | 1285 | } |
8b9d5b5e | 1286 | | postfix_expression DOT ID_TYPE |
6dc474b8 MD |
1287 | { |
1288 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1289 | $$->u.unary_expression.type = UNARY_STRING; | |
1290 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1291 | $$->u.unary_expression.link = UNARY_DOTLINK; | |
3122e6f0 JD |
1292 | bt_list_splice(&($1)->tmp_head, &($$)->tmp_head); |
1293 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); | |
6dc474b8 | 1294 | } |
8b9d5b5e | 1295 | | postfix_expression RARROW IDENTIFIER |
6dc474b8 MD |
1296 | { |
1297 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1298 | $$->u.unary_expression.type = UNARY_STRING; | |
1299 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1300 | $$->u.unary_expression.link = UNARY_ARROWLINK; | |
3122e6f0 JD |
1301 | bt_list_splice(&($1)->tmp_head, &($$)->tmp_head); |
1302 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); | |
6dc474b8 | 1303 | } |
8b9d5b5e | 1304 | | postfix_expression RARROW ID_TYPE |
6dc474b8 MD |
1305 | { |
1306 | $$ = make_node(scanner, NODE_UNARY_EXPRESSION); | |
1307 | $$->u.unary_expression.type = UNARY_STRING; | |
1308 | $$->u.unary_expression.u.string = yylval.gs->s; | |
1309 | $$->u.unary_expression.link = UNARY_ARROWLINK; | |
3122e6f0 JD |
1310 | bt_list_splice(&($1)->tmp_head, &($$)->tmp_head); |
1311 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); | |
6dc474b8 | 1312 | } |
8b9d5b5e MD |
1313 | ; |
1314 | ||
1315 | unary_expression: | |
1316 | postfix_expression | |
6dc474b8 | 1317 | { $$ = $1; } |
8b9d5b5e | 1318 | | PLUS postfix_expression |
f9c67088 EB |
1319 | { |
1320 | $$ = $2; | |
1321 | if ($$->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT | |
1322 | && $$->u.unary_expression.type != UNARY_SIGNED_CONSTANT) { | |
1323 | reparent_error(scanner, "expecting numeric constant"); | |
1324 | } | |
1325 | } | |
8b9d5b5e | 1326 | | MINUS postfix_expression |
6dc474b8 MD |
1327 | { |
1328 | $$ = $2; | |
6dc474b8 MD |
1329 | if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) { |
1330 | $$->u.unary_expression.type = UNARY_SIGNED_CONSTANT; | |
1331 | $$->u.unary_expression.u.signed_constant = | |
1332 | -($$->u.unary_expression.u.unsigned_constant); | |
ca3de390 | 1333 | } else if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) { |
6dc474b8 MD |
1334 | $$->u.unary_expression.u.signed_constant = |
1335 | -($$->u.unary_expression.u.signed_constant); | |
ca3de390 EB |
1336 | } else { |
1337 | reparent_error(scanner, "expecting numeric constant"); | |
6dc474b8 MD |
1338 | } |
1339 | } | |
8b9d5b5e MD |
1340 | ; |
1341 | ||
1342 | unary_expression_or_range: | |
1343 | unary_expression DOTDOTDOT unary_expression | |
6dc474b8 MD |
1344 | { |
1345 | $$ = $1; | |
3122e6f0 | 1346 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->tmp_head); |
48a01768 | 1347 | $3->u.unary_expression.link = UNARY_DOTDOTDOT; |
6dc474b8 | 1348 | } |
8b9d5b5e | 1349 | | unary_expression |
6dc474b8 | 1350 | { $$ = $1; } |
8b9d5b5e MD |
1351 | ; |
1352 | ||
1353 | /* 2.2: Declarations */ | |
1354 | ||
1355 | declaration: | |
1356 | declaration_specifiers SEMICOLON | |
6dc474b8 | 1357 | { $$ = $1; } |
8b9d5b5e | 1358 | | event_declaration |
6dc474b8 | 1359 | { $$ = $1; } |
8b9d5b5e | 1360 | | stream_declaration |
6dc474b8 | 1361 | { $$ = $1; } |
e2c76a4d MD |
1362 | | env_declaration |
1363 | { $$ = $1; } | |
8b9d5b5e | 1364 | | trace_declaration |
6dc474b8 | 1365 | { $$ = $1; } |
73d15916 MD |
1366 | | clock_declaration |
1367 | { $$ = $1; } | |
f133896d MD |
1368 | | callsite_declaration |
1369 | { $$ = $1; } | |
8b9d5b5e | 1370 | | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON |
6dc474b8 | 1371 | { |
3e11b713 MD |
1372 | struct ctf_node *list; |
1373 | ||
6dc474b8 | 1374 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
1375 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
1376 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
1377 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
1378 | _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head); | |
1379 | _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 1380 | } |
8b9d5b5e | 1381 | | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON |
6dc474b8 | 1382 | { |
3e11b713 MD |
1383 | struct ctf_node *list; |
1384 | ||
6dc474b8 | 1385 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
1386 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
1387 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
1388 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
1389 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 1390 | } |
8b9d5b5e | 1391 | | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON |
6dc474b8 | 1392 | { |
3e11b713 MD |
1393 | struct ctf_node *list; |
1394 | ||
6dc474b8 | 1395 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
1396 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
1397 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
1398 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
1399 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 1400 | } |
a030d084 | 1401 | | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON |
6dc474b8 | 1402 | { |
3e11b713 MD |
1403 | struct ctf_node *list; |
1404 | ||
6dc474b8 MD |
1405 | $$ = make_node(scanner, NODE_TYPEALIAS); |
1406 | $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET); | |
1407 | $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS); | |
3e11b713 MD |
1408 | |
1409 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1410 | $$->u.typealias.target->u.typealias_target.type_specifier_list = list; | |
3122e6f0 JD |
1411 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
1412 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators); | |
3e11b713 MD |
1413 | |
1414 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1415 | $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list; | |
3122e6f0 JD |
1416 | _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
1417 | _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators); | |
6dc474b8 | 1418 | } |
8b9d5b5e MD |
1419 | ; |
1420 | ||
1421 | event_declaration: | |
1422 | event_declaration_begin event_declaration_end | |
48a01768 MD |
1423 | { |
1424 | $$ = make_node(scanner, NODE_EVENT); | |
48a01768 | 1425 | } |
8b9d5b5e | 1426 | | event_declaration_begin ctf_assignment_expression_list event_declaration_end |
02b234c4 MD |
1427 | { |
1428 | $$ = make_node(scanner, NODE_EVENT); | |
48a01768 | 1429 | if (set_parent_node($2, $$)) |
6dc474b8 | 1430 | reparent_error(scanner, "event_declaration"); |
02b234c4 | 1431 | } |
8b9d5b5e MD |
1432 | ; |
1433 | ||
1434 | event_declaration_begin: | |
1435 | EVENT LBRAC | |
fce8006d | 1436 | { push_scope(scanner); } |
8b9d5b5e MD |
1437 | ; |
1438 | ||
1439 | event_declaration_end: | |
1440 | RBRAC SEMICOLON | |
fce8006d | 1441 | { pop_scope(scanner); } |
8b9d5b5e MD |
1442 | ; |
1443 | ||
1444 | ||
1445 | stream_declaration: | |
1446 | stream_declaration_begin stream_declaration_end | |
48a01768 MD |
1447 | { |
1448 | $$ = make_node(scanner, NODE_STREAM); | |
48a01768 | 1449 | } |
8b9d5b5e | 1450 | | stream_declaration_begin ctf_assignment_expression_list stream_declaration_end |
6dc474b8 MD |
1451 | { |
1452 | $$ = make_node(scanner, NODE_STREAM); | |
48a01768 | 1453 | if (set_parent_node($2, $$)) |
6dc474b8 MD |
1454 | reparent_error(scanner, "stream_declaration"); |
1455 | } | |
8b9d5b5e MD |
1456 | ; |
1457 | ||
1458 | stream_declaration_begin: | |
1459 | STREAM LBRAC | |
fce8006d | 1460 | { push_scope(scanner); } |
8b9d5b5e MD |
1461 | ; |
1462 | ||
1463 | stream_declaration_end: | |
1464 | RBRAC SEMICOLON | |
fce8006d | 1465 | { pop_scope(scanner); } |
8b9d5b5e MD |
1466 | ; |
1467 | ||
e2c76a4d MD |
1468 | env_declaration: |
1469 | env_declaration_begin env_declaration_end | |
1470 | { | |
1471 | $$ = make_node(scanner, NODE_ENV); | |
1472 | } | |
1473 | | env_declaration_begin ctf_assignment_expression_list env_declaration_end | |
1474 | { | |
1475 | $$ = make_node(scanner, NODE_ENV); | |
1476 | if (set_parent_node($2, $$)) | |
1477 | reparent_error(scanner, "env declaration"); | |
1478 | } | |
1479 | ; | |
1480 | ||
1481 | env_declaration_begin: | |
1482 | ENV LBRAC | |
1483 | { push_scope(scanner); } | |
1484 | ; | |
1485 | ||
1486 | env_declaration_end: | |
1487 | RBRAC SEMICOLON | |
1488 | { pop_scope(scanner); } | |
1489 | ; | |
1490 | ||
8b9d5b5e MD |
1491 | trace_declaration: |
1492 | trace_declaration_begin trace_declaration_end | |
48a01768 MD |
1493 | { |
1494 | $$ = make_node(scanner, NODE_TRACE); | |
48a01768 | 1495 | } |
8b9d5b5e | 1496 | | trace_declaration_begin ctf_assignment_expression_list trace_declaration_end |
6dc474b8 MD |
1497 | { |
1498 | $$ = make_node(scanner, NODE_TRACE); | |
48a01768 | 1499 | if (set_parent_node($2, $$)) |
6dc474b8 MD |
1500 | reparent_error(scanner, "trace_declaration"); |
1501 | } | |
8b9d5b5e MD |
1502 | ; |
1503 | ||
1504 | trace_declaration_begin: | |
1505 | TRACE LBRAC | |
fce8006d | 1506 | { push_scope(scanner); } |
8b9d5b5e MD |
1507 | ; |
1508 | ||
1509 | trace_declaration_end: | |
1510 | RBRAC SEMICOLON | |
fce8006d | 1511 | { pop_scope(scanner); } |
8b9d5b5e MD |
1512 | ; |
1513 | ||
73d15916 MD |
1514 | clock_declaration: |
1515 | CLOCK clock_declaration_begin clock_declaration_end | |
1516 | { | |
1517 | $$ = make_node(scanner, NODE_CLOCK); | |
1518 | } | |
1519 | | CLOCK clock_declaration_begin ctf_assignment_expression_list clock_declaration_end | |
1520 | { | |
1521 | $$ = make_node(scanner, NODE_CLOCK); | |
1522 | if (set_parent_node($3, $$)) | |
1523 | reparent_error(scanner, "trace_declaration"); | |
1524 | } | |
1525 | ; | |
1526 | ||
1527 | clock_declaration_begin: | |
1528 | LBRAC | |
1529 | { push_scope(scanner); } | |
1530 | ; | |
1531 | ||
1532 | clock_declaration_end: | |
1533 | RBRAC SEMICOLON | |
1534 | { pop_scope(scanner); } | |
1535 | ; | |
1536 | ||
f133896d MD |
1537 | callsite_declaration: |
1538 | CALLSITE callsite_declaration_begin callsite_declaration_end | |
1539 | { | |
1540 | $$ = make_node(scanner, NODE_CALLSITE); | |
1541 | } | |
1542 | | CALLSITE callsite_declaration_begin ctf_assignment_expression_list callsite_declaration_end | |
1543 | { | |
1544 | $$ = make_node(scanner, NODE_CALLSITE); | |
1545 | if (set_parent_node($3, $$)) | |
1546 | reparent_error(scanner, "trace_declaration"); | |
1547 | } | |
1548 | ; | |
1549 | ||
1550 | callsite_declaration_begin: | |
1551 | LBRAC | |
1552 | { push_scope(scanner); } | |
1553 | ; | |
1554 | ||
1555 | callsite_declaration_end: | |
1556 | RBRAC SEMICOLON | |
1557 | { pop_scope(scanner); } | |
1558 | ; | |
1559 | ||
0fbb34a5 MD |
1560 | integer_declaration_specifiers: |
1561 | CONST | |
1562 | { | |
1563 | struct ctf_node *node; | |
1564 | ||
1565 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1566 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1567 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 1568 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
0fbb34a5 MD |
1569 | } |
1570 | | integer_type_specifier | |
1571 | { | |
1572 | struct ctf_node *node; | |
1573 | ||
1574 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1575 | node = $1; | |
3122e6f0 | 1576 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
0fbb34a5 MD |
1577 | } |
1578 | | integer_declaration_specifiers CONST | |
1579 | { | |
1580 | struct ctf_node *node; | |
1581 | ||
1582 | $$ = $1; | |
1583 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1584 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 1585 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
0fbb34a5 MD |
1586 | } |
1587 | | integer_declaration_specifiers integer_type_specifier | |
1588 | { | |
1589 | $$ = $1; | |
3122e6f0 | 1590 | bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head); |
0fbb34a5 MD |
1591 | } |
1592 | ; | |
1593 | ||
8b9d5b5e MD |
1594 | declaration_specifiers: |
1595 | CONST | |
6dc474b8 | 1596 | { |
3e11b713 MD |
1597 | struct ctf_node *node; |
1598 | ||
1599 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1600 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1601 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 1602 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 1603 | } |
8b9d5b5e | 1604 | | type_specifier |
3e11b713 MD |
1605 | { |
1606 | struct ctf_node *node; | |
1607 | ||
1608 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
1609 | node = $1; | |
3122e6f0 | 1610 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
3e11b713 | 1611 | } |
8b9d5b5e | 1612 | | declaration_specifiers CONST |
6dc474b8 MD |
1613 | { |
1614 | struct ctf_node *node; | |
1615 | ||
48a01768 | 1616 | $$ = $1; |
6dc474b8 MD |
1617 | node = make_node(scanner, NODE_TYPE_SPECIFIER); |
1618 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 1619 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 1620 | } |
8b9d5b5e | 1621 | | declaration_specifiers type_specifier |
6dc474b8 MD |
1622 | { |
1623 | $$ = $1; | |
3122e6f0 | 1624 | bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 1625 | } |
8b9d5b5e MD |
1626 | ; |
1627 | ||
1628 | type_declarator_list: | |
1629 | type_declarator | |
0009a725 | 1630 | { $$ = $1; } |
8b9d5b5e | 1631 | | type_declarator_list COMMA type_declarator |
6dc474b8 MD |
1632 | { |
1633 | $$ = $1; | |
3122e6f0 | 1634 | bt_list_add_tail(&($3)->siblings, &($$)->tmp_head); |
6dc474b8 | 1635 | } |
8b9d5b5e MD |
1636 | ; |
1637 | ||
0fbb34a5 MD |
1638 | integer_type_specifier: |
1639 | CHAR | |
1640 | { | |
1641 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1642 | $$->u.type_specifier.type = TYPESPEC_CHAR; | |
1643 | } | |
1644 | | SHORT | |
1645 | { | |
1646 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1647 | $$->u.type_specifier.type = TYPESPEC_SHORT; | |
1648 | } | |
1649 | | INT | |
1650 | { | |
1651 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1652 | $$->u.type_specifier.type = TYPESPEC_INT; | |
1653 | } | |
1654 | | LONG | |
1655 | { | |
1656 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1657 | $$->u.type_specifier.type = TYPESPEC_LONG; | |
1658 | } | |
1659 | | SIGNED | |
1660 | { | |
1661 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1662 | $$->u.type_specifier.type = TYPESPEC_SIGNED; | |
1663 | } | |
1664 | | UNSIGNED | |
1665 | { | |
1666 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1667 | $$->u.type_specifier.type = TYPESPEC_UNSIGNED; | |
1668 | } | |
1669 | | _BOOL | |
1670 | { | |
1671 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1672 | $$->u.type_specifier.type = TYPESPEC_BOOL; | |
1673 | } | |
1674 | | ID_TYPE | |
1675 | { | |
1676 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1677 | $$->u.type_specifier.type = TYPESPEC_ID_TYPE; | |
1678 | $$->u.type_specifier.id_type = yylval.gs->s; | |
1679 | } | |
1680 | | INTEGER LBRAC RBRAC | |
1681 | { | |
1682 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1683 | $$->u.type_specifier.type = TYPESPEC_INTEGER; | |
1684 | $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER); | |
1685 | } | |
1686 | | INTEGER LBRAC ctf_assignment_expression_list RBRAC | |
1687 | { | |
1688 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1689 | $$->u.type_specifier.type = TYPESPEC_INTEGER; | |
1690 | $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER); | |
1691 | if (set_parent_node($3, $$->u.type_specifier.node)) | |
1692 | reparent_error(scanner, "integer reparent error"); | |
1693 | } | |
1694 | ; | |
1695 | ||
8b9d5b5e MD |
1696 | type_specifier: |
1697 | VOID | |
6dc474b8 MD |
1698 | { |
1699 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1700 | $$->u.type_specifier.type = TYPESPEC_VOID; | |
1701 | } | |
8b9d5b5e | 1702 | | CHAR |
6dc474b8 MD |
1703 | { |
1704 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1705 | $$->u.type_specifier.type = TYPESPEC_CHAR; | |
1706 | } | |
8b9d5b5e | 1707 | | SHORT |
6dc474b8 MD |
1708 | { |
1709 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1710 | $$->u.type_specifier.type = TYPESPEC_SHORT; | |
1711 | } | |
8b9d5b5e | 1712 | | INT |
6dc474b8 MD |
1713 | { |
1714 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1715 | $$->u.type_specifier.type = TYPESPEC_INT; | |
1716 | } | |
8b9d5b5e | 1717 | | LONG |
6dc474b8 MD |
1718 | { |
1719 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1720 | $$->u.type_specifier.type = TYPESPEC_LONG; | |
1721 | } | |
8b9d5b5e | 1722 | | FLOAT |
6dc474b8 MD |
1723 | { |
1724 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1725 | $$->u.type_specifier.type = TYPESPEC_FLOAT; | |
1726 | } | |
8b9d5b5e | 1727 | | DOUBLE |
6dc474b8 MD |
1728 | { |
1729 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1730 | $$->u.type_specifier.type = TYPESPEC_DOUBLE; | |
1731 | } | |
8b9d5b5e | 1732 | | SIGNED |
6dc474b8 MD |
1733 | { |
1734 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1735 | $$->u.type_specifier.type = TYPESPEC_SIGNED; | |
1736 | } | |
8b9d5b5e | 1737 | | UNSIGNED |
6dc474b8 MD |
1738 | { |
1739 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1740 | $$->u.type_specifier.type = TYPESPEC_UNSIGNED; | |
1741 | } | |
8b9d5b5e | 1742 | | _BOOL |
6dc474b8 MD |
1743 | { |
1744 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1745 | $$->u.type_specifier.type = TYPESPEC_BOOL; | |
1746 | } | |
8b9d5b5e | 1747 | | _COMPLEX |
6dc474b8 MD |
1748 | { |
1749 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1750 | $$->u.type_specifier.type = TYPESPEC_COMPLEX; | |
1751 | } | |
3888a159 MD |
1752 | | _IMAGINARY |
1753 | { | |
1754 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1755 | $$->u.type_specifier.type = TYPESPEC_IMAGINARY; | |
1756 | } | |
8b9d5b5e | 1757 | | ID_TYPE |
6dc474b8 MD |
1758 | { |
1759 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1760 | $$->u.type_specifier.type = TYPESPEC_ID_TYPE; | |
1761 | $$->u.type_specifier.id_type = yylval.gs->s; | |
1762 | } | |
8b9d5b5e | 1763 | | FLOATING_POINT LBRAC RBRAC |
6dc474b8 | 1764 | { |
3e11b713 MD |
1765 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1766 | $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT; | |
1767 | $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT); | |
6dc474b8 | 1768 | } |
8b9d5b5e | 1769 | | FLOATING_POINT LBRAC ctf_assignment_expression_list RBRAC |
6dc474b8 | 1770 | { |
3e11b713 MD |
1771 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1772 | $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT; | |
1773 | $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT); | |
1774 | if (set_parent_node($3, $$->u.type_specifier.node)) | |
6dc474b8 MD |
1775 | reparent_error(scanner, "floating point reparent error"); |
1776 | } | |
8b9d5b5e | 1777 | | INTEGER LBRAC RBRAC |
6dc474b8 | 1778 | { |
3e11b713 MD |
1779 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1780 | $$->u.type_specifier.type = TYPESPEC_INTEGER; | |
1781 | $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER); | |
6dc474b8 | 1782 | } |
8b9d5b5e | 1783 | | INTEGER LBRAC ctf_assignment_expression_list RBRAC |
6dc474b8 | 1784 | { |
3e11b713 MD |
1785 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1786 | $$->u.type_specifier.type = TYPESPEC_INTEGER; | |
1787 | $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER); | |
1788 | if (set_parent_node($3, $$->u.type_specifier.node)) | |
6dc474b8 MD |
1789 | reparent_error(scanner, "integer reparent error"); |
1790 | } | |
b40c8090 MD |
1791 | | STRING |
1792 | { | |
1793 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1794 | $$->u.type_specifier.type = TYPESPEC_STRING; | |
1795 | $$->u.type_specifier.node = make_node(scanner, NODE_STRING); | |
1796 | } | |
8b9d5b5e | 1797 | | STRING LBRAC RBRAC |
6dc474b8 | 1798 | { |
3e11b713 MD |
1799 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1800 | $$->u.type_specifier.type = TYPESPEC_STRING; | |
1801 | $$->u.type_specifier.node = make_node(scanner, NODE_STRING); | |
6dc474b8 | 1802 | } |
8b9d5b5e | 1803 | | STRING LBRAC ctf_assignment_expression_list RBRAC |
6dc474b8 | 1804 | { |
3e11b713 MD |
1805 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); |
1806 | $$->u.type_specifier.type = TYPESPEC_STRING; | |
1807 | $$->u.type_specifier.node = make_node(scanner, NODE_STRING); | |
1808 | if (set_parent_node($3, $$->u.type_specifier.node)) | |
6dc474b8 MD |
1809 | reparent_error(scanner, "string reparent error"); |
1810 | } | |
8b9d5b5e | 1811 | | ENUM enum_type_specifier |
3e11b713 MD |
1812 | { |
1813 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1814 | $$->u.type_specifier.type = TYPESPEC_ENUM; | |
1815 | $$->u.type_specifier.node = $2; | |
1816 | } | |
8b9d5b5e | 1817 | | VARIANT variant_type_specifier |
3e11b713 MD |
1818 | { |
1819 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1820 | $$->u.type_specifier.type = TYPESPEC_VARIANT; | |
1821 | $$->u.type_specifier.node = $2; | |
3e11b713 | 1822 | } |
8b9d5b5e | 1823 | | STRUCT struct_type_specifier |
3e11b713 MD |
1824 | { |
1825 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER); | |
1826 | $$->u.type_specifier.type = TYPESPEC_STRUCT; | |
1827 | $$->u.type_specifier.node = $2; | |
3e11b713 | 1828 | } |
8b9d5b5e MD |
1829 | ; |
1830 | ||
1831 | struct_type_specifier: | |
1832 | struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end | |
6dc474b8 MD |
1833 | { |
1834 | $$ = make_node(scanner, NODE_STRUCT); | |
1ee8e81d | 1835 | $$->u._struct.has_body = 1; |
5039b4cc | 1836 | if ($2 && set_parent_node($2, $$)) |
6dc474b8 MD |
1837 | reparent_error(scanner, "struct reparent error"); |
1838 | } | |
8b9d5b5e | 1839 | | IDENTIFIER struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end |
6dc474b8 MD |
1840 | { |
1841 | $$ = make_node(scanner, NODE_STRUCT); | |
1ee8e81d | 1842 | $$->u._struct.has_body = 1; |
6dc474b8 | 1843 | $$->u._struct.name = $1->s; |
5039b4cc | 1844 | if ($3 && set_parent_node($3, $$)) |
6dc474b8 MD |
1845 | reparent_error(scanner, "struct reparent error"); |
1846 | } | |
8b9d5b5e | 1847 | | ID_TYPE struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end |
6dc474b8 MD |
1848 | { |
1849 | $$ = make_node(scanner, NODE_STRUCT); | |
1ee8e81d | 1850 | $$->u._struct.has_body = 1; |
6dc474b8 | 1851 | $$->u._struct.name = $1->s; |
5039b4cc | 1852 | if ($3 && set_parent_node($3, $$)) |
6dc474b8 MD |
1853 | reparent_error(scanner, "struct reparent error"); |
1854 | } | |
8b9d5b5e | 1855 | | IDENTIFIER |
6dc474b8 MD |
1856 | { |
1857 | $$ = make_node(scanner, NODE_STRUCT); | |
1ee8e81d | 1858 | $$->u._struct.has_body = 0; |
6dc474b8 MD |
1859 | $$->u._struct.name = $1->s; |
1860 | } | |
8b9d5b5e | 1861 | | ID_TYPE |
6dc474b8 MD |
1862 | { |
1863 | $$ = make_node(scanner, NODE_STRUCT); | |
1ee8e81d | 1864 | $$->u._struct.has_body = 0; |
6dc474b8 MD |
1865 | $$->u._struct.name = $1->s; |
1866 | } | |
b7e35bad MD |
1867 | | struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN |
1868 | { | |
1869 | $$ = make_node(scanner, NODE_STRUCT); | |
1870 | $$->u._struct.has_body = 1; | |
3122e6f0 | 1871 | bt_list_add_tail(&($6)->siblings, &$$->u._struct.min_align); |
b7e35bad MD |
1872 | if ($2 && set_parent_node($2, $$)) |
1873 | reparent_error(scanner, "struct reparent error"); | |
1874 | } | |
1875 | | IDENTIFIER struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN | |
1876 | { | |
1877 | $$ = make_node(scanner, NODE_STRUCT); | |
1878 | $$->u._struct.has_body = 1; | |
1879 | $$->u._struct.name = $1->s; | |
3122e6f0 | 1880 | bt_list_add_tail(&($7)->siblings, &$$->u._struct.min_align); |
b7e35bad MD |
1881 | if ($3 && set_parent_node($3, $$)) |
1882 | reparent_error(scanner, "struct reparent error"); | |
1883 | } | |
1884 | | ID_TYPE struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN | |
1885 | { | |
1886 | $$ = make_node(scanner, NODE_STRUCT); | |
1887 | $$->u._struct.has_body = 1; | |
1888 | $$->u._struct.name = $1->s; | |
3122e6f0 | 1889 | bt_list_add_tail(&($7)->siblings, &$$->u._struct.min_align); |
b7e35bad MD |
1890 | if ($3 && set_parent_node($3, $$)) |
1891 | reparent_error(scanner, "struct reparent error"); | |
1892 | } | |
8b9d5b5e MD |
1893 | ; |
1894 | ||
1895 | struct_declaration_begin: | |
1896 | LBRAC | |
fce8006d | 1897 | { push_scope(scanner); } |
8b9d5b5e MD |
1898 | ; |
1899 | ||
1900 | struct_declaration_end: | |
1901 | RBRAC | |
fce8006d | 1902 | { pop_scope(scanner); } |
8b9d5b5e MD |
1903 | ; |
1904 | ||
1905 | variant_type_specifier: | |
1906 | variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end | |
6dc474b8 MD |
1907 | { |
1908 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1909 | $$->u.variant.has_body = 1; |
5039b4cc | 1910 | if ($2 && set_parent_node($2, $$)) |
6dc474b8 MD |
1911 | reparent_error(scanner, "variant reparent error"); |
1912 | } | |
8b9d5b5e | 1913 | | LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1914 | { |
1915 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1916 | $$->u.variant.has_body = 1; |
6dc474b8 | 1917 | $$->u.variant.choice = $2->s; |
5039b4cc | 1918 | if ($5 && set_parent_node($5, $$)) |
6dc474b8 MD |
1919 | reparent_error(scanner, "variant reparent error"); |
1920 | } | |
8b9d5b5e | 1921 | | LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1922 | { |
1923 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1924 | $$->u.variant.has_body = 1; |
6dc474b8 | 1925 | $$->u.variant.choice = $2->s; |
5039b4cc | 1926 | if ($5 && set_parent_node($5, $$)) |
6dc474b8 MD |
1927 | reparent_error(scanner, "variant reparent error"); |
1928 | } | |
8b9d5b5e | 1929 | | IDENTIFIER variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1930 | { |
1931 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1932 | $$->u.variant.has_body = 1; |
6dc474b8 | 1933 | $$->u.variant.name = $1->s; |
5039b4cc | 1934 | if ($3 && set_parent_node($3, $$)) |
6dc474b8 MD |
1935 | reparent_error(scanner, "variant reparent error"); |
1936 | } | |
8b9d5b5e | 1937 | | IDENTIFIER LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1938 | { |
1939 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1940 | $$->u.variant.has_body = 1; |
6dc474b8 MD |
1941 | $$->u.variant.name = $1->s; |
1942 | $$->u.variant.choice = $3->s; | |
5039b4cc | 1943 | if ($6 && set_parent_node($6, $$)) |
6dc474b8 MD |
1944 | reparent_error(scanner, "variant reparent error"); |
1945 | } | |
8b9d5b5e | 1946 | | IDENTIFIER LT IDENTIFIER GT |
6dc474b8 MD |
1947 | { |
1948 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1949 | $$->u.variant.has_body = 0; |
6dc474b8 MD |
1950 | $$->u.variant.name = $1->s; |
1951 | $$->u.variant.choice = $3->s; | |
1952 | } | |
8b9d5b5e | 1953 | | IDENTIFIER LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1954 | { |
1955 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1956 | $$->u.variant.has_body = 1; |
6dc474b8 MD |
1957 | $$->u.variant.name = $1->s; |
1958 | $$->u.variant.choice = $3->s; | |
5039b4cc | 1959 | if ($6 && set_parent_node($6, $$)) |
6dc474b8 MD |
1960 | reparent_error(scanner, "variant reparent error"); |
1961 | } | |
8b9d5b5e | 1962 | | IDENTIFIER LT ID_TYPE GT |
6dc474b8 MD |
1963 | { |
1964 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1965 | $$->u.variant.has_body = 0; |
6dc474b8 MD |
1966 | $$->u.variant.name = $1->s; |
1967 | $$->u.variant.choice = $3->s; | |
1968 | } | |
8b9d5b5e | 1969 | | ID_TYPE variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1970 | { |
1971 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1972 | $$->u.variant.has_body = 1; |
6dc474b8 | 1973 | $$->u.variant.name = $1->s; |
5039b4cc | 1974 | if ($3 && set_parent_node($3, $$)) |
6dc474b8 MD |
1975 | reparent_error(scanner, "variant reparent error"); |
1976 | } | |
8b9d5b5e | 1977 | | ID_TYPE LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1978 | { |
1979 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1980 | $$->u.variant.has_body = 1; |
6dc474b8 MD |
1981 | $$->u.variant.name = $1->s; |
1982 | $$->u.variant.choice = $3->s; | |
5039b4cc | 1983 | if ($6 && set_parent_node($6, $$)) |
6dc474b8 MD |
1984 | reparent_error(scanner, "variant reparent error"); |
1985 | } | |
8b9d5b5e | 1986 | | ID_TYPE LT IDENTIFIER GT |
6dc474b8 MD |
1987 | { |
1988 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1989 | $$->u.variant.has_body = 0; |
6dc474b8 MD |
1990 | $$->u.variant.name = $1->s; |
1991 | $$->u.variant.choice = $3->s; | |
1992 | } | |
8b9d5b5e | 1993 | | ID_TYPE LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end |
6dc474b8 MD |
1994 | { |
1995 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 1996 | $$->u.variant.has_body = 1; |
6dc474b8 MD |
1997 | $$->u.variant.name = $1->s; |
1998 | $$->u.variant.choice = $3->s; | |
5039b4cc | 1999 | if ($6 && set_parent_node($6, $$)) |
6dc474b8 MD |
2000 | reparent_error(scanner, "variant reparent error"); |
2001 | } | |
8b9d5b5e | 2002 | | ID_TYPE LT ID_TYPE GT |
6dc474b8 MD |
2003 | { |
2004 | $$ = make_node(scanner, NODE_VARIANT); | |
1ee8e81d | 2005 | $$->u.variant.has_body = 0; |
6dc474b8 MD |
2006 | $$->u.variant.name = $1->s; |
2007 | $$->u.variant.choice = $3->s; | |
2008 | } | |
8b9d5b5e MD |
2009 | ; |
2010 | ||
2011 | variant_declaration_begin: | |
2012 | LBRAC | |
fce8006d | 2013 | { push_scope(scanner); } |
8b9d5b5e MD |
2014 | ; |
2015 | ||
2016 | variant_declaration_end: | |
2017 | RBRAC | |
fce8006d | 2018 | { pop_scope(scanner); } |
8b9d5b5e MD |
2019 | ; |
2020 | ||
8b9d5b5e MD |
2021 | enum_type_specifier: |
2022 | LBRAC enumerator_list RBRAC | |
6dc474b8 MD |
2023 | { |
2024 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2025 | $$->u._enum.has_body = 1; |
3122e6f0 | 2026 | _bt_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2027 | } |
0fbb34a5 | 2028 | | COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC |
6dc474b8 MD |
2029 | { |
2030 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2031 | $$->u._enum.has_body = 1; |
3e11b713 | 2032 | ($$)->u._enum.container_type = $2; |
3122e6f0 | 2033 | _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2034 | } |
8b9d5b5e | 2035 | | IDENTIFIER LBRAC enumerator_list RBRAC |
6dc474b8 MD |
2036 | { |
2037 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2038 | $$->u._enum.has_body = 1; |
6dc474b8 | 2039 | $$->u._enum.enum_id = $1->s; |
3122e6f0 | 2040 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2041 | } |
0fbb34a5 | 2042 | | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC |
6dc474b8 MD |
2043 | { |
2044 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2045 | $$->u._enum.has_body = 1; |
6dc474b8 | 2046 | $$->u._enum.enum_id = $1->s; |
3e11b713 | 2047 | ($$)->u._enum.container_type = $3; |
3122e6f0 | 2048 | _bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2049 | } |
8b9d5b5e | 2050 | | ID_TYPE LBRAC enumerator_list RBRAC |
6dc474b8 MD |
2051 | { |
2052 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2053 | $$->u._enum.has_body = 1; |
6dc474b8 | 2054 | $$->u._enum.enum_id = $1->s; |
3122e6f0 | 2055 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2056 | } |
0fbb34a5 | 2057 | | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC |
6dc474b8 MD |
2058 | { |
2059 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2060 | $$->u._enum.has_body = 1; |
6dc474b8 | 2061 | $$->u._enum.enum_id = $1->s; |
3e11b713 | 2062 | ($$)->u._enum.container_type = $3; |
3122e6f0 | 2063 | _bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2064 | } |
8b9d5b5e | 2065 | | LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2066 | { |
2067 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2068 | $$->u._enum.has_body = 1; |
3122e6f0 | 2069 | _bt_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2070 | } |
0fbb34a5 | 2071 | | COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2072 | { |
2073 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2074 | $$->u._enum.has_body = 1; |
3e11b713 | 2075 | ($$)->u._enum.container_type = $2; |
3122e6f0 | 2076 | _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2077 | } |
8b9d5b5e | 2078 | | IDENTIFIER LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2079 | { |
2080 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2081 | $$->u._enum.has_body = 1; |
6dc474b8 | 2082 | $$->u._enum.enum_id = $1->s; |
3122e6f0 | 2083 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2084 | } |
0fbb34a5 | 2085 | | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2086 | { |
2087 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2088 | $$->u._enum.has_body = 1; |
6dc474b8 | 2089 | $$->u._enum.enum_id = $1->s; |
3e11b713 | 2090 | ($$)->u._enum.container_type = $3; |
3122e6f0 | 2091 | _bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2092 | } |
8b9d5b5e | 2093 | | IDENTIFIER |
6dc474b8 MD |
2094 | { |
2095 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2096 | $$->u._enum.has_body = 0; |
6dc474b8 MD |
2097 | $$->u._enum.enum_id = $1->s; |
2098 | } | |
8b9d5b5e | 2099 | | ID_TYPE LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2100 | { |
2101 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2102 | $$->u._enum.has_body = 1; |
6dc474b8 | 2103 | $$->u._enum.enum_id = $1->s; |
3122e6f0 | 2104 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2105 | } |
0fbb34a5 | 2106 | | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC |
6dc474b8 MD |
2107 | { |
2108 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2109 | $$->u._enum.has_body = 1; |
6dc474b8 | 2110 | $$->u._enum.enum_id = $1->s; |
3e11b713 | 2111 | ($$)->u._enum.container_type = $3; |
3122e6f0 | 2112 | _bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list); |
6dc474b8 | 2113 | } |
8b9d5b5e | 2114 | | ID_TYPE |
6dc474b8 MD |
2115 | { |
2116 | $$ = make_node(scanner, NODE_ENUM); | |
add40b62 | 2117 | $$->u._enum.has_body = 0; |
6dc474b8 MD |
2118 | $$->u._enum.enum_id = $1->s; |
2119 | } | |
8b9d5b5e MD |
2120 | ; |
2121 | ||
2122 | struct_or_variant_declaration_list: | |
2123 | /* empty */ | |
6dc474b8 | 2124 | { $$ = NULL; } |
8b9d5b5e | 2125 | | struct_or_variant_declaration_list struct_or_variant_declaration |
6dc474b8 MD |
2126 | { |
2127 | if ($1) { | |
2128 | $$ = $1; | |
3122e6f0 | 2129 | bt_list_add_tail(&($2)->siblings, &($$)->tmp_head); |
6dc474b8 MD |
2130 | } else { |
2131 | $$ = $2; | |
3122e6f0 | 2132 | bt_list_add_tail(&($$)->siblings, &($$)->tmp_head); |
6dc474b8 MD |
2133 | } |
2134 | } | |
8b9d5b5e MD |
2135 | ; |
2136 | ||
2137 | struct_or_variant_declaration: | |
1ee8e81d | 2138 | declaration_specifiers struct_or_variant_declarator_list SEMICOLON |
6dc474b8 | 2139 | { |
3e11b713 MD |
2140 | struct ctf_node *list; |
2141 | ||
2142 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
3122e6f0 | 2143 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
6dc474b8 | 2144 | $$ = make_node(scanner, NODE_STRUCT_OR_VARIANT_DECLARATION); |
3e11b713 | 2145 | ($$)->u.struct_or_variant_declaration.type_specifier_list = list; |
3122e6f0 | 2146 | _bt_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.type_declarators); |
6dc474b8 | 2147 | } |
1ee8e81d | 2148 | | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON |
6dc474b8 | 2149 | { |
3e11b713 MD |
2150 | struct ctf_node *list; |
2151 | ||
6dc474b8 | 2152 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
2153 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
2154 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
2155 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2156 | _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head); | |
2157 | _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 2158 | } |
1ee8e81d | 2159 | | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON |
6dc474b8 | 2160 | { |
3e11b713 MD |
2161 | struct ctf_node *list; |
2162 | ||
6dc474b8 | 2163 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
2164 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
2165 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
2166 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2167 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 2168 | } |
1ee8e81d | 2169 | | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON |
6dc474b8 | 2170 | { |
3e11b713 MD |
2171 | struct ctf_node *list; |
2172 | ||
2173 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
3122e6f0 | 2174 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
6dc474b8 | 2175 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 | 2176 | ($$)->u.struct_or_variant_declaration.type_specifier_list = list; |
3122e6f0 | 2177 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); |
6dc474b8 | 2178 | } |
a030d084 | 2179 | | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON |
6dc474b8 | 2180 | { |
3e11b713 MD |
2181 | struct ctf_node *list; |
2182 | ||
6dc474b8 MD |
2183 | $$ = make_node(scanner, NODE_TYPEALIAS); |
2184 | $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET); | |
2185 | $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS); | |
3e11b713 MD |
2186 | |
2187 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2188 | $$->u.typealias.target->u.typealias_target.type_specifier_list = list; | |
3122e6f0 JD |
2189 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2190 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators); | |
3e11b713 MD |
2191 | |
2192 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2193 | $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list; | |
3122e6f0 JD |
2194 | _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2195 | _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators); | |
6dc474b8 | 2196 | } |
8b9d5b5e MD |
2197 | ; |
2198 | ||
1ee8e81d | 2199 | alias_declaration_specifiers: |
8b9d5b5e | 2200 | CONST |
6dc474b8 | 2201 | { |
3e11b713 MD |
2202 | struct ctf_node *node; |
2203 | ||
2204 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2205 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
2206 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 2207 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 2208 | } |
8b9d5b5e | 2209 | | type_specifier |
3e11b713 MD |
2210 | { |
2211 | struct ctf_node *node; | |
2212 | ||
2213 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2214 | node = $1; | |
3122e6f0 | 2215 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
3e11b713 | 2216 | } |
1ee8e81d MD |
2217 | | IDENTIFIER |
2218 | { | |
3e11b713 MD |
2219 | struct ctf_node *node; |
2220 | ||
1ee8e81d | 2221 | add_type(scanner, $1); |
3e11b713 MD |
2222 | $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
2223 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
2224 | node->u.type_specifier.type = TYPESPEC_ID_TYPE; | |
2225 | node->u.type_specifier.id_type = yylval.gs->s; | |
3122e6f0 | 2226 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
1ee8e81d MD |
2227 | } |
2228 | | alias_declaration_specifiers CONST | |
6dc474b8 MD |
2229 | { |
2230 | struct ctf_node *node; | |
2231 | ||
2232 | $$ = $1; | |
2233 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
2234 | node->u.type_specifier.type = TYPESPEC_CONST; | |
3122e6f0 | 2235 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 2236 | } |
1ee8e81d | 2237 | | alias_declaration_specifiers type_specifier |
6dc474b8 MD |
2238 | { |
2239 | $$ = $1; | |
3122e6f0 | 2240 | bt_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head); |
6dc474b8 | 2241 | } |
1ee8e81d MD |
2242 | | alias_declaration_specifiers IDENTIFIER |
2243 | { | |
2244 | struct ctf_node *node; | |
2245 | ||
2246 | add_type(scanner, $2); | |
2247 | $$ = $1; | |
2248 | node = make_node(scanner, NODE_TYPE_SPECIFIER); | |
2249 | node->u.type_specifier.type = TYPESPEC_ID_TYPE; | |
2250 | node->u.type_specifier.id_type = yylval.gs->s; | |
3122e6f0 | 2251 | bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head); |
1ee8e81d | 2252 | } |
8b9d5b5e MD |
2253 | ; |
2254 | ||
2255 | struct_or_variant_declarator_list: | |
2256 | struct_or_variant_declarator | |
0009a725 | 2257 | { $$ = $1; } |
8b9d5b5e | 2258 | | struct_or_variant_declarator_list COMMA struct_or_variant_declarator |
6dc474b8 MD |
2259 | { |
2260 | $$ = $1; | |
3122e6f0 | 2261 | bt_list_add_tail(&($3)->siblings, &($$)->tmp_head); |
6dc474b8 | 2262 | } |
8b9d5b5e MD |
2263 | ; |
2264 | ||
2265 | struct_or_variant_declarator: | |
2266 | declarator | |
6dc474b8 | 2267 | { $$ = $1; } |
8b9d5b5e | 2268 | | COLON unary_expression |
6dc474b8 | 2269 | { $$ = $2; } |
8b9d5b5e | 2270 | | declarator COLON unary_expression |
6dc474b8 MD |
2271 | { |
2272 | $$ = $1; | |
48a01768 | 2273 | if (set_parent_node($3, $1)) |
6dc474b8 MD |
2274 | reparent_error(scanner, "struct_or_variant_declarator"); |
2275 | } | |
8b9d5b5e MD |
2276 | ; |
2277 | ||
2278 | enumerator_list: | |
2279 | enumerator | |
0009a725 | 2280 | { $$ = $1; } |
8b9d5b5e | 2281 | | enumerator_list COMMA enumerator |
6dc474b8 MD |
2282 | { |
2283 | $$ = $1; | |
3122e6f0 | 2284 | bt_list_add_tail(&($3)->siblings, &($$)->tmp_head); |
6dc474b8 | 2285 | } |
8b9d5b5e MD |
2286 | ; |
2287 | ||
2288 | enumerator: | |
2289 | IDENTIFIER | |
6dc474b8 MD |
2290 | { |
2291 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2292 | $$->u.enumerator.id = $1->s; | |
2293 | } | |
8b9d5b5e | 2294 | | ID_TYPE |
6dc474b8 MD |
2295 | { |
2296 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2297 | $$->u.enumerator.id = $1->s; | |
2298 | } | |
8b9d5b5e | 2299 | | keywords |
6dc474b8 MD |
2300 | { |
2301 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2302 | $$->u.enumerator.id = $1->s; | |
2303 | } | |
d876a5ba | 2304 | | STRING_LITERAL |
6dc474b8 MD |
2305 | { |
2306 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
d876a5ba | 2307 | $$->u.enumerator.id = $1->s; |
6dc474b8 | 2308 | } |
8b9d5b5e | 2309 | | IDENTIFIER EQUAL unary_expression_or_range |
6dc474b8 MD |
2310 | { |
2311 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2312 | $$->u.enumerator.id = $1->s; | |
3122e6f0 | 2313 | bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values); |
6dc474b8 | 2314 | } |
8b9d5b5e | 2315 | | ID_TYPE EQUAL unary_expression_or_range |
6dc474b8 MD |
2316 | { |
2317 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2318 | $$->u.enumerator.id = $1->s; | |
3122e6f0 | 2319 | bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values); |
6dc474b8 | 2320 | } |
8b9d5b5e | 2321 | | keywords EQUAL unary_expression_or_range |
6dc474b8 MD |
2322 | { |
2323 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
2324 | $$->u.enumerator.id = $1->s; | |
3122e6f0 | 2325 | bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values); |
6dc474b8 | 2326 | } |
d876a5ba | 2327 | | STRING_LITERAL EQUAL unary_expression_or_range |
6dc474b8 MD |
2328 | { |
2329 | $$ = make_node(scanner, NODE_ENUMERATOR); | |
d876a5ba EB |
2330 | $$->u.enumerator.id = $1->s; |
2331 | bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values); | |
6dc474b8 | 2332 | } |
8b9d5b5e MD |
2333 | ; |
2334 | ||
2335 | abstract_declarator_list: | |
2336 | abstract_declarator | |
0009a725 | 2337 | { $$ = $1; } |
8b9d5b5e | 2338 | | abstract_declarator_list COMMA abstract_declarator |
6dc474b8 MD |
2339 | { |
2340 | $$ = $1; | |
3122e6f0 | 2341 | bt_list_add_tail(&($3)->siblings, &($$)->tmp_head); |
6dc474b8 | 2342 | } |
8b9d5b5e MD |
2343 | ; |
2344 | ||
2345 | abstract_declarator: | |
2346 | direct_abstract_declarator | |
6dc474b8 | 2347 | { $$ = $1; } |
8b9d5b5e | 2348 | | pointer direct_abstract_declarator |
6dc474b8 MD |
2349 | { |
2350 | $$ = $2; | |
3122e6f0 | 2351 | bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers); |
6dc474b8 | 2352 | } |
8b9d5b5e MD |
2353 | ; |
2354 | ||
2355 | direct_abstract_declarator: | |
2356 | /* empty */ | |
6dc474b8 MD |
2357 | { |
2358 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2359 | $$->u.type_declarator.type = TYPEDEC_ID; | |
2360 | /* id is NULL */ | |
2361 | } | |
8b9d5b5e | 2362 | | IDENTIFIER |
6dc474b8 MD |
2363 | { |
2364 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2365 | $$->u.type_declarator.type = TYPEDEC_ID; | |
2366 | $$->u.type_declarator.u.id = $1->s; | |
2367 | } | |
8b9d5b5e | 2368 | | LPAREN abstract_declarator RPAREN |
6dc474b8 MD |
2369 | { |
2370 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2371 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2372 | $$->u.type_declarator.u.nested.type_declarator = $2; | |
2373 | } | |
98df1c9f | 2374 | | direct_abstract_declarator LSBRAC unary_expression RSBRAC |
6dc474b8 MD |
2375 | { |
2376 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2377 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2378 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
3122e6f0 JD |
2379 | BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length); |
2380 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length); | |
6dc474b8 | 2381 | } |
8b9d5b5e | 2382 | | direct_abstract_declarator LSBRAC RSBRAC |
6dc474b8 MD |
2383 | { |
2384 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2385 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2386 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
2387 | $$->u.type_declarator.u.nested.abstract_array = 1; | |
2388 | } | |
8b9d5b5e MD |
2389 | ; |
2390 | ||
e0c14875 MD |
2391 | alias_abstract_declarator_list: |
2392 | alias_abstract_declarator | |
6dc474b8 | 2393 | { $$ = $1; } |
e0c14875 MD |
2394 | | alias_abstract_declarator_list COMMA alias_abstract_declarator |
2395 | { | |
2396 | $$ = $1; | |
3122e6f0 | 2397 | bt_list_add_tail(&($3)->siblings, &($$)->tmp_head); |
e0c14875 MD |
2398 | } |
2399 | ; | |
2400 | ||
2401 | alias_abstract_declarator: | |
2402 | direct_alias_abstract_declarator | |
2403 | { $$ = $1; } | |
2404 | | pointer direct_alias_abstract_declarator | |
6dc474b8 MD |
2405 | { |
2406 | $$ = $2; | |
3122e6f0 | 2407 | bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers); |
6dc474b8 | 2408 | } |
8b9d5b5e MD |
2409 | ; |
2410 | ||
e0c14875 MD |
2411 | direct_alias_abstract_declarator: |
2412 | /* empty */ | |
6dc474b8 MD |
2413 | { |
2414 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
e0c14875 MD |
2415 | $$->u.type_declarator.type = TYPEDEC_ID; |
2416 | /* id is NULL */ | |
6dc474b8 | 2417 | } |
e0c14875 | 2418 | | LPAREN alias_abstract_declarator RPAREN |
6dc474b8 MD |
2419 | { |
2420 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2421 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2422 | $$->u.type_declarator.u.nested.type_declarator = $2; | |
2423 | } | |
98df1c9f | 2424 | | direct_alias_abstract_declarator LSBRAC unary_expression RSBRAC |
6dc474b8 MD |
2425 | { |
2426 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2427 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2428 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
3122e6f0 JD |
2429 | BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length); |
2430 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length); | |
6dc474b8 | 2431 | } |
e0c14875 MD |
2432 | | direct_alias_abstract_declarator LSBRAC RSBRAC |
2433 | { | |
2434 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2435 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2436 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
2437 | $$->u.type_declarator.u.nested.abstract_array = 1; | |
2438 | } | |
8b9d5b5e MD |
2439 | ; |
2440 | ||
e0c14875 MD |
2441 | declarator: |
2442 | direct_declarator | |
6dc474b8 | 2443 | { $$ = $1; } |
e0c14875 | 2444 | | pointer direct_declarator |
6dc474b8 MD |
2445 | { |
2446 | $$ = $2; | |
3122e6f0 | 2447 | bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers); |
6dc474b8 | 2448 | } |
8b9d5b5e MD |
2449 | ; |
2450 | ||
e0c14875 | 2451 | direct_declarator: |
8b9d5b5e | 2452 | IDENTIFIER |
6dc474b8 | 2453 | { |
6dc474b8 MD |
2454 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); |
2455 | $$->u.type_declarator.type = TYPEDEC_ID; | |
2456 | $$->u.type_declarator.u.id = $1->s; | |
2457 | } | |
e0c14875 | 2458 | | LPAREN declarator RPAREN |
6dc474b8 MD |
2459 | { |
2460 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2461 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2462 | $$->u.type_declarator.u.nested.type_declarator = $2; | |
2463 | } | |
98df1c9f | 2464 | | direct_declarator LSBRAC unary_expression RSBRAC |
6dc474b8 MD |
2465 | { |
2466 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2467 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2468 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
3122e6f0 JD |
2469 | BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length); |
2470 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length); | |
6dc474b8 | 2471 | } |
8b9d5b5e MD |
2472 | ; |
2473 | ||
e0c14875 MD |
2474 | type_declarator: |
2475 | direct_type_declarator | |
6dc474b8 | 2476 | { $$ = $1; } |
e0c14875 | 2477 | | pointer direct_type_declarator |
6dc474b8 MD |
2478 | { |
2479 | $$ = $2; | |
3122e6f0 | 2480 | bt_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers); |
6dc474b8 | 2481 | } |
8b9d5b5e MD |
2482 | ; |
2483 | ||
e0c14875 MD |
2484 | direct_type_declarator: |
2485 | IDENTIFIER | |
6dc474b8 MD |
2486 | { |
2487 | add_type(scanner, $1); | |
2488 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2489 | $$->u.type_declarator.type = TYPEDEC_ID; | |
2490 | $$->u.type_declarator.u.id = $1->s; | |
2491 | } | |
e0c14875 | 2492 | | LPAREN type_declarator RPAREN |
6dc474b8 MD |
2493 | { |
2494 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2495 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2496 | $$->u.type_declarator.u.nested.type_declarator = $2; | |
2497 | } | |
98df1c9f | 2498 | | direct_type_declarator LSBRAC unary_expression RSBRAC |
6dc474b8 MD |
2499 | { |
2500 | $$ = make_node(scanner, NODE_TYPE_DECLARATOR); | |
2501 | $$->u.type_declarator.type = TYPEDEC_NESTED; | |
2502 | $$->u.type_declarator.u.nested.type_declarator = $1; | |
3122e6f0 JD |
2503 | BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length); |
2504 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length); | |
6dc474b8 | 2505 | } |
8b9d5b5e MD |
2506 | ; |
2507 | ||
2508 | pointer: | |
2509 | STAR | |
48a01768 MD |
2510 | { |
2511 | $$ = make_node(scanner, NODE_POINTER); | |
48a01768 | 2512 | } |
8b9d5b5e | 2513 | | STAR pointer |
6dc474b8 MD |
2514 | { |
2515 | $$ = make_node(scanner, NODE_POINTER); | |
3122e6f0 | 2516 | bt_list_splice(&($2)->tmp_head, &($$)->tmp_head); |
6dc474b8 | 2517 | } |
8b9d5b5e | 2518 | | STAR type_qualifier_list pointer |
6dc474b8 MD |
2519 | { |
2520 | $$ = make_node(scanner, NODE_POINTER); | |
2521 | $$->u.pointer.const_qualifier = 1; | |
3122e6f0 | 2522 | bt_list_splice(&($3)->tmp_head, &($$)->tmp_head); |
6dc474b8 | 2523 | } |
8b9d5b5e MD |
2524 | ; |
2525 | ||
2526 | type_qualifier_list: | |
6dc474b8 | 2527 | /* pointer assumes only const type qualifier */ |
8b9d5b5e MD |
2528 | CONST |
2529 | | type_qualifier_list CONST | |
2530 | ; | |
2531 | ||
2532 | /* 2.3: CTF-specific declarations */ | |
2533 | ||
2534 | ctf_assignment_expression_list: | |
2535 | ctf_assignment_expression SEMICOLON | |
0009a725 | 2536 | { $$ = $1; } |
8b9d5b5e | 2537 | | ctf_assignment_expression_list ctf_assignment_expression SEMICOLON |
6dc474b8 MD |
2538 | { |
2539 | $$ = $1; | |
3122e6f0 | 2540 | bt_list_add_tail(&($2)->siblings, &($$)->tmp_head); |
6dc474b8 | 2541 | } |
8b9d5b5e MD |
2542 | ; |
2543 | ||
2544 | ctf_assignment_expression: | |
2545 | unary_expression EQUAL unary_expression | |
02b234c4 | 2546 | { |
6dc474b8 MD |
2547 | /* |
2548 | * Because we have left and right, cannot use | |
48a01768 | 2549 | * set_parent_node. |
6dc474b8 | 2550 | */ |
02b234c4 | 2551 | $$ = make_node(scanner, NODE_CTF_EXPRESSION); |
3122e6f0 | 2552 | _bt_list_splice_tail(&($1)->tmp_head, &($$)->u.ctf_expression.left); |
6dc474b8 MD |
2553 | if ($1->u.unary_expression.type != UNARY_STRING) |
2554 | reparent_error(scanner, "ctf_assignment_expression left expects string"); | |
3122e6f0 | 2555 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.ctf_expression.right); |
02b234c4 | 2556 | } |
427c09b7 | 2557 | | unary_expression TYPEASSIGN declaration_specifiers /* Only allow struct */ |
6dc474b8 MD |
2558 | { |
2559 | /* | |
2560 | * Because we have left and right, cannot use | |
48a01768 | 2561 | * set_parent_node. |
6dc474b8 MD |
2562 | */ |
2563 | $$ = make_node(scanner, NODE_CTF_EXPRESSION); | |
3122e6f0 | 2564 | _bt_list_splice_tail(&($1)->tmp_head, &($$)->u.ctf_expression.left); |
6dc474b8 MD |
2565 | if ($1->u.unary_expression.type != UNARY_STRING) |
2566 | reparent_error(scanner, "ctf_assignment_expression left expects string"); | |
3122e6f0 | 2567 | bt_list_add_tail(&($3)->siblings, &($$)->u.ctf_expression.right); |
6dc474b8 | 2568 | } |
8b9d5b5e | 2569 | | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list |
6dc474b8 | 2570 | { |
3e11b713 MD |
2571 | struct ctf_node *list; |
2572 | ||
2573 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
3122e6f0 JD |
2574 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2575 | _bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head); | |
6dc474b8 | 2576 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 | 2577 | ($$)->u.struct_or_variant_declaration.type_specifier_list = list; |
3122e6f0 | 2578 | _bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators); |
6dc474b8 | 2579 | } |
8b9d5b5e | 2580 | | TYPEDEF declaration_specifiers type_declarator_list |
6dc474b8 | 2581 | { |
3e11b713 MD |
2582 | struct ctf_node *list; |
2583 | ||
6dc474b8 | 2584 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 MD |
2585 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); |
2586 | $$->u._typedef.type_specifier_list = list; | |
3122e6f0 JD |
2587 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2588 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); | |
6dc474b8 | 2589 | } |
8b9d5b5e | 2590 | | declaration_specifiers TYPEDEF type_declarator_list |
6dc474b8 | 2591 | { |
3e11b713 MD |
2592 | struct ctf_node *list; |
2593 | ||
2594 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
3122e6f0 | 2595 | _bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
6dc474b8 | 2596 | $$ = make_node(scanner, NODE_TYPEDEF); |
3e11b713 | 2597 | ($$)->u.struct_or_variant_declaration.type_specifier_list = list; |
3122e6f0 | 2598 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators); |
6dc474b8 | 2599 | } |
a030d084 | 2600 | | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list |
6dc474b8 | 2601 | { |
3e11b713 MD |
2602 | struct ctf_node *list; |
2603 | ||
6dc474b8 MD |
2604 | $$ = make_node(scanner, NODE_TYPEALIAS); |
2605 | $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET); | |
2606 | $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS); | |
3e11b713 MD |
2607 | |
2608 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2609 | $$->u.typealias.target->u.typealias_target.type_specifier_list = list; | |
3122e6f0 JD |
2610 | _bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2611 | _bt_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators); | |
3e11b713 MD |
2612 | |
2613 | list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST); | |
2614 | $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list; | |
3122e6f0 JD |
2615 | _bt_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head); |
2616 | _bt_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators); | |
6dc474b8 | 2617 | } |
8b9d5b5e | 2618 | ; |