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