xref: /titanic_50/usr/src/tools/ndrgen/ndr_parse.y (revision a0b6e447978c306e15941d158bf6939a42ed2726)
1d0e51869Samw %{
2d0e51869Samw /*
3d0e51869Samw  * CDDL HEADER START
4d0e51869Samw  *
5d0e51869Samw  * The contents of this file are subject to the terms of the
6d0e51869Samw  * Common Development and Distribution License (the "License").
7d0e51869Samw  * You may not use this file except in compliance with the License.
8d0e51869Samw  *
9d0e51869Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d0e51869Samw  * or http://www.opensolaris.org/os/licensing.
11d0e51869Samw  * See the License for the specific language governing permissions
12d0e51869Samw  * and limitations under the License.
13d0e51869Samw  *
14d0e51869Samw  * When distributing Covered Code, include this CDDL HEADER in each
15d0e51869Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16d0e51869Samw  * If applicable, add the following below this CDDL HEADER, with the
17d0e51869Samw  * fields enclosed by brackets "[]" replaced with your own identifying
18d0e51869Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
19d0e51869Samw  *
20d0e51869Samw  * CDDL HEADER END
21d0e51869Samw  */
22d0e51869Samw 
23d0e51869Samw /*
24*a0b6e447SAlan Wright  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25d0e51869Samw  * Use is subject to license terms.
26d0e51869Samw  */
27d0e51869Samw 
28d0e51869Samw #include "ndrgen.h"
29d0e51869Samw 
30d0e51869Samw typedef struct node *node_ptr;
31d0e51869Samw #define YYSTYPE node_ptr
32d0e51869Samw %}
33d0e51869Samw 
34d0e51869Samw /* keywords */
35d0e51869Samw %token STRUCT_KW UNION_KW TYPEDEF_KW
36d0e51869Samw 
37d0e51869Samw /* advice keywords */
38d0e51869Samw %token ALIGN_KW OPERATION_KW IN_KW OUT_KW
39d0e51869Samw %token INTERFACE_KW UUID_KW _NO_REORDER_KW EXTERN_KW
40d0e51869Samw %token SIZE_IS_KW LENGTH_IS_KW STRING_KW REFERENCE_KW
41d0e51869Samw %token CASE_KW DEFAULT_KW SWITCH_IS_KW
42d0e51869Samw %token TRANSMIT_AS_KW ARG_IS_KW
43d0e51869Samw 
44d0e51869Samw /* composite keywords */
45d0e51869Samw %token BASIC_TYPE TYPENAME
46d0e51869Samw 
47d0e51869Samw /* symbols and punctuation */
48d0e51869Samw %token IDENTIFIER INTEGER STRING
49*a0b6e447SAlan Wright %token LC RC SEMI STAR DIV MOD PLUS MINUS AND OR XOR LB RB LP RP
50d0e51869Samw 
51d0e51869Samw 
52d0e51869Samw %token L_MEMBER
53d0e51869Samw 
54d0e51869Samw 
55d0e51869Samw %%
56d0e51869Samw 
57d0e51869Samw defn	:	/* empty */
58d0e51869Samw 	|	construct_list	={ construct_list = (struct node *)$1; }
59d0e51869Samw 	;
60d0e51869Samw 
61d0e51869Samw construct_list:	construct
62d0e51869Samw 	|	construct_list construct ={ n_splice ($1,$2); }
63d0e51869Samw 	;
64d0e51869Samw 
65d0e51869Samw construct:	struct
66d0e51869Samw 	|	union
67d0e51869Samw 	|	typedef
68d0e51869Samw 	;
69d0e51869Samw 
70d0e51869Samw struct	:	advice STRUCT_KW typename LC members RC SEMI
71d0e51869Samw 		={ $$ = n_cons (STRUCT_KW, $1, $3, $5);
72d0e51869Samw 		   construct_fixup ($$);
73d0e51869Samw 		}
74d0e51869Samw 	;
75d0e51869Samw 
76d0e51869Samw union	:	advice UNION_KW typename LC members RC SEMI
77d0e51869Samw 		={ $$ = n_cons (UNION_KW, $1, $3, $5);
78d0e51869Samw 		   construct_fixup ($$);
79d0e51869Samw 		}
80d0e51869Samw 	;
81d0e51869Samw 
82d0e51869Samw typedef	:	TYPEDEF_KW member
83d0e51869Samw 		={ $$ = n_cons (TYPEDEF_KW, 0, $2->n_m_name, $2);
84d0e51869Samw 		   construct_fixup ($$);
85d0e51869Samw 		}
86d0e51869Samw 	;
87d0e51869Samw 
88d0e51869Samw members	:	member
89d0e51869Samw 	|	members member		 ={ n_splice ($1,$2); }
90d0e51869Samw 	;
91d0e51869Samw 
92d0e51869Samw member	:	advice type declarator SEMI
93d0e51869Samw 		={ $$ = n_cons (L_MEMBER, $1, $2, $3);
94d0e51869Samw 		   member_fixup ($$);
95d0e51869Samw 		}
96d0e51869Samw 	;
97d0e51869Samw 
98d0e51869Samw advice	:	/* empty */		={ $$ = 0; }
99d0e51869Samw 	|	adv_list
100d0e51869Samw 	;
101d0e51869Samw 
102d0e51869Samw adv_list:	LB adv_attrs RB		={ $$ = $2; }
103d0e51869Samw 	|	adv_list LB adv_attrs RB ={ n_splice ($1,$3); }
104d0e51869Samw 	;
105d0e51869Samw 
106d0e51869Samw adv_attrs:	adv_attr
107d0e51869Samw 	|	adv_attr adv_attr	={ n_splice ($1,$2); }
108d0e51869Samw 	;
109d0e51869Samw 
110d0e51869Samw adv_attr:	IN_KW			={ $$ = n_cons (IN_KW); }
111d0e51869Samw 	|	OUT_KW			={ $$ = n_cons (OUT_KW); }
112d0e51869Samw 	|	OPERATION_KW LP arg RP	={ $$ = n_cons (OPERATION_KW, $3); }
113d0e51869Samw 	|	ALIGN_KW LP arg RP	={ $$ = n_cons (ALIGN_KW, $3); }
114d0e51869Samw 	|	STRING_KW		={ $$ = n_cons (STRING_KW); }
115d0e51869Samw 
116*a0b6e447SAlan Wright 	|	SIZE_IS_KW LP arg RP
117*a0b6e447SAlan Wright 				={ $$ = n_cons (SIZE_IS_KW, $3, $3, $3); }
118*a0b6e447SAlan Wright 	|	SIZE_IS_KW LP arg operator INTEGER RP
119*a0b6e447SAlan Wright 				={ $$ = n_cons (SIZE_IS_KW, $3, $4, $5); }
120*a0b6e447SAlan Wright 
121*a0b6e447SAlan Wright 	|	LENGTH_IS_KW LP arg RP
122*a0b6e447SAlan Wright 				={ $$ = n_cons (LENGTH_IS_KW, $3, $3, $3); }
123*a0b6e447SAlan Wright 	|	LENGTH_IS_KW LP arg operator INTEGER RP
124*a0b6e447SAlan Wright 				={ $$ = n_cons (LENGTH_IS_KW, $3, $4, $5); }
125*a0b6e447SAlan Wright 
126*a0b6e447SAlan Wright 	|	SWITCH_IS_KW LP arg RP
127*a0b6e447SAlan Wright 				={ $$ = n_cons (SWITCH_IS_KW, $3, $3, $3); }
128*a0b6e447SAlan Wright 	|	SWITCH_IS_KW LP arg operator INTEGER RP
129*a0b6e447SAlan Wright 				={ $$ = n_cons (SWITCH_IS_KW, $3, $4, $5); }
130*a0b6e447SAlan Wright 
131d0e51869Samw 	|	CASE_KW LP arg RP	={ $$ = n_cons (CASE_KW, $3); }
132d0e51869Samw 	|	DEFAULT_KW		={ $$ = n_cons (DEFAULT_KW); }
133d0e51869Samw 
134d0e51869Samw 	|	ARG_IS_KW LP arg RP	={ $$ = n_cons (ARG_IS_KW, $3); }
135d0e51869Samw 	|	TRANSMIT_AS_KW LP BASIC_TYPE RP
136d0e51869Samw 					={ $$ = n_cons (TRANSMIT_AS_KW, $3); }
137d0e51869Samw 
138d0e51869Samw 	|	INTERFACE_KW LP arg RP	={ $$ = n_cons (INTERFACE_KW, $3); }
139d0e51869Samw 	|	UUID_KW LP arg RP	={ $$ = n_cons (UUID_KW, $3); }
140d0e51869Samw 	|	_NO_REORDER_KW		={ $$ = n_cons (_NO_REORDER_KW); }
141d0e51869Samw 	|	EXTERN_KW		={ $$ = n_cons (EXTERN_KW); }
142d0e51869Samw 	|	REFERENCE_KW		={ $$ = n_cons (REFERENCE_KW); }
143d0e51869Samw 	;
144d0e51869Samw 
145d0e51869Samw arg	:	IDENTIFIER
146d0e51869Samw 	|	INTEGER
147d0e51869Samw 	|	STRING
148d0e51869Samw 	;
149d0e51869Samw 
150d0e51869Samw type	:	BASIC_TYPE
151d0e51869Samw 	|	typename
152d0e51869Samw 	|	STRUCT_KW typename	={ $$ = $2; }
153d0e51869Samw 	|	UNION_KW  typename	={ $$ = $2; }
154d0e51869Samw 	;
155d0e51869Samw 
156d0e51869Samw typename:	TYPENAME
157d0e51869Samw 	|	IDENTIFIER
158d0e51869Samw 	;
159d0e51869Samw 
160*a0b6e447SAlan Wright operator:	STAR
161*a0b6e447SAlan Wright 	|	DIV
162*a0b6e447SAlan Wright 	|	MOD
163*a0b6e447SAlan Wright 	|	PLUS
164*a0b6e447SAlan Wright 	|	MINUS
165*a0b6e447SAlan Wright 	|	AND
166*a0b6e447SAlan Wright 	|	OR
167*a0b6e447SAlan Wright 	|	XOR
168*a0b6e447SAlan Wright 	;
169*a0b6e447SAlan Wright 
170d0e51869Samw declarator:	decl1
171d0e51869Samw 	;
172d0e51869Samw 
173d0e51869Samw decl1	:	decl2
174d0e51869Samw 	|	STAR decl1		={ $$ = n_cons (STAR, $2); }
175d0e51869Samw 	;
176d0e51869Samw 
177d0e51869Samw decl2	:	decl3
178d0e51869Samw 	|	decl3 LB RB		={ $$ = n_cons (LB, $1, 0); }
179d0e51869Samw 	|	decl3 LB STAR RB	={ $$ = n_cons (LB, $1, 0); }
180d0e51869Samw 	|	decl3 LB INTEGER RB	={ $$ = n_cons (LB, $1, $3); }
181d0e51869Samw 	;
182d0e51869Samw 
183d0e51869Samw decl3	:	IDENTIFIER
184d0e51869Samw 	|	LP decl1 RP		={ $$ = n_cons (LP, $2); }
185d0e51869Samw 	;
186d0e51869Samw 
187d0e51869Samw 
188d0e51869Samw 
189d0e51869Samw %%
190