5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
30 typedef
struct node
*node_ptr
;
31 #define YYSTYPE node_ptr
35 %token STRUCT_KW UNION_KW TYPEDEF_KW
38 %token ALIGN_KW OPERATION_KW IN_KW OUT_KW
39 %token INTERFACE_KW UUID_KW _NO_REORDER_KW EXTERN_KW
40 %token SIZE_IS_KW LENGTH_IS_KW STRING_KW REFERENCE_KW
41 %token CASE_KW DEFAULT_KW SWITCH_IS_KW
42 %token TRANSMIT_AS_KW ARG_IS_KW
44 /* composite keywords */
45 %token BASIC_TYPE TYPENAME
47 /* symbols and punctuation */
48 %token IDENTIFIER INTEGER STRING
49 %token LC RC SEMI STAR DIV MOD PLUS MINUS AND OR XOR LB RB LP RP
58 | construct_list
={ construct_list
= (struct node
*)$1; }
61 construct_list: construct
62 | construct_list construct
={ n_splice
($1,$2); }
70 struct : advice STRUCT_KW typename LC members RC SEMI
71 ={ $$
= n_cons
(STRUCT_KW
, $1, $3, $5);
76 union : advice UNION_KW typename LC members RC SEMI
77 ={ $$
= n_cons
(UNION_KW
, $1, $3, $5);
82 typedef
: TYPEDEF_KW member
83 ={ $$
= n_cons
(TYPEDEF_KW
, 0, $2->n_m_name
, $2);
89 | members member
={ n_splice
($1,$2); }
92 member
: advice type declarator SEMI
93 ={ $$
= n_cons
(L_MEMBER
, $1, $2, $3);
98 advice
: /* empty */ ={ $$
= 0; }
102 adv_list: LB adv_attrs RB
={ $$
= $2; }
103 | adv_list LB adv_attrs RB
={ n_splice
($1,$3); }
107 | adv_attr adv_attr
={ n_splice
($1,$2); }
110 adv_attr: IN_KW
={ $$
= n_cons
(IN_KW
); }
111 | OUT_KW
={ $$
= n_cons
(OUT_KW
); }
112 | OPERATION_KW LP arg RP
={ $$
= n_cons
(OPERATION_KW
, $3); }
113 | ALIGN_KW LP arg RP
={ $$
= n_cons
(ALIGN_KW
, $3); }
114 | STRING_KW
={ $$
= n_cons
(STRING_KW
); }
116 | SIZE_IS_KW LP arg RP
117 ={ $$
= n_cons
(SIZE_IS_KW
, $3, $3, $3); }
118 | SIZE_IS_KW LP arg operator INTEGER RP
119 ={ $$
= n_cons
(SIZE_IS_KW
, $3, $4, $5); }
121 | LENGTH_IS_KW LP arg RP
122 ={ $$
= n_cons
(LENGTH_IS_KW
, $3, $3, $3); }
123 | LENGTH_IS_KW LP arg operator INTEGER RP
124 ={ $$
= n_cons
(LENGTH_IS_KW
, $3, $4, $5); }
126 | SWITCH_IS_KW LP arg RP
127 ={ $$
= n_cons
(SWITCH_IS_KW
, $3, $3, $3); }
128 | SWITCH_IS_KW LP arg operator INTEGER RP
129 ={ $$
= n_cons
(SWITCH_IS_KW
, $3, $4, $5); }
131 | CASE_KW LP arg RP
={ $$
= n_cons
(CASE_KW
, $3); }
132 | DEFAULT_KW
={ $$
= n_cons
(DEFAULT_KW
); }
134 | ARG_IS_KW LP arg RP
={ $$
= n_cons
(ARG_IS_KW
, $3); }
135 | TRANSMIT_AS_KW LP BASIC_TYPE RP
136 ={ $$
= n_cons
(TRANSMIT_AS_KW
, $3); }
138 | INTERFACE_KW LP arg RP
={ $$
= n_cons
(INTERFACE_KW
, $3); }
139 | UUID_KW LP arg RP
={ $$
= n_cons
(UUID_KW
, $3); }
140 | _NO_REORDER_KW
={ $$
= n_cons
(_NO_REORDER_KW
); }
141 | EXTERN_KW
={ $$
= n_cons
(EXTERN_KW
); }
142 | REFERENCE_KW
={ $$
= n_cons
(REFERENCE_KW
); }
152 | STRUCT_KW typename
={ $$
= $2; }
153 | UNION_KW typename
={ $$
= $2; }
174 | STAR decl1
={ $$
= n_cons
(STAR
, $2); }
178 | decl3 LB RB
={ $$
= n_cons
(LB
, $1, 0); }
179 | decl3 LB STAR RB
={ $$
= n_cons
(LB
, $1, 0); }
180 | decl3 LB INTEGER RB
={ $$
= n_cons
(LB
, $1, $3); }
184 | LP decl1 RP
={ $$
= n_cons
(LP
, $2); }