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