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 /* 24a0b6e447SAlan Wright * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25d0e51869Samw * Use is subject to license terms. 26d0e51869Samw */ 27d0e51869Samw 28ce8560eeSMatt Barden /* 29ce8560eeSMatt Barden * Copyright 2020 Tintri by DDN, Inc. All rights reserved. 30ce8560eeSMatt Barden */ 31ce8560eeSMatt Barden 32d0e51869Samw #include "ndrgen.h" 33d0e51869Samw 34d0e51869Samw typedef struct node *node_ptr; 35d0e51869Samw #define YYSTYPE node_ptr 36d0e51869Samw %} 37d0e51869Samw 38d0e51869Samw /* keywords */ 39d0e51869Samw %token STRUCT_KW UNION_KW TYPEDEF_KW 40d0e51869Samw 41d0e51869Samw /* advice keywords */ 42d0e51869Samw %token ALIGN_KW OPERATION_KW IN_KW OUT_KW 43d0e51869Samw %token INTERFACE_KW UUID_KW _NO_REORDER_KW EXTERN_KW 44d0e51869Samw %token SIZE_IS_KW LENGTH_IS_KW STRING_KW REFERENCE_KW 45d0e51869Samw %token CASE_KW DEFAULT_KW SWITCH_IS_KW 46ce8560eeSMatt Barden %token TRANSMIT_AS_KW ARG_IS_KW FAKE_KW 47d0e51869Samw 48d0e51869Samw /* composite keywords */ 49d0e51869Samw %token BASIC_TYPE TYPENAME 50d0e51869Samw 51d0e51869Samw /* symbols and punctuation */ 52d0e51869Samw %token IDENTIFIER INTEGER STRING 53a0b6e447SAlan Wright %token LC RC SEMI STAR DIV MOD PLUS MINUS AND OR XOR LB RB LP RP 54d0e51869Samw 55d0e51869Samw 56d0e51869Samw %token L_MEMBER 57d0e51869Samw 58d0e51869Samw 59d0e51869Samw %% 60d0e51869Samw 61d0e51869Samw defn : /* empty */ 62*724c5febSToomas Soome | construct_list { construct_list = (struct node *)$1; } 63d0e51869Samw ; 64d0e51869Samw 65d0e51869Samw construct_list: construct 66*724c5febSToomas Soome | construct_list construct { n_splice ($1,$2); } 67d0e51869Samw ; 68d0e51869Samw 69d0e51869Samw construct: struct 70d0e51869Samw | union 71d0e51869Samw | typedef 72d0e51869Samw ; 73d0e51869Samw 74d0e51869Samw struct : advice STRUCT_KW typename LC members RC SEMI 75*724c5febSToomas Soome { $$ = n_cons (STRUCT_KW, $1, $3, $5); 76d0e51869Samw construct_fixup ($$); 77d0e51869Samw } 78d0e51869Samw ; 79d0e51869Samw 80d0e51869Samw union : advice UNION_KW typename LC members RC SEMI 81*724c5febSToomas Soome { $$ = n_cons (UNION_KW, $1, $3, $5); 82d0e51869Samw construct_fixup ($$); 83d0e51869Samw } 84d0e51869Samw ; 85d0e51869Samw 86d0e51869Samw typedef : TYPEDEF_KW member 87*724c5febSToomas Soome { $$ = n_cons (TYPEDEF_KW, 0, $2->n_m_name, $2); 88d0e51869Samw construct_fixup ($$); 89d0e51869Samw } 90d0e51869Samw ; 91d0e51869Samw 92d0e51869Samw members : member 93*724c5febSToomas Soome | members member { n_splice ($1,$2); } 94d0e51869Samw ; 95d0e51869Samw 96d0e51869Samw member : advice type declarator SEMI 97*724c5febSToomas Soome { $$ = n_cons (L_MEMBER, $1, $2, $3); 98d0e51869Samw member_fixup ($$); 99d0e51869Samw } 100d0e51869Samw ; 101d0e51869Samw 102*724c5febSToomas Soome advice : /* empty */ { $$ = 0; } 103d0e51869Samw | adv_list 104d0e51869Samw ; 105d0e51869Samw 106*724c5febSToomas Soome adv_list: LB adv_attrs RB { $$ = $2; } 107*724c5febSToomas Soome | adv_list LB adv_attrs RB { n_splice ($1,$3); } 108d0e51869Samw ; 109d0e51869Samw 110d0e51869Samw adv_attrs: adv_attr 111*724c5febSToomas Soome | adv_attr adv_attr { n_splice ($1,$2); } 112d0e51869Samw ; 113d0e51869Samw 114*724c5febSToomas Soome adv_attr: IN_KW { $$ = n_cons (IN_KW); } 115*724c5febSToomas Soome | OUT_KW { $$ = n_cons (OUT_KW); } 116*724c5febSToomas Soome | OPERATION_KW LP arg RP { $$ = n_cons (OPERATION_KW, $3); } 117*724c5febSToomas Soome | ALIGN_KW LP arg RP { $$ = n_cons (ALIGN_KW, $3); } 118*724c5febSToomas Soome | STRING_KW { $$ = n_cons (STRING_KW); } 119*724c5febSToomas Soome | FAKE_KW { $$ = n_cons (FAKE_KW); } 120d0e51869Samw 121a0b6e447SAlan Wright | SIZE_IS_KW LP arg RP 122*724c5febSToomas Soome { $$ = n_cons (SIZE_IS_KW, $3, $3, $3); } 123a0b6e447SAlan Wright | SIZE_IS_KW LP arg operator INTEGER RP 124*724c5febSToomas Soome { $$ = n_cons (SIZE_IS_KW, $3, $4, $5); } 125a0b6e447SAlan Wright 126a0b6e447SAlan Wright | LENGTH_IS_KW LP arg RP 127*724c5febSToomas Soome { $$ = n_cons (LENGTH_IS_KW, $3, $3, $3); } 128a0b6e447SAlan Wright | LENGTH_IS_KW LP arg operator INTEGER RP 129*724c5febSToomas Soome { $$ = n_cons (LENGTH_IS_KW, $3, $4, $5); } 130a0b6e447SAlan Wright 131a0b6e447SAlan Wright | SWITCH_IS_KW LP arg RP 132*724c5febSToomas Soome { $$ = n_cons (SWITCH_IS_KW, $3, $3, $3); } 133a0b6e447SAlan Wright | SWITCH_IS_KW LP arg operator INTEGER RP 134*724c5febSToomas Soome { $$ = n_cons (SWITCH_IS_KW, $3, $4, $5); } 135a0b6e447SAlan Wright 136*724c5febSToomas Soome | CASE_KW LP arg RP { $$ = n_cons (CASE_KW, $3); } 137*724c5febSToomas Soome | DEFAULT_KW { $$ = n_cons (DEFAULT_KW); } 138d0e51869Samw 139*724c5febSToomas Soome | ARG_IS_KW LP arg RP { $$ = n_cons (ARG_IS_KW, $3); } 140d0e51869Samw | TRANSMIT_AS_KW LP BASIC_TYPE RP 141*724c5febSToomas Soome { $$ = n_cons (TRANSMIT_AS_KW, $3); } 142d0e51869Samw 143*724c5febSToomas Soome | INTERFACE_KW LP arg RP { $$ = n_cons (INTERFACE_KW, $3); } 144*724c5febSToomas Soome | UUID_KW LP arg RP { $$ = n_cons (UUID_KW, $3); } 145*724c5febSToomas Soome | _NO_REORDER_KW { $$ = n_cons (_NO_REORDER_KW); } 146*724c5febSToomas Soome | EXTERN_KW { $$ = n_cons (EXTERN_KW); } 147*724c5febSToomas Soome | REFERENCE_KW { $$ = n_cons (REFERENCE_KW); } 148d0e51869Samw ; 149d0e51869Samw 150d0e51869Samw arg : IDENTIFIER 151d0e51869Samw | INTEGER 152d0e51869Samw | STRING 153d0e51869Samw ; 154d0e51869Samw 155d0e51869Samw type : BASIC_TYPE 156d0e51869Samw | typename 157*724c5febSToomas Soome | STRUCT_KW typename { $$ = $2; } 158*724c5febSToomas Soome | UNION_KW typename { $$ = $2; } 159d0e51869Samw ; 160d0e51869Samw 161d0e51869Samw typename: TYPENAME 162d0e51869Samw | IDENTIFIER 163d0e51869Samw ; 164d0e51869Samw 165a0b6e447SAlan Wright operator: STAR 166a0b6e447SAlan Wright | DIV 167a0b6e447SAlan Wright | MOD 168a0b6e447SAlan Wright | PLUS 169a0b6e447SAlan Wright | MINUS 170a0b6e447SAlan Wright | AND 171a0b6e447SAlan Wright | OR 172a0b6e447SAlan Wright | XOR 173a0b6e447SAlan Wright ; 174a0b6e447SAlan Wright 175d0e51869Samw declarator: decl1 176d0e51869Samw ; 177d0e51869Samw 178d0e51869Samw decl1 : decl2 179*724c5febSToomas Soome | STAR decl1 { $$ = n_cons (STAR, $2); } 180d0e51869Samw ; 181d0e51869Samw 182d0e51869Samw decl2 : decl3 183*724c5febSToomas Soome | decl3 LB RB { $$ = n_cons (LB, $1, 0); } 184*724c5febSToomas Soome | decl3 LB STAR RB { $$ = n_cons (LB, $1, 0); } 185*724c5febSToomas Soome | decl3 LB INTEGER RB { $$ = n_cons (LB, $1, $3); } 186d0e51869Samw ; 187d0e51869Samw 188d0e51869Samw decl3 : IDENTIFIER 189*724c5febSToomas Soome | LP decl1 RP { $$ = n_cons (LP, $2); } 190d0e51869Samw ; 191d0e51869Samw 192d0e51869Samw 193d0e51869Samw 194d0e51869Samw %% 195