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