5 * Common Trace Format Metadata Grammar.
7 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
28 #include <babeltrace/list.h>
29 #include <babeltrace/babeltrace.h>
30 #include "ctf-scanner.h"
31 #include "ctf-parser.h"
37 * TODO: support enum, variant and struct declarations in scopes.
40 /* Join two lists, put "add" at the end of "head". */
42 _cds_list_splice_tail (struct cds_list_head *add, struct cds_list_head *head)
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;
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);
62 struct cds_list_head gc;
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",
93 const char *node_type(struct ctf_node *node)
95 if (node->type < NR_NODE_TYPES)
96 return node_type_to_str[node->type];
101 static struct gc_string *gc_string_alloc(struct ctf_scanner *scanner,
104 struct gc_string *gstr;
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;
112 gstr = malloc(alloclen);
113 cds_list_add(&gstr->gc, &scanner->allocated_strings);
114 gstr->alloclen = alloclen;
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.
123 struct gc_string *gc_string_append(struct ctf_scanner *scanner,
124 struct gc_string *gstr,
125 struct gc_string *gsrc)
127 size_t newlen = strlen(gsrc->s) + strlen(gstr->s) + 1;
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;
135 if (alloclen > gstr->alloclen) {
136 struct gc_string *newgstr;
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);
145 strcat(gstr->s, gsrc->s);
147 cds_list_del(&gsrc->gc);
152 void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src)
154 lvalp->gs = gc_string_alloc(scanner, strlen(src) + 1);
155 strcpy(lvalp->gs->s, src);
158 static void init_scope(struct ctf_scanner_scope *scope,
159 struct ctf_scanner_scope *parent)
161 scope->parent = parent;
162 scope->types = g_hash_table_new_full(g_str_hash, g_str_equal,
166 static void finalize_scope(struct ctf_scanner_scope *scope)
168 g_hash_table_destroy(scope->types);
171 static void push_scope(struct ctf_scanner *scanner)
173 struct ctf_scanner_scope *ns;
175 printf_debug("push scope\n");
176 ns = malloc(sizeof(struct ctf_scanner_scope));
177 init_scope(ns, scanner->cs);
181 static void pop_scope(struct ctf_scanner *scanner)
183 struct ctf_scanner_scope *os;
185 printf_debug("pop scope\n");
187 scanner->cs = os->parent;
192 static int lookup_type(struct ctf_scanner_scope *s, const char *id)
196 ret = (int) (long) g_hash_table_lookup(s->types, id);
197 printf_debug("lookup %p %s %d\n", s, id, ret);
201 int is_type(struct ctf_scanner *scanner, const char *id)
203 struct ctf_scanner_scope *it;
206 for (it = scanner->cs; it != NULL; it = it->parent) {
207 if (lookup_type(it, id)) {
212 printf_debug("is type %s %d\n", id, ret);
216 static void add_type(struct ctf_scanner *scanner, struct gc_string *id)
218 printf_debug("add type %s\n", id->s);
219 if (lookup_type(scanner->cs, id->s))
221 g_hash_table_insert(scanner->cs->types, id->s, id->s);
224 static struct ctf_node *make_node(struct ctf_scanner *scanner,
227 struct ctf_ast *ast = ctf_scanner_get_ast(scanner);
228 struct ctf_node *node;
230 node = malloc(sizeof(*node));
233 memset(node, 0, sizeof(*node));
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);
241 fprintf(stderr, "[error] %s: trying to create root node\n", __func__);
245 CDS_INIT_LIST_HEAD(&node->u.event.declaration_list);
248 CDS_INIT_LIST_HEAD(&node->u.stream.declaration_list);
251 CDS_INIT_LIST_HEAD(&node->u.trace.declaration_list);
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);
258 case NODE_UNARY_EXPRESSION:
262 CDS_INIT_LIST_HEAD(&node->u._typedef.type_declarators);
264 case NODE_TYPEALIAS_TARGET:
265 CDS_INIT_LIST_HEAD(&node->u.typealias_target.type_declarators);
267 case NODE_TYPEALIAS_ALIAS:
268 CDS_INIT_LIST_HEAD(&node->u.typealias_alias.type_declarators);
273 case NODE_TYPE_SPECIFIER:
275 case NODE_TYPE_SPECIFIER_LIST:
276 CDS_INIT_LIST_HEAD(&node->u.type_specifier_list.head);
280 case NODE_TYPE_DECLARATOR:
281 CDS_INIT_LIST_HEAD(&node->u.type_declarator.pointers);
284 case NODE_FLOATING_POINT:
285 CDS_INIT_LIST_HEAD(&node->u.floating_point.expressions);
288 CDS_INIT_LIST_HEAD(&node->u.integer.expressions);
291 CDS_INIT_LIST_HEAD(&node->u.string.expressions);
293 case NODE_ENUMERATOR:
294 CDS_INIT_LIST_HEAD(&node->u.enumerator.values);
297 CDS_INIT_LIST_HEAD(&node->u._enum.enumerator_list);
299 case NODE_STRUCT_OR_VARIANT_DECLARATION:
300 CDS_INIT_LIST_HEAD(&node->u.struct_or_variant_declaration.type_declarators);
303 CDS_INIT_LIST_HEAD(&node->u.variant.declaration_list);
306 CDS_INIT_LIST_HEAD(&node->u._struct.declaration_list);
311 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
319 static int reparent_ctf_expression(struct ctf_node *node,
320 struct ctf_node *parent)
322 switch (parent->type) {
324 _cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
327 _cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
330 _cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
332 case NODE_FLOATING_POINT:
333 _cds_list_splice_tail(&node->tmp_head, &parent->u.floating_point.expressions);
336 _cds_list_splice_tail(&node->tmp_head, &parent->u.integer.expressions);
339 _cds_list_splice_tail(&node->tmp_head, &parent->u.string.expressions);
343 case NODE_CTF_EXPRESSION:
345 case NODE_TYPEALIAS_TARGET:
346 case NODE_TYPEALIAS_ALIAS:
348 case NODE_TYPE_SPECIFIER:
349 case NODE_TYPE_SPECIFIER_LIST:
351 case NODE_TYPE_DECLARATOR:
352 case NODE_ENUMERATOR:
354 case NODE_STRUCT_OR_VARIANT_DECLARATION:
357 case NODE_UNARY_EXPRESSION:
362 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
369 static int reparent_typedef(struct ctf_node *node, struct ctf_node *parent)
371 switch (parent->type) {
373 _cds_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list);
376 _cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
379 _cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
382 _cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
385 _cds_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list);
388 _cds_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list);
391 case NODE_FLOATING_POINT:
394 case NODE_CTF_EXPRESSION:
396 case NODE_TYPEALIAS_TARGET:
397 case NODE_TYPEALIAS_ALIAS:
399 case NODE_TYPE_SPECIFIER:
400 case NODE_TYPE_SPECIFIER_LIST:
402 case NODE_TYPE_DECLARATOR:
403 case NODE_ENUMERATOR:
405 case NODE_STRUCT_OR_VARIANT_DECLARATION:
406 case NODE_UNARY_EXPRESSION:
411 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
418 static int reparent_typealias(struct ctf_node *node, struct ctf_node *parent)
420 switch (parent->type) {
422 _cds_list_splice_tail(&node->tmp_head, &parent->u.root.declaration_list);
425 _cds_list_splice_tail(&node->tmp_head, &parent->u.event.declaration_list);
428 _cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
431 _cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
434 _cds_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list);
437 _cds_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list);
440 case NODE_FLOATING_POINT:
443 case NODE_CTF_EXPRESSION:
445 case NODE_TYPEALIAS_TARGET:
446 case NODE_TYPEALIAS_ALIAS:
448 case NODE_TYPE_SPECIFIER:
449 case NODE_TYPE_SPECIFIER_LIST:
451 case NODE_TYPE_DECLARATOR:
452 case NODE_ENUMERATOR:
454 case NODE_STRUCT_OR_VARIANT_DECLARATION:
455 case NODE_UNARY_EXPRESSION:
460 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
467 static int reparent_type_specifier(struct ctf_node *node,
468 struct ctf_node *parent)
470 switch (parent->type) {
471 case NODE_TYPE_SPECIFIER_LIST:
472 _cds_list_splice_tail(&node->tmp_head, &parent->u.type_specifier_list.head);
475 case NODE_TYPE_SPECIFIER:
482 case NODE_TYPEALIAS_TARGET:
483 case NODE_TYPEALIAS_ALIAS:
484 case NODE_TYPE_DECLARATOR:
486 case NODE_STRUCT_OR_VARIANT_DECLARATION:
488 case NODE_FLOATING_POINT:
491 case NODE_CTF_EXPRESSION:
493 case NODE_ENUMERATOR:
494 case NODE_UNARY_EXPRESSION:
499 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
506 static int reparent_type_specifier_list(struct ctf_node *node,
507 struct ctf_node *parent)
509 switch (parent->type) {
511 cds_list_add_tail(&node->siblings, &parent->u.root.declaration_list);
514 cds_list_add_tail(&node->siblings, &parent->u.event.declaration_list);
517 cds_list_add_tail(&node->siblings, &parent->u.stream.declaration_list);
520 cds_list_add_tail(&node->siblings, &parent->u.trace.declaration_list);
523 cds_list_add_tail(&node->siblings, &parent->u.variant.declaration_list);
526 cds_list_add_tail(&node->siblings, &parent->u._struct.declaration_list);
529 parent->u._typedef.type_specifier_list = node;
531 case NODE_TYPEALIAS_TARGET:
532 parent->u.typealias_target.type_specifier_list = node;
534 case NODE_TYPEALIAS_ALIAS:
535 parent->u.typealias_alias.type_specifier_list = node;
537 case NODE_TYPE_DECLARATOR:
538 parent->u.type_declarator.type = TYPEDEC_NESTED;
539 parent->u.type_declarator.u.nested.length = node;
542 parent->u._enum.container_type = node;
544 case NODE_STRUCT_OR_VARIANT_DECLARATION:
545 parent->u.struct_or_variant_declaration.type_specifier_list = node;
547 case NODE_TYPE_SPECIFIER:
549 case NODE_FLOATING_POINT:
552 case NODE_CTF_EXPRESSION:
554 case NODE_ENUMERATOR:
555 case NODE_UNARY_EXPRESSION:
560 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
567 static int reparent_type_declarator(struct ctf_node *node,
568 struct ctf_node *parent)
570 switch (parent->type) {
571 case NODE_TYPE_DECLARATOR:
572 parent->u.type_declarator.type = TYPEDEC_NESTED;
573 parent->u.type_declarator.u.nested.type_declarator = node;
575 case NODE_STRUCT_OR_VARIANT_DECLARATION:
576 _cds_list_splice_tail(&node->tmp_head, &parent->u.struct_or_variant_declaration.type_declarators);
579 _cds_list_splice_tail(&node->tmp_head, &parent->u._typedef.type_declarators);
581 case NODE_TYPEALIAS_TARGET:
582 _cds_list_splice_tail(&node->tmp_head, &parent->u.typealias_target.type_declarators);
584 case NODE_TYPEALIAS_ALIAS:
585 _cds_list_splice_tail(&node->tmp_head, &parent->u.typealias_alias.type_declarators);
596 case NODE_FLOATING_POINT:
599 case NODE_CTF_EXPRESSION:
600 case NODE_TYPE_SPECIFIER:
601 case NODE_TYPE_SPECIFIER_LIST:
603 case NODE_ENUMERATOR:
604 case NODE_UNARY_EXPRESSION:
609 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
619 * Link node to parent. Returns 0 on success, -EPERM if it is not permitted to
620 * create the link declared by the input, -ENOENT if node or parent is NULL,
621 * -EINVAL if there is an internal structure problem.
623 static int set_parent_node(struct ctf_node *node,
624 struct ctf_node *parent)
626 if (!node || !parent)
629 /* Note: Linking to parent will be done only by an external visitor */
631 switch (node->type) {
633 fprintf(stderr, "[error] %s: trying to reparent root node\n", __func__);
637 if (parent->type == NODE_ROOT) {
638 _cds_list_splice_tail(&node->tmp_head, &parent->u.root.event);
644 if (parent->type == NODE_ROOT) {
645 _cds_list_splice_tail(&node->tmp_head, &parent->u.root.stream);
651 if (parent->type == NODE_ROOT) {
652 _cds_list_splice_tail(&node->tmp_head, &parent->u.root.trace);
658 case NODE_CTF_EXPRESSION:
659 return reparent_ctf_expression(node, parent);
660 case NODE_UNARY_EXPRESSION:
661 if (parent->type == NODE_TYPE_DECLARATOR)
662 parent->u.type_declarator.bitfield_len = node;
668 return reparent_typedef(node, parent);
669 case NODE_TYPEALIAS_TARGET:
670 if (parent->type == NODE_TYPEALIAS)
671 parent->u.typealias.target = node;
674 case NODE_TYPEALIAS_ALIAS:
675 if (parent->type == NODE_TYPEALIAS)
676 parent->u.typealias.alias = node;
680 return reparent_typealias(node, parent);
683 if (parent->type == NODE_TYPE_DECLARATOR) {
684 _cds_list_splice_tail(&node->tmp_head, &parent->u.type_declarator.pointers);
688 case NODE_TYPE_DECLARATOR:
689 return reparent_type_declarator(node, parent);
691 case NODE_TYPE_SPECIFIER_LIST:
692 return reparent_type_specifier_list(node, parent);
694 case NODE_TYPE_SPECIFIER:
695 return reparent_type_specifier(node, parent);
697 case NODE_FLOATING_POINT:
703 return -EINVAL; /* Dealt with internally within grammar */
705 case NODE_ENUMERATOR:
706 if (parent->type == NODE_ENUM) {
707 _cds_list_splice_tail(&node->tmp_head, &parent->u._enum.enumerator_list);
712 case NODE_STRUCT_OR_VARIANT_DECLARATION:
713 switch (parent->type) {
715 _cds_list_splice_tail(&node->tmp_head, &parent->u._struct.declaration_list);
718 _cds_list_splice_tail(&node->tmp_head, &parent->u.variant.declaration_list);
727 fprintf(stderr, "[error] %s: unknown node type %d\n", __func__,
734 void yyerror(struct ctf_scanner *scanner, const char *str)
736 fprintf(stderr, "error %s\n", str);
744 #define reparent_error(scanner, str) \
746 yyerror(scanner, YY_("reparent_error: " str "\n")); \
750 static void free_strings(struct cds_list_head *list)
752 struct gc_string *gstr, *tmp;
754 cds_list_for_each_entry_safe(gstr, tmp, list, gc)
758 static struct ctf_ast *ctf_ast_alloc(void)
762 ast = malloc(sizeof(*ast));
765 memset(ast, 0, sizeof(*ast));
766 CDS_INIT_LIST_HEAD(&ast->allocated_nodes);
767 ast->root.type = NODE_ROOT;
768 CDS_INIT_LIST_HEAD(&ast->root.tmp_head);
769 CDS_INIT_LIST_HEAD(&ast->root.u.root.declaration_list);
770 CDS_INIT_LIST_HEAD(&ast->root.u.root.trace);
771 CDS_INIT_LIST_HEAD(&ast->root.u.root.stream);
772 CDS_INIT_LIST_HEAD(&ast->root.u.root.event);
776 static void ctf_ast_free(struct ctf_ast *ast)
778 struct ctf_node *node, *tmp;
780 cds_list_for_each_entry_safe(node, tmp, &ast->allocated_nodes, gc)
784 int ctf_scanner_append_ast(struct ctf_scanner *scanner)
786 return yyparse(scanner);
789 struct ctf_scanner *ctf_scanner_alloc(FILE *input)
791 struct ctf_scanner *scanner;
794 yydebug = babeltrace_debug;
796 scanner = malloc(sizeof(*scanner));
799 memset(scanner, 0, sizeof(*scanner));
801 ret = yylex_init_extra(scanner, &scanner->scanner);
803 fprintf(stderr, "yylex_init error\n");
804 goto cleanup_scanner;
806 /* Start processing new stream */
807 yyrestart(input, scanner->scanner);
809 scanner->ast = ctf_ast_alloc();
812 init_scope(&scanner->root_scope, NULL);
813 scanner->cs = &scanner->root_scope;
814 CDS_INIT_LIST_HEAD(&scanner->allocated_strings);
817 fprintf(stdout, "Scanner input is a%s.\n",
818 isatty(fileno(input)) ? "n interactive tty" :
819 " noninteractive file");
824 ret = yylex_destroy(scanner->scanner);
826 fprintf(stderr, "yylex_destroy error\n");
832 void ctf_scanner_free(struct ctf_scanner *scanner)
836 finalize_scope(&scanner->root_scope);
837 free_strings(&scanner->allocated_strings);
838 ctf_ast_free(scanner->ast);
839 ret = yylex_destroy(scanner->scanner);
841 fprintf(stderr, "yylex_destroy error\n");
849 %parse-param {struct ctf_scanner *scanner}
850 %lex-param {struct ctf_scanner *scanner}
852 * Expect two shift-reduce conflicts. Caused by enum name-opt : type {}
853 * vs struct { int :value; } (unnamed bit-field). The default is to
854 * shift, so whenever we encounter an enumeration, we are doing the
855 * proper thing (shift). It is illegal to declare an enumeration
856 * "bit-field", so it is OK if this situation ends up in a parsing
861 %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
862 %token <gs> IDENTIFIER ID_TYPE
868 struct gc_string *gs;
873 %type <gs> s_char s_char_sequence c_char c_char_sequence
875 %type <n> postfix_expression unary_expression unary_expression_or_range
877 %type <n> declaration
878 %type <n> event_declaration
879 %type <n> stream_declaration
880 %type <n> trace_declaration
881 %type <n> integer_declaration_specifiers
882 %type <n> declaration_specifiers
883 %type <n> alias_declaration_specifiers
885 %type <n> type_declarator_list
886 %type <n> integer_type_specifier
887 %type <n> type_specifier
888 %type <n> struct_type_specifier
889 %type <n> variant_type_specifier
890 %type <n> declaration_specifiers_or_integer_constant
891 %type <n> enum_type_specifier
892 %type <n> struct_or_variant_declaration_list
893 %type <n> struct_or_variant_declaration
894 %type <n> struct_or_variant_declarator_list
895 %type <n> struct_or_variant_declarator
896 %type <n> enumerator_list
898 %type <n> abstract_declarator_list
899 %type <n> abstract_declarator
900 %type <n> direct_abstract_declarator
901 %type <n> alias_abstract_declarator_list
902 %type <n> alias_abstract_declarator
903 %type <n> direct_alias_abstract_declarator
905 %type <n> direct_declarator
906 %type <n> type_declarator
907 %type <n> direct_type_declarator
909 %type <n> ctf_assignment_expression_list
910 %type <n> ctf_assignment_expression
917 if (set_parent_node($1, &ctf_scanner_get_ast(scanner)->root))
918 reparent_error(scanner, "error reparenting to root");
922 if (set_parent_node($2, &ctf_scanner_get_ast(scanner)->root))
923 reparent_error(scanner, "error reparenting to root");
981 | c_char_sequence c_char
982 { $$ = gc_string_append(scanner, $1, $2); }
990 reparent_error(scanner, "escape sequences not supported yet");
994 /* 1.6 String literals */
999 | s_char_sequence s_char
1000 { $$ = gc_string_append(scanner, $1, $2); }
1008 reparent_error(scanner, "escape sequences not supported yet");
1012 /* 2: Phrase structure grammar */
1017 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1018 $$->u.unary_expression.type = UNARY_STRING;
1019 $$->u.unary_expression.u.string = yylval.gs->s;
1023 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1024 $$->u.unary_expression.type = UNARY_STRING;
1025 $$->u.unary_expression.u.string = yylval.gs->s;
1029 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1030 $$->u.unary_expression.type = UNARY_STRING;
1031 $$->u.unary_expression.u.string = yylval.gs->s;
1035 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1036 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1037 sscanf(yylval.gs->s, "%" PRIu64,
1038 &$$->u.unary_expression.u.unsigned_constant);
1042 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1043 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1044 sscanf(yylval.gs->s, "0%" PRIo64,
1045 &$$->u.unary_expression.u.unsigned_constant);
1047 | HEXADECIMAL_CONSTANT
1049 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1050 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1051 sscanf(yylval.gs->s, "0x%" PRIx64,
1052 &$$->u.unary_expression.u.unsigned_constant);
1054 | STRING_LITERAL_START DQUOTE
1056 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1057 $$->u.unary_expression.type = UNARY_STRING;
1058 $$->u.unary_expression.u.string = "";
1060 | STRING_LITERAL_START s_char_sequence DQUOTE
1062 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1063 $$->u.unary_expression.type = UNARY_STRING;
1064 $$->u.unary_expression.u.string = $2->s;
1066 | CHARACTER_CONSTANT_START c_char_sequence SQUOTE
1068 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1069 $$->u.unary_expression.type = UNARY_STRING;
1070 $$->u.unary_expression.u.string = $2->s;
1072 | LPAREN unary_expression RPAREN
1074 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1075 $$->u.unary_expression.type = UNARY_NESTED;
1076 $$->u.unary_expression.u.nested_exp = $2;
1078 | postfix_expression LSBRAC unary_expression RSBRAC
1080 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1081 $$->u.unary_expression.type = UNARY_SBRAC;
1082 $$->u.unary_expression.u.sbrac_exp = $3;
1083 cds_list_splice(&($1)->tmp_head, &($$)->tmp_head);
1084 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1086 | postfix_expression DOT IDENTIFIER
1088 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1089 $$->u.unary_expression.type = UNARY_STRING;
1090 $$->u.unary_expression.u.string = yylval.gs->s;
1091 $$->u.unary_expression.link = UNARY_DOTLINK;
1092 cds_list_splice(&($1)->tmp_head, &($$)->tmp_head);
1093 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1095 | postfix_expression DOT ID_TYPE
1097 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1098 $$->u.unary_expression.type = UNARY_STRING;
1099 $$->u.unary_expression.u.string = yylval.gs->s;
1100 $$->u.unary_expression.link = UNARY_DOTLINK;
1101 cds_list_splice(&($1)->tmp_head, &($$)->tmp_head);
1102 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1104 | postfix_expression RARROW IDENTIFIER
1106 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1107 $$->u.unary_expression.type = UNARY_STRING;
1108 $$->u.unary_expression.u.string = yylval.gs->s;
1109 $$->u.unary_expression.link = UNARY_ARROWLINK;
1110 cds_list_splice(&($1)->tmp_head, &($$)->tmp_head);
1111 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1113 | postfix_expression RARROW ID_TYPE
1115 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1116 $$->u.unary_expression.type = UNARY_STRING;
1117 $$->u.unary_expression.u.string = yylval.gs->s;
1118 $$->u.unary_expression.link = UNARY_ARROWLINK;
1119 cds_list_splice(&($1)->tmp_head, &($$)->tmp_head);
1120 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1127 | PLUS postfix_expression
1129 | MINUS postfix_expression
1132 if ($$->u.unary_expression.type != UNARY_SIGNED_CONSTANT
1133 && $$->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT)
1134 reparent_error(scanner, "expecting numeric constant");
1136 if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) {
1137 $$->u.unary_expression.type = UNARY_SIGNED_CONSTANT;
1138 $$->u.unary_expression.u.signed_constant =
1139 -($$->u.unary_expression.u.unsigned_constant);
1141 $$->u.unary_expression.u.signed_constant =
1142 -($$->u.unary_expression.u.signed_constant);
1147 unary_expression_or_range:
1148 unary_expression DOTDOTDOT unary_expression
1151 _cds_list_splice_tail(&($3)->tmp_head, &($$)->tmp_head);
1152 $3->u.unary_expression.link = UNARY_DOTDOTDOT;
1158 /* 2.2: Declarations */
1161 declaration_specifiers SEMICOLON
1165 | stream_declaration
1169 | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
1171 struct ctf_node *list;
1173 $$ = make_node(scanner, NODE_TYPEDEF);
1174 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1175 $$->u._typedef.type_specifier_list = list;
1176 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1177 _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1178 _cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
1180 | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
1182 struct ctf_node *list;
1184 $$ = make_node(scanner, NODE_TYPEDEF);
1185 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1186 $$->u._typedef.type_specifier_list = list;
1187 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1188 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
1190 | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
1192 struct ctf_node *list;
1194 $$ = make_node(scanner, NODE_TYPEDEF);
1195 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1196 $$->u._typedef.type_specifier_list = list;
1197 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1198 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
1200 | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
1202 struct ctf_node *list;
1204 $$ = make_node(scanner, NODE_TYPEALIAS);
1205 $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
1206 $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
1208 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1209 $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
1210 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1211 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
1213 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1214 $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
1215 _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1216 _cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
1221 event_declaration_begin event_declaration_end
1223 $$ = make_node(scanner, NODE_EVENT);
1225 | event_declaration_begin ctf_assignment_expression_list event_declaration_end
1227 $$ = make_node(scanner, NODE_EVENT);
1228 if (set_parent_node($2, $$))
1229 reparent_error(scanner, "event_declaration");
1233 event_declaration_begin:
1235 { push_scope(scanner); }
1238 event_declaration_end:
1240 { pop_scope(scanner); }
1245 stream_declaration_begin stream_declaration_end
1247 $$ = make_node(scanner, NODE_STREAM);
1249 | stream_declaration_begin ctf_assignment_expression_list stream_declaration_end
1251 $$ = make_node(scanner, NODE_STREAM);
1252 if (set_parent_node($2, $$))
1253 reparent_error(scanner, "stream_declaration");
1257 stream_declaration_begin:
1259 { push_scope(scanner); }
1262 stream_declaration_end:
1264 { pop_scope(scanner); }
1269 trace_declaration_begin trace_declaration_end
1271 $$ = make_node(scanner, NODE_TRACE);
1273 | trace_declaration_begin ctf_assignment_expression_list trace_declaration_end
1275 $$ = make_node(scanner, NODE_TRACE);
1276 if (set_parent_node($2, $$))
1277 reparent_error(scanner, "trace_declaration");
1281 trace_declaration_begin:
1283 { push_scope(scanner); }
1286 trace_declaration_end:
1288 { pop_scope(scanner); }
1291 integer_declaration_specifiers:
1294 struct ctf_node *node;
1296 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1297 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1298 node->u.type_specifier.type = TYPESPEC_CONST;
1299 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1301 | integer_type_specifier
1303 struct ctf_node *node;
1305 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1307 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1309 | integer_declaration_specifiers CONST
1311 struct ctf_node *node;
1314 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1315 node->u.type_specifier.type = TYPESPEC_CONST;
1316 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1318 | integer_declaration_specifiers integer_type_specifier
1321 cds_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
1325 declaration_specifiers:
1328 struct ctf_node *node;
1330 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1331 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1332 node->u.type_specifier.type = TYPESPEC_CONST;
1333 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1337 struct ctf_node *node;
1339 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1341 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1343 | declaration_specifiers CONST
1345 struct ctf_node *node;
1348 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1349 node->u.type_specifier.type = TYPESPEC_CONST;
1350 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1352 | declaration_specifiers type_specifier
1355 cds_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
1359 type_declarator_list:
1362 | type_declarator_list COMMA type_declarator
1365 cds_list_add_tail(&($3)->siblings, &($$)->tmp_head);
1369 integer_type_specifier:
1372 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1373 $$->u.type_specifier.type = TYPESPEC_CHAR;
1377 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1378 $$->u.type_specifier.type = TYPESPEC_SHORT;
1382 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1383 $$->u.type_specifier.type = TYPESPEC_INT;
1387 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1388 $$->u.type_specifier.type = TYPESPEC_LONG;
1392 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1393 $$->u.type_specifier.type = TYPESPEC_SIGNED;
1397 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1398 $$->u.type_specifier.type = TYPESPEC_UNSIGNED;
1402 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1403 $$->u.type_specifier.type = TYPESPEC_BOOL;
1407 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1408 $$->u.type_specifier.type = TYPESPEC_ID_TYPE;
1409 $$->u.type_specifier.id_type = yylval.gs->s;
1411 | INTEGER LBRAC RBRAC
1413 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1414 $$->u.type_specifier.type = TYPESPEC_INTEGER;
1415 $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
1417 | INTEGER LBRAC ctf_assignment_expression_list RBRAC
1419 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1420 $$->u.type_specifier.type = TYPESPEC_INTEGER;
1421 $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
1422 if (set_parent_node($3, $$->u.type_specifier.node))
1423 reparent_error(scanner, "integer reparent error");
1430 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1431 $$->u.type_specifier.type = TYPESPEC_VOID;
1435 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1436 $$->u.type_specifier.type = TYPESPEC_CHAR;
1440 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1441 $$->u.type_specifier.type = TYPESPEC_SHORT;
1445 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1446 $$->u.type_specifier.type = TYPESPEC_INT;
1450 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1451 $$->u.type_specifier.type = TYPESPEC_LONG;
1455 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1456 $$->u.type_specifier.type = TYPESPEC_FLOAT;
1460 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1461 $$->u.type_specifier.type = TYPESPEC_DOUBLE;
1465 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1466 $$->u.type_specifier.type = TYPESPEC_SIGNED;
1470 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1471 $$->u.type_specifier.type = TYPESPEC_UNSIGNED;
1475 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1476 $$->u.type_specifier.type = TYPESPEC_BOOL;
1480 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1481 $$->u.type_specifier.type = TYPESPEC_COMPLEX;
1485 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1486 $$->u.type_specifier.type = TYPESPEC_IMAGINARY;
1490 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1491 $$->u.type_specifier.type = TYPESPEC_ID_TYPE;
1492 $$->u.type_specifier.id_type = yylval.gs->s;
1494 | FLOATING_POINT LBRAC RBRAC
1496 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1497 $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
1498 $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
1500 | FLOATING_POINT LBRAC ctf_assignment_expression_list RBRAC
1502 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1503 $$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
1504 $$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
1505 if (set_parent_node($3, $$->u.type_specifier.node))
1506 reparent_error(scanner, "floating point reparent error");
1508 | INTEGER LBRAC RBRAC
1510 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1511 $$->u.type_specifier.type = TYPESPEC_INTEGER;
1512 $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
1514 | INTEGER LBRAC ctf_assignment_expression_list RBRAC
1516 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1517 $$->u.type_specifier.type = TYPESPEC_INTEGER;
1518 $$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
1519 if (set_parent_node($3, $$->u.type_specifier.node))
1520 reparent_error(scanner, "integer reparent error");
1524 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1525 $$->u.type_specifier.type = TYPESPEC_STRING;
1526 $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
1528 | STRING LBRAC RBRAC
1530 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1531 $$->u.type_specifier.type = TYPESPEC_STRING;
1532 $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
1534 | STRING LBRAC ctf_assignment_expression_list RBRAC
1536 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1537 $$->u.type_specifier.type = TYPESPEC_STRING;
1538 $$->u.type_specifier.node = make_node(scanner, NODE_STRING);
1539 if (set_parent_node($3, $$->u.type_specifier.node))
1540 reparent_error(scanner, "string reparent error");
1542 | ENUM enum_type_specifier
1544 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1545 $$->u.type_specifier.type = TYPESPEC_ENUM;
1546 $$->u.type_specifier.node = $2;
1548 | VARIANT variant_type_specifier
1550 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1551 $$->u.type_specifier.type = TYPESPEC_VARIANT;
1552 $$->u.type_specifier.node = $2;
1554 | STRUCT struct_type_specifier
1556 $$ = make_node(scanner, NODE_TYPE_SPECIFIER);
1557 $$->u.type_specifier.type = TYPESPEC_STRUCT;
1558 $$->u.type_specifier.node = $2;
1562 struct_type_specifier:
1563 struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end
1565 $$ = make_node(scanner, NODE_STRUCT);
1566 $$->u._struct.has_body = 1;
1567 if ($2 && set_parent_node($2, $$))
1568 reparent_error(scanner, "struct reparent error");
1570 | IDENTIFIER struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end
1572 $$ = make_node(scanner, NODE_STRUCT);
1573 $$->u._struct.has_body = 1;
1574 $$->u._struct.name = $1->s;
1575 if ($3 && set_parent_node($3, $$))
1576 reparent_error(scanner, "struct reparent error");
1578 | ID_TYPE struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end
1580 $$ = make_node(scanner, NODE_STRUCT);
1581 $$->u._struct.has_body = 1;
1582 $$->u._struct.name = $1->s;
1583 if ($3 && set_parent_node($3, $$))
1584 reparent_error(scanner, "struct reparent error");
1588 $$ = make_node(scanner, NODE_STRUCT);
1589 $$->u._struct.has_body = 0;
1590 $$->u._struct.name = $1->s;
1594 $$ = make_node(scanner, NODE_STRUCT);
1595 $$->u._struct.has_body = 0;
1596 $$->u._struct.name = $1->s;
1600 struct_declaration_begin:
1602 { push_scope(scanner); }
1605 struct_declaration_end:
1607 { pop_scope(scanner); }
1610 variant_type_specifier:
1611 variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1613 $$ = make_node(scanner, NODE_VARIANT);
1614 $$->u.variant.has_body = 1;
1615 if ($2 && set_parent_node($2, $$))
1616 reparent_error(scanner, "variant reparent error");
1618 | LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1620 $$ = make_node(scanner, NODE_VARIANT);
1621 $$->u.variant.has_body = 1;
1622 $$->u.variant.choice = $2->s;
1623 if ($5 && set_parent_node($5, $$))
1624 reparent_error(scanner, "variant reparent error");
1626 | LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1628 $$ = make_node(scanner, NODE_VARIANT);
1629 $$->u.variant.has_body = 1;
1630 $$->u.variant.choice = $2->s;
1631 if ($5 && set_parent_node($5, $$))
1632 reparent_error(scanner, "variant reparent error");
1634 | IDENTIFIER variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1636 $$ = make_node(scanner, NODE_VARIANT);
1637 $$->u.variant.has_body = 1;
1638 $$->u.variant.name = $1->s;
1639 if ($3 && set_parent_node($3, $$))
1640 reparent_error(scanner, "variant reparent error");
1642 | IDENTIFIER LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1644 $$ = make_node(scanner, NODE_VARIANT);
1645 $$->u.variant.has_body = 1;
1646 $$->u.variant.name = $1->s;
1647 $$->u.variant.choice = $3->s;
1648 if ($6 && set_parent_node($6, $$))
1649 reparent_error(scanner, "variant reparent error");
1651 | IDENTIFIER LT IDENTIFIER GT
1653 $$ = make_node(scanner, NODE_VARIANT);
1654 $$->u.variant.has_body = 0;
1655 $$->u.variant.name = $1->s;
1656 $$->u.variant.choice = $3->s;
1658 | IDENTIFIER LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1660 $$ = make_node(scanner, NODE_VARIANT);
1661 $$->u.variant.has_body = 1;
1662 $$->u.variant.name = $1->s;
1663 $$->u.variant.choice = $3->s;
1664 if ($6 && set_parent_node($6, $$))
1665 reparent_error(scanner, "variant reparent error");
1667 | IDENTIFIER LT ID_TYPE GT
1669 $$ = make_node(scanner, NODE_VARIANT);
1670 $$->u.variant.has_body = 0;
1671 $$->u.variant.name = $1->s;
1672 $$->u.variant.choice = $3->s;
1674 | ID_TYPE variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1676 $$ = make_node(scanner, NODE_VARIANT);
1677 $$->u.variant.has_body = 1;
1678 $$->u.variant.name = $1->s;
1679 if ($3 && set_parent_node($3, $$))
1680 reparent_error(scanner, "variant reparent error");
1682 | ID_TYPE LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1684 $$ = make_node(scanner, NODE_VARIANT);
1685 $$->u.variant.has_body = 1;
1686 $$->u.variant.name = $1->s;
1687 $$->u.variant.choice = $3->s;
1688 if ($6 && set_parent_node($6, $$))
1689 reparent_error(scanner, "variant reparent error");
1691 | ID_TYPE LT IDENTIFIER GT
1693 $$ = make_node(scanner, NODE_VARIANT);
1694 $$->u.variant.has_body = 0;
1695 $$->u.variant.name = $1->s;
1696 $$->u.variant.choice = $3->s;
1698 | ID_TYPE LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
1700 $$ = make_node(scanner, NODE_VARIANT);
1701 $$->u.variant.has_body = 1;
1702 $$->u.variant.name = $1->s;
1703 $$->u.variant.choice = $3->s;
1704 if ($6 && set_parent_node($6, $$))
1705 reparent_error(scanner, "variant reparent error");
1707 | ID_TYPE LT ID_TYPE GT
1709 $$ = make_node(scanner, NODE_VARIANT);
1710 $$->u.variant.has_body = 0;
1711 $$->u.variant.name = $1->s;
1712 $$->u.variant.choice = $3->s;
1716 variant_declaration_begin:
1718 { push_scope(scanner); }
1721 variant_declaration_end:
1723 { pop_scope(scanner); }
1726 declaration_specifiers_or_integer_constant:
1727 declaration_specifiers
1731 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1732 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1733 sscanf(yylval.gs->s, "%" PRIu64,
1734 &$$->u.unary_expression.u.unsigned_constant);
1738 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1739 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1740 sscanf(yylval.gs->s, "0%" PRIo64,
1741 &$$->u.unary_expression.u.unsigned_constant);
1743 | HEXADECIMAL_CONSTANT
1745 $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
1746 $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
1747 sscanf(yylval.gs->s, "0x%" PRIx64,
1748 &$$->u.unary_expression.u.unsigned_constant);
1752 enum_type_specifier:
1753 LBRAC enumerator_list RBRAC
1755 $$ = make_node(scanner, NODE_ENUM);
1756 $$->u._enum.has_body = 1;
1757 _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list);
1759 | COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
1761 $$ = make_node(scanner, NODE_ENUM);
1762 $$->u._enum.has_body = 1;
1763 ($$)->u._enum.container_type = $2;
1764 _cds_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
1766 | IDENTIFIER LBRAC enumerator_list RBRAC
1768 $$ = make_node(scanner, NODE_ENUM);
1769 $$->u._enum.has_body = 1;
1770 $$->u._enum.enum_id = $1->s;
1771 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
1773 | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
1775 $$ = make_node(scanner, NODE_ENUM);
1776 $$->u._enum.has_body = 1;
1777 $$->u._enum.enum_id = $1->s;
1778 ($$)->u._enum.container_type = $3;
1779 _cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
1781 | ID_TYPE LBRAC enumerator_list RBRAC
1783 $$ = make_node(scanner, NODE_ENUM);
1784 $$->u._enum.has_body = 1;
1785 $$->u._enum.enum_id = $1->s;
1786 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
1788 | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
1790 $$ = make_node(scanner, NODE_ENUM);
1791 $$->u._enum.has_body = 1;
1792 $$->u._enum.enum_id = $1->s;
1793 ($$)->u._enum.container_type = $3;
1794 _cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
1796 | LBRAC enumerator_list COMMA RBRAC
1798 $$ = make_node(scanner, NODE_ENUM);
1799 $$->u._enum.has_body = 1;
1800 _cds_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list);
1802 | COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
1804 $$ = make_node(scanner, NODE_ENUM);
1805 $$->u._enum.has_body = 1;
1806 ($$)->u._enum.container_type = $2;
1807 _cds_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
1809 | IDENTIFIER LBRAC enumerator_list COMMA RBRAC
1811 $$ = make_node(scanner, NODE_ENUM);
1812 $$->u._enum.has_body = 1;
1813 $$->u._enum.enum_id = $1->s;
1814 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
1816 | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
1818 $$ = make_node(scanner, NODE_ENUM);
1819 $$->u._enum.has_body = 1;
1820 $$->u._enum.enum_id = $1->s;
1821 ($$)->u._enum.container_type = $3;
1822 _cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
1826 $$ = make_node(scanner, NODE_ENUM);
1827 $$->u._enum.has_body = 0;
1828 $$->u._enum.enum_id = $1->s;
1830 | ID_TYPE LBRAC enumerator_list COMMA RBRAC
1832 $$ = make_node(scanner, NODE_ENUM);
1833 $$->u._enum.has_body = 1;
1834 $$->u._enum.enum_id = $1->s;
1835 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
1837 | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
1839 $$ = make_node(scanner, NODE_ENUM);
1840 $$->u._enum.has_body = 1;
1841 $$->u._enum.enum_id = $1->s;
1842 ($$)->u._enum.container_type = $3;
1843 _cds_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
1847 $$ = make_node(scanner, NODE_ENUM);
1848 $$->u._enum.has_body = 0;
1849 $$->u._enum.enum_id = $1->s;
1853 struct_or_variant_declaration_list:
1856 | struct_or_variant_declaration_list struct_or_variant_declaration
1860 cds_list_add_tail(&($2)->siblings, &($$)->tmp_head);
1863 cds_list_add_tail(&($$)->siblings, &($$)->tmp_head);
1868 struct_or_variant_declaration:
1869 declaration_specifiers struct_or_variant_declarator_list SEMICOLON
1871 struct ctf_node *list;
1873 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1874 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1875 $$ = make_node(scanner, NODE_STRUCT_OR_VARIANT_DECLARATION);
1876 ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
1877 _cds_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.type_declarators);
1879 | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
1881 struct ctf_node *list;
1883 $$ = make_node(scanner, NODE_TYPEDEF);
1884 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1885 $$->u._typedef.type_specifier_list = list;
1886 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1887 _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1888 _cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
1890 | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
1892 struct ctf_node *list;
1894 $$ = make_node(scanner, NODE_TYPEDEF);
1895 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1896 $$->u._typedef.type_specifier_list = list;
1897 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1898 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
1900 | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
1902 struct ctf_node *list;
1904 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1905 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1906 $$ = make_node(scanner, NODE_TYPEDEF);
1907 ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
1908 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
1910 | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
1912 struct ctf_node *list;
1914 $$ = make_node(scanner, NODE_TYPEALIAS);
1915 $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
1916 $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
1918 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1919 $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
1920 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1921 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
1923 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1924 $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
1925 _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
1926 _cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);
1930 alias_declaration_specifiers:
1933 struct ctf_node *node;
1935 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1936 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1937 node->u.type_specifier.type = TYPESPEC_CONST;
1938 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1942 struct ctf_node *node;
1944 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1946 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1950 struct ctf_node *node;
1952 add_type(scanner, $1);
1953 $$ = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
1954 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1955 node->u.type_specifier.type = TYPESPEC_ID_TYPE;
1956 node->u.type_specifier.id_type = yylval.gs->s;
1957 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1959 | alias_declaration_specifiers CONST
1961 struct ctf_node *node;
1964 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1965 node->u.type_specifier.type = TYPESPEC_CONST;
1966 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1968 | alias_declaration_specifiers type_specifier
1971 cds_list_add_tail(&($2)->siblings, &($$)->u.type_specifier_list.head);
1973 | alias_declaration_specifiers IDENTIFIER
1975 struct ctf_node *node;
1977 add_type(scanner, $2);
1979 node = make_node(scanner, NODE_TYPE_SPECIFIER);
1980 node->u.type_specifier.type = TYPESPEC_ID_TYPE;
1981 node->u.type_specifier.id_type = yylval.gs->s;
1982 cds_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
1986 struct_or_variant_declarator_list:
1987 struct_or_variant_declarator
1989 | struct_or_variant_declarator_list COMMA struct_or_variant_declarator
1992 cds_list_add_tail(&($3)->siblings, &($$)->tmp_head);
1996 struct_or_variant_declarator:
1999 | COLON unary_expression
2001 | declarator COLON unary_expression
2004 if (set_parent_node($3, $1))
2005 reparent_error(scanner, "struct_or_variant_declarator");
2012 | enumerator_list COMMA enumerator
2015 cds_list_add_tail(&($3)->siblings, &($$)->tmp_head);
2022 $$ = make_node(scanner, NODE_ENUMERATOR);
2023 $$->u.enumerator.id = $1->s;
2027 $$ = make_node(scanner, NODE_ENUMERATOR);
2028 $$->u.enumerator.id = $1->s;
2032 $$ = make_node(scanner, NODE_ENUMERATOR);
2033 $$->u.enumerator.id = $1->s;
2035 | STRING_LITERAL_START DQUOTE
2037 $$ = make_node(scanner, NODE_ENUMERATOR);
2038 $$->u.enumerator.id = "";
2040 | STRING_LITERAL_START s_char_sequence DQUOTE
2042 $$ = make_node(scanner, NODE_ENUMERATOR);
2043 $$->u.enumerator.id = $2->s;
2045 | IDENTIFIER EQUAL unary_expression_or_range
2047 $$ = make_node(scanner, NODE_ENUMERATOR);
2048 $$->u.enumerator.id = $1->s;
2049 cds_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
2051 | ID_TYPE EQUAL unary_expression_or_range
2053 $$ = make_node(scanner, NODE_ENUMERATOR);
2054 $$->u.enumerator.id = $1->s;
2055 cds_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
2057 | keywords EQUAL unary_expression_or_range
2059 $$ = make_node(scanner, NODE_ENUMERATOR);
2060 $$->u.enumerator.id = $1->s;
2061 cds_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
2063 | STRING_LITERAL_START DQUOTE EQUAL unary_expression_or_range
2065 $$ = make_node(scanner, NODE_ENUMERATOR);
2066 $$->u.enumerator.id = "";
2067 cds_list_splice(&($4)->tmp_head, &($$)->u.enumerator.values);
2069 | STRING_LITERAL_START s_char_sequence DQUOTE EQUAL unary_expression_or_range
2071 $$ = make_node(scanner, NODE_ENUMERATOR);
2072 $$->u.enumerator.id = $2->s;
2073 cds_list_splice(&($5)->tmp_head, &($$)->u.enumerator.values);
2077 abstract_declarator_list:
2080 | abstract_declarator_list COMMA abstract_declarator
2083 cds_list_add_tail(&($3)->siblings, &($$)->tmp_head);
2087 abstract_declarator:
2088 direct_abstract_declarator
2090 | pointer direct_abstract_declarator
2093 cds_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
2097 direct_abstract_declarator:
2100 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2101 $$->u.type_declarator.type = TYPEDEC_ID;
2106 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2107 $$->u.type_declarator.type = TYPEDEC_ID;
2108 $$->u.type_declarator.u.id = $1->s;
2110 | LPAREN abstract_declarator RPAREN
2112 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2113 $$->u.type_declarator.type = TYPEDEC_NESTED;
2114 $$->u.type_declarator.u.nested.type_declarator = $2;
2116 | direct_abstract_declarator LSBRAC declaration_specifiers_or_integer_constant RSBRAC
2118 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2119 $$->u.type_declarator.type = TYPEDEC_NESTED;
2120 $$->u.type_declarator.u.nested.type_declarator = $1;
2121 ($$)->u.type_declarator.u.nested.length = $3;
2123 | direct_abstract_declarator LSBRAC RSBRAC
2125 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2126 $$->u.type_declarator.type = TYPEDEC_NESTED;
2127 $$->u.type_declarator.u.nested.type_declarator = $1;
2128 $$->u.type_declarator.u.nested.abstract_array = 1;
2132 alias_abstract_declarator_list:
2133 alias_abstract_declarator
2135 | alias_abstract_declarator_list COMMA alias_abstract_declarator
2138 cds_list_add_tail(&($3)->siblings, &($$)->tmp_head);
2142 alias_abstract_declarator:
2143 direct_alias_abstract_declarator
2145 | pointer direct_alias_abstract_declarator
2148 cds_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
2152 direct_alias_abstract_declarator:
2155 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2156 $$->u.type_declarator.type = TYPEDEC_ID;
2159 | LPAREN alias_abstract_declarator RPAREN
2161 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2162 $$->u.type_declarator.type = TYPEDEC_NESTED;
2163 $$->u.type_declarator.u.nested.type_declarator = $2;
2165 | direct_alias_abstract_declarator LSBRAC declaration_specifiers_or_integer_constant RSBRAC
2167 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2168 $$->u.type_declarator.type = TYPEDEC_NESTED;
2169 $$->u.type_declarator.u.nested.type_declarator = $1;
2170 ($$)->u.type_declarator.u.nested.length = $3;
2172 | direct_alias_abstract_declarator LSBRAC RSBRAC
2174 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2175 $$->u.type_declarator.type = TYPEDEC_NESTED;
2176 $$->u.type_declarator.u.nested.type_declarator = $1;
2177 $$->u.type_declarator.u.nested.abstract_array = 1;
2184 | pointer direct_declarator
2187 cds_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
2194 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2195 $$->u.type_declarator.type = TYPEDEC_ID;
2196 $$->u.type_declarator.u.id = $1->s;
2198 | LPAREN declarator RPAREN
2200 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2201 $$->u.type_declarator.type = TYPEDEC_NESTED;
2202 $$->u.type_declarator.u.nested.type_declarator = $2;
2204 | direct_declarator LSBRAC declaration_specifiers_or_integer_constant RSBRAC
2206 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2207 $$->u.type_declarator.type = TYPEDEC_NESTED;
2208 $$->u.type_declarator.u.nested.type_declarator = $1;
2209 ($$)->u.type_declarator.u.nested.length = $3;
2214 direct_type_declarator
2216 | pointer direct_type_declarator
2219 cds_list_splice(&($1)->tmp_head, &($$)->u.type_declarator.pointers);
2223 direct_type_declarator:
2226 add_type(scanner, $1);
2227 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2228 $$->u.type_declarator.type = TYPEDEC_ID;
2229 $$->u.type_declarator.u.id = $1->s;
2231 | LPAREN type_declarator RPAREN
2233 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2234 $$->u.type_declarator.type = TYPEDEC_NESTED;
2235 $$->u.type_declarator.u.nested.type_declarator = $2;
2237 | direct_type_declarator LSBRAC declaration_specifiers_or_integer_constant RSBRAC
2239 $$ = make_node(scanner, NODE_TYPE_DECLARATOR);
2240 $$->u.type_declarator.type = TYPEDEC_NESTED;
2241 $$->u.type_declarator.u.nested.type_declarator = $1;
2242 ($$)->u.type_declarator.u.nested.length = $3;
2249 $$ = make_node(scanner, NODE_POINTER);
2253 $$ = make_node(scanner, NODE_POINTER);
2254 cds_list_splice(&($2)->tmp_head, &($$)->tmp_head);
2256 | STAR type_qualifier_list pointer
2258 $$ = make_node(scanner, NODE_POINTER);
2259 $$->u.pointer.const_qualifier = 1;
2260 cds_list_splice(&($3)->tmp_head, &($$)->tmp_head);
2264 type_qualifier_list:
2265 /* pointer assumes only const type qualifier */
2267 | type_qualifier_list CONST
2270 /* 2.3: CTF-specific declarations */
2272 ctf_assignment_expression_list:
2273 ctf_assignment_expression SEMICOLON
2275 | ctf_assignment_expression_list ctf_assignment_expression SEMICOLON
2278 cds_list_add_tail(&($2)->siblings, &($$)->tmp_head);
2282 ctf_assignment_expression:
2283 unary_expression EQUAL unary_expression
2286 * Because we have left and right, cannot use
2289 $$ = make_node(scanner, NODE_CTF_EXPRESSION);
2290 _cds_list_splice_tail(&($1)->tmp_head, &($$)->u.ctf_expression.left);
2291 if ($1->u.unary_expression.type != UNARY_STRING)
2292 reparent_error(scanner, "ctf_assignment_expression left expects string");
2293 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.ctf_expression.right);
2295 | unary_expression TYPEASSIGN declaration_specifiers /* Only allow struct */
2298 * Because we have left and right, cannot use
2301 $$ = make_node(scanner, NODE_CTF_EXPRESSION);
2302 _cds_list_splice_tail(&($1)->tmp_head, &($$)->u.ctf_expression.left);
2303 if ($1->u.unary_expression.type != UNARY_STRING)
2304 reparent_error(scanner, "ctf_assignment_expression left expects string");
2305 cds_list_add_tail(&($3)->siblings, &($$)->u.ctf_expression.right);
2307 | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list
2309 struct ctf_node *list;
2311 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
2312 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2313 _cds_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2314 $$ = make_node(scanner, NODE_TYPEDEF);
2315 ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
2316 _cds_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
2318 | TYPEDEF declaration_specifiers type_declarator_list
2320 struct ctf_node *list;
2322 $$ = make_node(scanner, NODE_TYPEDEF);
2323 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
2324 $$->u._typedef.type_specifier_list = list;
2325 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2326 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
2328 | declaration_specifiers TYPEDEF type_declarator_list
2330 struct ctf_node *list;
2332 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
2333 _cds_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2334 $$ = make_node(scanner, NODE_TYPEDEF);
2335 ($$)->u.struct_or_variant_declaration.type_specifier_list = list;
2336 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
2338 | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list
2340 struct ctf_node *list;
2342 $$ = make_node(scanner, NODE_TYPEALIAS);
2343 $$->u.typealias.target = make_node(scanner, NODE_TYPEALIAS_TARGET);
2344 $$->u.typealias.alias = make_node(scanner, NODE_TYPEALIAS_ALIAS);
2346 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
2347 $$->u.typealias.target->u.typealias_target.type_specifier_list = list;
2348 _cds_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2349 _cds_list_splice_tail(&($3)->tmp_head, &($$)->u.typealias.target->u.typealias_target.type_declarators);
2351 list = make_node(scanner, NODE_TYPE_SPECIFIER_LIST);
2352 $$->u.typealias.alias->u.typealias_alias.type_specifier_list = list;
2353 _cds_list_splice_tail(&($5)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
2354 _cds_list_splice_tail(&($6)->tmp_head, &($$)->u.typealias.alias->u.typealias_alias.type_declarators);