| 1 |
// Copyright 2017 The go-libvirt Authors. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
// The generated code notice below is output to the generated file. *This* file, |
| 16 |
// (sunrpc.y) is the yacc grammar for the sunrpc protocol language, and is *not* |
| 17 |
// generated. |
| 18 |
|
| 19 |
%{ |
| 20 |
// Copyright 2017 The go-libvirt Authors. |
| 21 |
// |
| 22 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 23 |
// you may not use this file except in compliance with the License. |
| 24 |
// You may obtain a copy of the License at |
| 25 |
// |
| 26 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 27 |
// |
| 28 |
// Unless required by applicable law or agreed to in writing, software |
| 29 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 30 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 31 |
// See the License for the specific language governing permissions and |
| 32 |
// limitations under the License. |
| 33 |
|
| 34 |
// |
| 35 |
// Code generated by goyacc. DO NOT EDIT. |
| 36 |
// |
| 37 |
// To regenerate, run 'go generate' in internal/lvgen. |
| 38 |
// |
| 39 |
|
| 40 |
package lvgen |
| 41 |
|
| 42 |
import ( |
| 43 |
//"fmt" |
| 44 |
) |
| 45 |
|
| 46 |
%} |
| 47 |
|
| 48 |
// SymType |
| 49 |
%union{ |
| 50 |
val string |
| 51 |
} |
| 52 |
|
| 53 |
// XDR tokens: |
| 54 |
%token BOOL CASE CONST DEFAULT DOUBLE ENUM FLOAT OPAQUE STRING STRUCT |
| 55 |
%token SWITCH TYPEDEF UNION UNSIGNED VOID HYPER INT SHORT CHAR |
| 56 |
%token IDENTIFIER CONSTANT ERROR |
| 57 |
// RPCL additional tokens: |
| 58 |
%token PROGRAM VERSION |
| 59 |
%token METADATACOMMENT |
| 60 |
%token PROCIDENTIFIER |
| 61 |
|
| 62 |
%% |
| 63 |
|
| 64 |
specification |
| 65 |
: definition_list |
| 66 |
; |
| 67 |
|
| 68 |
value |
| 69 |
: IDENTIFIER |
| 70 |
| CONSTANT |
| 71 |
; |
| 72 |
|
| 73 |
definition_list |
| 74 |
: definition ';' |
| 75 |
| definition ';' definition_list |
| 76 |
; |
| 77 |
|
| 78 |
definition |
| 79 |
: enum_definition |
| 80 |
| const_definition |
| 81 |
| typedef_definition |
| 82 |
| struct_definition |
| 83 |
| union_definition |
| 84 |
| program_definition |
| 85 |
; |
| 86 |
|
| 87 |
enum_definition |
| 88 |
: ENUM enum_ident '{' enum_value_list '}' { StartEnum($2.val) } |
| 89 |
; |
| 90 |
|
| 91 |
enum_value_list |
| 92 |
: enum_value |
| 93 |
| enum_value ',' enum_value_list |
| 94 |
; |
| 95 |
|
| 96 |
enum_value |
| 97 |
: enum_value_ident { |
| 98 |
err := AddEnumAutoVal($1.val) |
| 99 |
if err != nil { |
| 100 |
yylex.Error(err.Error()) |
| 101 |
return 1 |
| 102 |
} |
| 103 |
} |
| 104 |
| enum_value_ident '=' value { |
| 105 |
err := AddEnumVal($1.val, $3.val) |
| 106 |
if err != nil { |
| 107 |
yylex.Error(err.Error()) |
| 108 |
return 1 |
| 109 |
} |
| 110 |
} |
| 111 |
| enum_proc_ident '=' value { |
| 112 |
err := AddProcEnumVal($1.val, $3.val, "") |
| 113 |
if err != nil { |
| 114 |
yylex.Error(err.Error()) |
| 115 |
return 1 |
| 116 |
} |
| 117 |
} |
| 118 |
| METADATACOMMENT enum_proc_ident '=' value { |
| 119 |
err := AddProcEnumVal($2.val, $4.val, $1.val) |
| 120 |
if err != nil { |
| 121 |
yylex.Error(err.Error()) |
| 122 |
return 1 |
| 123 |
} |
| 124 |
} |
| 125 |
; |
| 126 |
|
| 127 |
enum_proc_ident |
| 128 |
: PROCIDENTIFIER |
| 129 |
; |
| 130 |
|
| 131 |
enum_ident |
| 132 |
: IDENTIFIER |
| 133 |
; |
| 134 |
|
| 135 |
enum_value_ident |
| 136 |
: IDENTIFIER |
| 137 |
; |
| 138 |
|
| 139 |
// Ignore consts that are set to IDENTIFIERs - this isn't allowed by the spec, |
| 140 |
// but occurs in the file because libvirt runs the pre-processor on the protocol |
| 141 |
// file, and it handles replacing the identifier with it's #defined value. |
| 142 |
const_definition |
| 143 |
: CONST const_ident '=' IDENTIFIER |
| 144 |
| CONST const_ident '=' CONSTANT { |
| 145 |
err := AddConst($2.val, $4.val) |
| 146 |
if err != nil { |
| 147 |
yylex.Error(err.Error()) |
| 148 |
return 1 |
| 149 |
} |
| 150 |
} |
| 151 |
; |
| 152 |
|
| 153 |
const_ident |
| 154 |
: IDENTIFIER |
| 155 |
; |
| 156 |
|
| 157 |
typedef_definition |
| 158 |
: TYPEDEF {StartTypedef()} declaration |
| 159 |
; |
| 160 |
|
| 161 |
declaration |
| 162 |
: simple_declaration |
| 163 |
| fixed_array_declaration |
| 164 |
| variable_array_declaration |
| 165 |
| pointer_declaration |
| 166 |
; |
| 167 |
|
| 168 |
simple_declaration |
| 169 |
: type_specifier variable_ident {AddDeclaration($2.val, $1.val)} |
| 170 |
; |
| 171 |
|
| 172 |
type_specifier |
| 173 |
: int_spec |
| 174 |
| UNSIGNED int_spec {$$.val = "u"+$2.val} |
| 175 |
| FLOAT {$$.val = "float32"} |
| 176 |
| DOUBLE {$$.val = "float64"} |
| 177 |
| BOOL {$$.val = "bool"} |
| 178 |
| STRING {$$.val = "string"} |
| 179 |
| OPAQUE {$$.val = "byte"} |
| 180 |
| enum_definition |
| 181 |
| struct_definition |
| 182 |
| union_definition |
| 183 |
| IDENTIFIER |
| 184 |
; |
| 185 |
|
| 186 |
int_spec |
| 187 |
: HYPER {$$.val = "int64"} |
| 188 |
| INT {$$.val = "int32"} |
| 189 |
| SHORT {$$.val = "int16"} |
| 190 |
| CHAR {$$.val = "int8"} |
| 191 |
; |
| 192 |
|
| 193 |
variable_ident |
| 194 |
: IDENTIFIER |
| 195 |
; |
| 196 |
|
| 197 |
fixed_array_declaration |
| 198 |
: type_specifier variable_ident '[' value ']' { AddFixedArray($2.val, $1.val, $4.val) } |
| 199 |
; |
| 200 |
|
| 201 |
variable_array_declaration |
| 202 |
: type_specifier variable_ident '<' value '>' { AddVariableArray($2.val, $1.val, $4.val) } |
| 203 |
| type_specifier variable_ident '<' '>' { AddVariableArray($2.val, $1.val, "") } |
| 204 |
; |
| 205 |
|
| 206 |
// while pointer_declarations may look like their familiar c-equivalents, in the |
| 207 |
// XDR language they actually declare "Optional-data". The simplest |
| 208 |
// representation to use for these is a variable-length array with a size of 1. |
| 209 |
// See the XDR spec for a more complete explanation of this. |
| 210 |
pointer_declaration |
| 211 |
: type_specifier '*' variable_ident { AddOptValue($3.val, $1.val) } |
| 212 |
; |
| 213 |
|
| 214 |
struct_definition |
| 215 |
: STRUCT struct_ident '{' {StartStruct($2.val)} declaration_list '}' { AddStruct() } |
| 216 |
; |
| 217 |
|
| 218 |
struct_ident |
| 219 |
: IDENTIFIER |
| 220 |
; |
| 221 |
|
| 222 |
declaration_list |
| 223 |
: declaration ';' |
| 224 |
| declaration ';' declaration_list |
| 225 |
; |
| 226 |
|
| 227 |
union_definition |
| 228 |
: UNION union_ident {StartUnion($2.val)} SWITCH '(' simple_declaration ')' '{' case_list '}' {AddUnion()} |
| 229 |
; |
| 230 |
|
| 231 |
union_ident |
| 232 |
: IDENTIFIER |
| 233 |
; |
| 234 |
|
| 235 |
case_list |
| 236 |
: case ';' |
| 237 |
| case ';' case_list |
| 238 |
; |
| 239 |
|
| 240 |
case |
| 241 |
: CASE value {StartCase($2.val)} ':' declaration {AddCase()} |
| 242 |
| DEFAULT {StartCase("default")} ':' declaration {AddCase()} |
| 243 |
; |
| 244 |
|
| 245 |
program_definition |
| 246 |
: PROGRAM program_ident '{' version_list '}' '=' value |
| 247 |
; |
| 248 |
|
| 249 |
program_ident |
| 250 |
: IDENTIFIER |
| 251 |
; |
| 252 |
|
| 253 |
version_list |
| 254 |
: version ';' |
| 255 |
| version ';' version_list |
| 256 |
; |
| 257 |
|
| 258 |
version |
| 259 |
: VERSION version_ident '{' procedure_list '}' '=' value ';' |
| 260 |
; |
| 261 |
|
| 262 |
version_ident |
| 263 |
: IDENTIFIER |
| 264 |
; |
| 265 |
|
| 266 |
procedure_list |
| 267 |
: procedure ';' |
| 268 |
| procedure ';' procedure_list |
| 269 |
; |
| 270 |
|
| 271 |
procedure |
| 272 |
: type_specifier procedure_ident '(' type_specifier ')' '=' value ';' |
| 273 |
; |
| 274 |
|
| 275 |
procedure_ident |
| 276 |
: IDENTIFIER |
| 277 |
; |
| 278 |
|
| 279 |
%% |