1 %{ 2 /* 3 * CDDL HEADER START 4 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 #include "ndrgen.h" 31 32 typedef struct node *node_ptr; 33 #define YYSTYPE node_ptr 34 %} 35 36 /* keywords */ 37 %token STRUCT_KW UNION_KW TYPEDEF_KW 38 39 /* advice keywords */ 40 %token ALIGN_KW OPERATION_KW IN_KW OUT_KW 41 %token INTERFACE_KW UUID_KW _NO_REORDER_KW EXTERN_KW 42 %token SIZE_IS_KW LENGTH_IS_KW STRING_KW REFERENCE_KW 43 %token CASE_KW DEFAULT_KW SWITCH_IS_KW 44 %token TRANSMIT_AS_KW ARG_IS_KW 45 46 /* composite keywords */ 47 %token BASIC_TYPE TYPENAME 48 49 /* symbols and punctuation */ 50 %token IDENTIFIER INTEGER STRING 51 %token LC RC SEMI STAR LB RB LP RP 52 53 54 %token L_MEMBER 55 56 57 %% 58 59 defn : /* empty */ 60 | construct_list ={ construct_list = (struct node *)$1; } 61 ; 62 63 construct_list: construct 64 | construct_list construct ={ n_splice ($1,$2); } 65 ; 66 67 construct: struct 68 | union 69 | typedef 70 ; 71 72 struct : advice STRUCT_KW typename LC members RC SEMI 73 ={ $$ = n_cons (STRUCT_KW, $1, $3, $5); 74 construct_fixup ($$); 75 } 76 ; 77 78 union : advice UNION_KW typename LC members RC SEMI 79 ={ $$ = n_cons (UNION_KW, $1, $3, $5); 80 construct_fixup ($$); 81 } 82 ; 83 84 typedef : TYPEDEF_KW member 85 ={ $$ = n_cons (TYPEDEF_KW, 0, $2->n_m_name, $2); 86 construct_fixup ($$); 87 } 88 ; 89 90 members : member 91 | members member ={ n_splice ($1,$2); } 92 ; 93 94 member : advice type declarator SEMI 95 ={ $$ = n_cons (L_MEMBER, $1, $2, $3); 96 member_fixup ($$); 97 } 98 ; 99 100 advice : /* empty */ ={ $$ = 0; } 101 | adv_list 102 ; 103 104 adv_list: LB adv_attrs RB ={ $$ = $2; } 105 | adv_list LB adv_attrs RB ={ n_splice ($1,$3); } 106 ; 107 108 adv_attrs: adv_attr 109 | adv_attr adv_attr ={ n_splice ($1,$2); } 110 ; 111 112 adv_attr: IN_KW ={ $$ = n_cons (IN_KW); } 113 | OUT_KW ={ $$ = n_cons (OUT_KW); } 114 | OPERATION_KW LP arg RP ={ $$ = n_cons (OPERATION_KW, $3); } 115 | ALIGN_KW LP arg RP ={ $$ = n_cons (ALIGN_KW, $3); } 116 117 | STRING_KW ={ $$ = n_cons (STRING_KW); } 118 | SIZE_IS_KW LP arg RP ={ $$ = n_cons (SIZE_IS_KW, $3); } 119 | LENGTH_IS_KW LP arg RP ={ $$ = n_cons (LENGTH_IS_KW, $3); } 120 121 | SWITCH_IS_KW LP arg RP ={ $$ = n_cons (SWITCH_IS_KW, $3); } 122 | CASE_KW LP arg RP ={ $$ = n_cons (CASE_KW, $3); } 123 | DEFAULT_KW ={ $$ = n_cons (DEFAULT_KW); } 124 125 | ARG_IS_KW LP arg RP ={ $$ = n_cons (ARG_IS_KW, $3); } 126 | TRANSMIT_AS_KW LP BASIC_TYPE RP 127 ={ $$ = n_cons (TRANSMIT_AS_KW, $3); } 128 129 | INTERFACE_KW LP arg RP ={ $$ = n_cons (INTERFACE_KW, $3); } 130 | UUID_KW LP arg RP ={ $$ = n_cons (UUID_KW, $3); } 131 | _NO_REORDER_KW ={ $$ = n_cons (_NO_REORDER_KW); } 132 | EXTERN_KW ={ $$ = n_cons (EXTERN_KW); } 133 | REFERENCE_KW ={ $$ = n_cons (REFERENCE_KW); } 134 ; 135 136 arg : IDENTIFIER 137 | INTEGER 138 | STRING 139 ; 140 141 type : BASIC_TYPE 142 | typename 143 | STRUCT_KW typename ={ $$ = $2; } 144 | UNION_KW typename ={ $$ = $2; } 145 ; 146 147 typename: TYPENAME 148 | IDENTIFIER 149 ; 150 151 declarator: decl1 152 ; 153 154 decl1 : decl2 155 | STAR decl1 ={ $$ = n_cons (STAR, $2); } 156 ; 157 158 decl2 : decl3 159 | decl3 LB RB ={ $$ = n_cons (LB, $1, 0); } 160 | decl3 LB STAR RB ={ $$ = n_cons (LB, $1, 0); } 161 | decl3 LB INTEGER RB ={ $$ = n_cons (LB, $1, $3); } 162 ; 163 164 decl3 : IDENTIFIER 165 | LP decl1 RP ={ $$ = n_cons (LP, $2); } 166 ; 167 168 169 170 %% 171