8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / tools / ndrgen / ndr_parse.y
blob88de5ace2a17af60d4c474ffd0ebb86152364111
1 %{
2 /*
3 * CDDL HEADER START
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]
20 * CDDL HEADER END
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #include "ndrgen.h"
30 typedef struct node *node_ptr;
31 #define YYSTYPE node_ptr
34 /* keywords */
35 %token STRUCT_KW UNION_KW TYPEDEF_KW
37 /* advice keywords */
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
52 %token L_MEMBER
57 defn : /* empty */
58 | construct_list ={ construct_list = (struct node *)$1; }
61 construct_list: construct
62 | construct_list construct ={ n_splice ($1,$2); }
65 construct: struct
66 | union
67 | typedef
70 struct : advice STRUCT_KW typename LC members RC SEMI
71 ={ $$ = n_cons (STRUCT_KW, $1, $3, $5);
72 construct_fixup ($$);
76 union : advice UNION_KW typename LC members RC SEMI
77 ={ $$ = n_cons (UNION_KW, $1, $3, $5);
78 construct_fixup ($$);
82 typedef : TYPEDEF_KW member
83 ={ $$ = n_cons (TYPEDEF_KW, 0, $2->n_m_name, $2);
84 construct_fixup ($$);
88 members : member
89 | members member ={ n_splice ($1,$2); }
92 member : advice type declarator SEMI
93 ={ $$ = n_cons (L_MEMBER, $1, $2, $3);
94 member_fixup ($$);
98 advice : /* empty */ ={ $$ = 0; }
99 | adv_list
102 adv_list: LB adv_attrs RB ={ $$ = $2; }
103 | adv_list LB adv_attrs RB ={ n_splice ($1,$3); }
106 adv_attrs: adv_attr
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); }
145 arg : IDENTIFIER
146 | INTEGER
147 | STRING
150 type : BASIC_TYPE
151 | typename
152 | STRUCT_KW typename ={ $$ = $2; }
153 | UNION_KW typename ={ $$ = $2; }
156 typename: TYPENAME
157 | IDENTIFIER
160 operator: STAR
161 | DIV
162 | MOD
163 | PLUS
164 | MINUS
165 | AND
166 | OR
167 | XOR
170 declarator: decl1
173 decl1 : decl2
174 | STAR decl1 ={ $$ = n_cons (STAR, $2); }
177 decl2 : decl3
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); }
183 decl3 : IDENTIFIER
184 | LP decl1 RP ={ $$ = n_cons (LP, $2); }