6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
8 * with the License.
9 *
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
14 *
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 *
21 * CDDL HEADER END
22 *
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <dt_impl.h>
30
31 #define OP1(op, c) dt_node_op1(op, c)
32 #define OP2(op, l, r) dt_node_op2(op, l, r)
33 #define OP3(x, y, z) dt_node_op3(x, y, z)
34 #define LINK(l, r) dt_node_link(l, r)
35 #define DUP(s) strdup(s)
36
37 %}
38
39 %union {
40 dt_node_t *l_node;
41 dt_decl_t *l_decl;
42 char *l_str;
43 uintmax_t l_int;
44 int l_tok;
45 }
46
47 %token DT_TOK_COMMA DT_TOK_ELLIPSIS
85 %token DT_KEY_IMPORT
86 %token DT_KEY_INLINE
87 %token DT_KEY_INT
88 %token DT_KEY_LONG
89 %token DT_KEY_PROBE
90 %token DT_KEY_PROVIDER
91 %token DT_KEY_REGISTER
92 %token DT_KEY_RESTRICT
93 %token DT_KEY_RETURN
94 %token DT_KEY_SELF
95 %token DT_KEY_SHORT
96 %token DT_KEY_SIGNED
97 %token DT_KEY_STATIC
98 %token DT_KEY_STRING
99 %token DT_KEY_STRUCT
100 %token DT_KEY_SWITCH
101 %token DT_KEY_THIS
102 %token DT_KEY_TYPEDEF
103 %token DT_KEY_UNION
104 %token DT_KEY_UNSIGNED
105 %token DT_KEY_VOID
106 %token DT_KEY_VOLATILE
107 %token DT_KEY_WHILE
108 %token DT_KEY_XLATOR
109
110 %token DT_TOK_EPRED
111 %token DT_CTX_DEXPR
112 %token DT_CTX_DPROG
113 %token DT_CTX_DTYPE
114 %token DT_TOK_EOF 0
115
116 %left DT_TOK_COMMA
117 %right DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ DT_TOK_DIV_EQ
118 DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ DT_TOK_LSH_EQ
119 DT_TOK_RSH_EQ
120 %left DT_TOK_QUESTION DT_TOK_COLON
121 %left DT_TOK_LOR
122 %left DT_TOK_LXOR
123 %left DT_TOK_LAND
124 %left DT_TOK_BOR
616 | DT_KEY_STATIC { dt_decl_class(DT_DC_STATIC); }
617 | DT_KEY_EXTERN { dt_decl_class(DT_DC_EXTERN); }
618 | DT_KEY_TYPEDEF { dt_decl_class(DT_DC_TYPEDEF); }
619 ;
620
621 d_storage_class_specifier:
622 storage_class_specifier
623 | DT_KEY_SELF { dt_decl_class(DT_DC_SELF); }
624 | DT_KEY_THIS { dt_decl_class(DT_DC_THIS); }
625 ;
626
627 type_specifier: DT_KEY_VOID { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("void")); }
628 | DT_KEY_CHAR { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("char")); }
629 | DT_KEY_SHORT { $$ = dt_decl_attr(DT_DA_SHORT); }
630 | DT_KEY_INT { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("int")); }
631 | DT_KEY_LONG { $$ = dt_decl_attr(DT_DA_LONG); }
632 | DT_KEY_FLOAT { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("float")); }
633 | DT_KEY_DOUBLE { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("double")); }
634 | DT_KEY_SIGNED { $$ = dt_decl_attr(DT_DA_SIGNED); }
635 | DT_KEY_UNSIGNED { $$ = dt_decl_attr(DT_DA_UNSIGNED); }
636 | DT_KEY_STRING {
637 $$ = dt_decl_spec(CTF_K_TYPEDEF, DUP("string"));
638 }
639 | DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_TYPEDEF, $1); }
640 | struct_or_union_specifier
641 | enum_specifier
642 ;
643
644 type_qualifier: DT_KEY_CONST { $$ = dt_decl_attr(DT_DA_CONST); }
645 | DT_KEY_RESTRICT { $$ = dt_decl_attr(DT_DA_RESTRICT); }
646 | DT_KEY_VOLATILE { $$ = dt_decl_attr(DT_DA_VOLATILE); }
647 ;
648
649 struct_or_union_specifier:
650 struct_or_union_definition struct_declaration_list '}' {
651 $$ = dt_scope_pop();
652 }
653 | struct_or_union DT_TOK_IDENT { $$ = dt_decl_spec($1, $2); }
654 | struct_or_union DT_TOK_TNAME { $$ = dt_decl_spec($1, $2); }
655 ;
|
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
8 * with the License.
9 *
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
14 *
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 *
21 * CDDL HEADER END
22 *
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright (c) 2013 by Delphix. All rights reserved.
28 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
29 */
30
31 #include <dt_impl.h>
32
33 #define OP1(op, c) dt_node_op1(op, c)
34 #define OP2(op, l, r) dt_node_op2(op, l, r)
35 #define OP3(x, y, z) dt_node_op3(x, y, z)
36 #define LINK(l, r) dt_node_link(l, r)
37 #define DUP(s) strdup(s)
38
39 %}
40
41 %union {
42 dt_node_t *l_node;
43 dt_decl_t *l_decl;
44 char *l_str;
45 uintmax_t l_int;
46 int l_tok;
47 }
48
49 %token DT_TOK_COMMA DT_TOK_ELLIPSIS
87 %token DT_KEY_IMPORT
88 %token DT_KEY_INLINE
89 %token DT_KEY_INT
90 %token DT_KEY_LONG
91 %token DT_KEY_PROBE
92 %token DT_KEY_PROVIDER
93 %token DT_KEY_REGISTER
94 %token DT_KEY_RESTRICT
95 %token DT_KEY_RETURN
96 %token DT_KEY_SELF
97 %token DT_KEY_SHORT
98 %token DT_KEY_SIGNED
99 %token DT_KEY_STATIC
100 %token DT_KEY_STRING
101 %token DT_KEY_STRUCT
102 %token DT_KEY_SWITCH
103 %token DT_KEY_THIS
104 %token DT_KEY_TYPEDEF
105 %token DT_KEY_UNION
106 %token DT_KEY_UNSIGNED
107 %token DT_KEY_USERLAND
108 %token DT_KEY_VOID
109 %token DT_KEY_VOLATILE
110 %token DT_KEY_WHILE
111 %token DT_KEY_XLATOR
112
113 %token DT_TOK_EPRED
114 %token DT_CTX_DEXPR
115 %token DT_CTX_DPROG
116 %token DT_CTX_DTYPE
117 %token DT_TOK_EOF 0
118
119 %left DT_TOK_COMMA
120 %right DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ DT_TOK_DIV_EQ
121 DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ DT_TOK_LSH_EQ
122 DT_TOK_RSH_EQ
123 %left DT_TOK_QUESTION DT_TOK_COLON
124 %left DT_TOK_LOR
125 %left DT_TOK_LXOR
126 %left DT_TOK_LAND
127 %left DT_TOK_BOR
619 | DT_KEY_STATIC { dt_decl_class(DT_DC_STATIC); }
620 | DT_KEY_EXTERN { dt_decl_class(DT_DC_EXTERN); }
621 | DT_KEY_TYPEDEF { dt_decl_class(DT_DC_TYPEDEF); }
622 ;
623
624 d_storage_class_specifier:
625 storage_class_specifier
626 | DT_KEY_SELF { dt_decl_class(DT_DC_SELF); }
627 | DT_KEY_THIS { dt_decl_class(DT_DC_THIS); }
628 ;
629
630 type_specifier: DT_KEY_VOID { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("void")); }
631 | DT_KEY_CHAR { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("char")); }
632 | DT_KEY_SHORT { $$ = dt_decl_attr(DT_DA_SHORT); }
633 | DT_KEY_INT { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("int")); }
634 | DT_KEY_LONG { $$ = dt_decl_attr(DT_DA_LONG); }
635 | DT_KEY_FLOAT { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("float")); }
636 | DT_KEY_DOUBLE { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("double")); }
637 | DT_KEY_SIGNED { $$ = dt_decl_attr(DT_DA_SIGNED); }
638 | DT_KEY_UNSIGNED { $$ = dt_decl_attr(DT_DA_UNSIGNED); }
639 | DT_KEY_USERLAND { $$ = dt_decl_attr(DT_DA_USER); }
640 | DT_KEY_STRING {
641 $$ = dt_decl_spec(CTF_K_TYPEDEF, DUP("string"));
642 }
643 | DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_TYPEDEF, $1); }
644 | struct_or_union_specifier
645 | enum_specifier
646 ;
647
648 type_qualifier: DT_KEY_CONST { $$ = dt_decl_attr(DT_DA_CONST); }
649 | DT_KEY_RESTRICT { $$ = dt_decl_attr(DT_DA_RESTRICT); }
650 | DT_KEY_VOLATILE { $$ = dt_decl_attr(DT_DA_VOLATILE); }
651 ;
652
653 struct_or_union_specifier:
654 struct_or_union_definition struct_declaration_list '}' {
655 $$ = dt_scope_pop();
656 }
657 | struct_or_union DT_TOK_IDENT { $$ = dt_decl_spec($1, $2); }
658 | struct_or_union DT_TOK_TNAME { $$ = dt_decl_spec($1, $2); }
659 ;
|