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