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