Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 1 | %{ |
| 2 | |
| 3 | #include "AST.h" |
| 4 | #include "ArrayType.h" |
| 5 | #include "CompoundType.h" |
| 6 | #include "Constant.h" |
| 7 | #include "EnumType.h" |
| 8 | #include "Interface.h" |
| 9 | #include "Method.h" |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 10 | #include "TypeDef.h" |
| 11 | #include "VectorType.h" |
| 12 | |
| 13 | #include "hidl-gen_y.h" |
| 14 | |
| 15 | #include <stdio.h> |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 16 | #include <utils/String8.h> |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 17 | |
| 18 | using namespace android; |
| 19 | |
| 20 | extern int yylex(YYSTYPE *yylval_param, void *yyscanner); |
| 21 | extern int column; |
| 22 | |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 23 | int yyerror(AST *, const char *s) { |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 24 | fflush(stdout); |
| 25 | printf("\n%*s\n%*s\n", column, "^", column, s); |
| 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | #define scanner ast->scanner() |
| 31 | |
| 32 | %} |
| 33 | |
| 34 | %parse-param { android::AST *ast } |
| 35 | %lex-param { void *scanner } |
| 36 | %pure-parser |
| 37 | |
| 38 | %token<str> CONST |
| 39 | %token<str> ENUM |
| 40 | %token<str> EXTENDS |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 41 | %token<str> FQNAME |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 42 | %token<str> GENERATES |
| 43 | %token<str> IDENTIFIER |
| 44 | %token<str> IMPORT |
| 45 | %token<str> INTEGER |
| 46 | %token<str> INTERFACE |
| 47 | %token<str> PACKAGE |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 48 | %token<type> SCALAR |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 49 | %token<str> STRUCT |
| 50 | %token<str> STRING_LITERAL |
| 51 | %token<str> TYPEDEF |
| 52 | %token<str> UNION |
| 53 | %token<str> VEC |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 54 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 55 | %type<str> optIdentifier package |
| 56 | %type<str> const_value |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 57 | %type<type> fqname |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 58 | |
| 59 | %type<type> type opt_storage_type |
| 60 | %type<type> enum_declaration |
| 61 | %type<type> struct_or_union_declaration |
| 62 | %type<type> opt_extends |
| 63 | |
| 64 | %type<field> field_declaration |
| 65 | %type<fields> field_declarations struct_or_union_body |
| 66 | %type<enumValue> enum_value |
| 67 | %type<enumValues> enum_values |
| 68 | %type<typedVars> typed_vars |
| 69 | %type<typedVar> typed_var |
| 70 | %type<method> method_declaration |
| 71 | %type<compoundStyle> struct_or_union_keyword |
| 72 | |
| 73 | %start program |
| 74 | |
| 75 | %union { |
| 76 | const char *str; |
| 77 | android::Type *type; |
| 78 | android::CompoundType *compoundType; |
| 79 | android::CompoundField *field; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 80 | std::vector<android::CompoundField *> *fields; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 81 | android::EnumValue *enumValue; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 82 | std::vector<android::EnumValue *> *enumValues; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 83 | android::TypedVar *typedVar; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 84 | std::vector<android::TypedVar *> *typedVars; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 85 | android::Method *method; |
| 86 | android::CompoundType::Style compoundStyle; |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 87 | android::Vector<std::string> *stringVec; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | %% |
| 91 | |
| 92 | program |
Andreas Huber | da51b8e | 2016-07-28 16:00:57 -0700 | [diff] [blame] | 93 | : package imports body |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 94 | ; |
| 95 | |
| 96 | fqname |
| 97 | : FQNAME |
| 98 | { |
| 99 | $$ = ast->lookupType($1); |
| 100 | if ($$ == NULL) { |
| 101 | yyerror(ast, |
| 102 | android::String8::format( |
| 103 | "Failed to lookup type '%s'.", $1).string()); |
| 104 | YYERROR; |
| 105 | } |
| 106 | } |
| 107 | | IDENTIFIER |
| 108 | { |
| 109 | $$ = ast->lookupType($1); |
| 110 | if ($$ == NULL) { |
| 111 | yyerror(ast, |
| 112 | android::String8::format( |
| 113 | "Failed to lookup type '%s'.", $1).string()); |
| 114 | YYERROR; |
| 115 | } |
| 116 | } |
| 117 | | SCALAR |
| 118 | ; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 119 | |
| 120 | package |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 121 | : PACKAGE FQNAME ';' |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 122 | { |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 123 | if (!ast->setPackage($2)) { |
| 124 | yyerror(ast, "Malformed package identifier."); |
| 125 | YYERROR; |
| 126 | } |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 127 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 128 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 129 | imports |
| 130 | : /* empty */ |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 131 | | imports IMPORT FQNAME ';' |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 132 | { |
Andreas Huber | 68f2459 | 2016-07-29 14:53:48 -0700 | [diff] [blame] | 133 | if (!ast->addImport($3)) { |
| 134 | yyerror(ast, |
| 135 | android::String8::format( |
| 136 | "Unable to import '%s'.", $3)); |
| 137 | |
| 138 | YYERROR; |
| 139 | } |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 140 | } |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 141 | | imports IMPORT IDENTIFIER ';' |
| 142 | { |
Andreas Huber | 68f2459 | 2016-07-29 14:53:48 -0700 | [diff] [blame] | 143 | if (!ast->addImport($3)) { |
| 144 | yyerror(ast, |
| 145 | android::String8::format( |
| 146 | "Unable to import '%s'.", $3)); |
| 147 | |
| 148 | YYERROR; |
| 149 | } |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 150 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 151 | ; |
| 152 | |
| 153 | opt_extends |
| 154 | : /* empty */ { $$ = NULL; } |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 155 | | EXTENDS fqname { $$ = $2; } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 156 | |
| 157 | body |
| 158 | : INTERFACE IDENTIFIER opt_extends |
| 159 | { |
Andreas Huber | 6cb08cf | 2016-08-03 15:44:51 -0700 | [diff] [blame] | 160 | if ($3 != NULL && !$3->isInterface()) { |
| 161 | fprintf(stderr, "You can only extend interfaces.\n"); |
| 162 | YYERROR; |
| 163 | } |
| 164 | |
Andreas Huber | 6cb08cf | 2016-08-03 15:44:51 -0700 | [diff] [blame] | 165 | Interface *iface = new Interface(static_cast<Interface *>($3)); |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 166 | |
| 167 | // Register interface immediately so it can be referenced inside |
| 168 | // definition. |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 169 | if (!ast->addScopedType($2, iface)) { |
| 170 | YYERROR; |
| 171 | } |
Andreas Huber | eb1081f | 2016-07-28 13:13:24 -0700 | [diff] [blame] | 172 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 173 | ast->enterScope(iface); |
| 174 | } |
| 175 | '{' interface_declarations '}' ';' |
| 176 | { |
| 177 | Interface *iface = static_cast<Interface *>(ast->scope()); |
| 178 | |
| 179 | ast->leaveScope(); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 180 | } |
| 181 | | type_declarations |
| 182 | ; |
| 183 | |
| 184 | interface_declarations |
| 185 | : /* empty */ |
| 186 | | interface_declarations type_declaration |
| 187 | | interface_declarations method_declaration |
| 188 | { |
| 189 | Interface *iface = static_cast<Interface *>(ast->scope()); |
| 190 | iface->addMethod($2); |
| 191 | } |
| 192 | ; |
| 193 | |
| 194 | type_declarations |
Andreas Huber | a2723d2 | 2016-07-29 15:36:07 -0700 | [diff] [blame] | 195 | : /* empty */ |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 196 | | type_declarations type_declaration |
| 197 | ; |
| 198 | |
| 199 | type_declaration |
| 200 | : named_struct_or_union_declaration ';' |
| 201 | | named_enum_declaration ';' |
| 202 | | typedef_declaration ';' |
| 203 | | const_declaration ';' |
| 204 | ; |
| 205 | |
| 206 | typedef_declaration |
| 207 | : TYPEDEF type IDENTIFIER |
| 208 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 209 | TypeDef *def = new TypeDef($2); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 210 | if (!ast->addScopedType($3, def)) { |
| 211 | YYERROR; |
| 212 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 213 | } |
| 214 | ; |
| 215 | |
| 216 | const_value |
| 217 | : INTEGER |
| 218 | | STRING_LITERAL ; |
| 219 | |
| 220 | const_declaration |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 221 | : CONST fqname IDENTIFIER '=' const_value |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 222 | { |
| 223 | Constant *constant = new Constant($3, $2, $5); |
| 224 | ast->scope()->addConstant(constant); |
| 225 | } |
| 226 | ; |
| 227 | |
| 228 | method_declaration |
| 229 | : IDENTIFIER '(' typed_vars ')' ';' |
| 230 | { |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 231 | $$ = new Method($1, $3, new std::vector<TypedVar *>); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 232 | } |
| 233 | | IDENTIFIER '(' typed_vars ')' GENERATES '(' typed_vars ')' ';' |
| 234 | { |
| 235 | $$ = new Method($1, $3, $7); |
| 236 | } |
| 237 | ; |
| 238 | |
| 239 | typed_vars |
| 240 | : /* empty */ |
| 241 | { |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 242 | $$ = new std::vector<TypedVar *>; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 243 | } |
| 244 | | typed_var |
| 245 | { |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 246 | $$ = new std::vector<TypedVar *>; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 247 | $$->push_back($1); |
| 248 | } |
| 249 | | typed_vars ',' typed_var |
| 250 | { |
| 251 | $$ = $1; |
| 252 | $$->push_back($3); |
| 253 | } |
| 254 | ; |
| 255 | |
| 256 | typed_var : type IDENTIFIER { $$ = new TypedVar($2, $1); } |
| 257 | ; |
| 258 | |
| 259 | |
| 260 | struct_or_union_keyword |
| 261 | : STRUCT { $$ = CompoundType::STYLE_STRUCT; } |
| 262 | | UNION { $$ = CompoundType::STYLE_UNION; } |
| 263 | ; |
| 264 | |
| 265 | named_struct_or_union_declaration |
| 266 | : struct_or_union_keyword IDENTIFIER |
| 267 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 268 | CompoundType *container = new CompoundType($1); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 269 | ast->enterScope(container); |
| 270 | } |
| 271 | struct_or_union_body |
| 272 | { |
| 273 | CompoundType *container = static_cast<CompoundType *>(ast->scope()); |
| 274 | |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 275 | if (!container->setFields($4)) { |
| 276 | YYERROR; |
| 277 | } |
| 278 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 279 | ast->leaveScope(); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 280 | if (!ast->addScopedType($2, container)) { |
| 281 | YYERROR; |
| 282 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 283 | } |
| 284 | ; |
| 285 | |
| 286 | struct_or_union_declaration |
| 287 | : struct_or_union_keyword optIdentifier |
| 288 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 289 | CompoundType *container = new CompoundType($1); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 290 | ast->enterScope(container); |
| 291 | } |
| 292 | struct_or_union_body |
| 293 | { |
| 294 | CompoundType *container = static_cast<CompoundType *>(ast->scope()); |
| 295 | |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 296 | if (!container->setFields($4)) { |
| 297 | YYERROR; |
| 298 | } |
| 299 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 300 | ast->leaveScope(); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 301 | if (!ast->addScopedType($2, container)) { |
| 302 | YYERROR; |
| 303 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 304 | |
Andreas Huber | fd4afab | 2016-08-03 13:02:57 -0700 | [diff] [blame] | 305 | $$ = container->ref(); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 306 | } |
| 307 | ; |
| 308 | |
| 309 | struct_or_union_body |
| 310 | : '{' field_declarations '}' { $$ = $2; } |
| 311 | ; |
| 312 | |
| 313 | field_declarations |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 314 | : /* empty */ { $$ = new std::vector<CompoundField *>; } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 315 | | field_declarations field_declaration |
| 316 | { |
| 317 | $$ = $1; |
| 318 | |
| 319 | if ($2 != NULL) { |
| 320 | $$->push_back($2); |
| 321 | } |
| 322 | } |
| 323 | ; |
| 324 | |
| 325 | field_declaration |
| 326 | : type IDENTIFIER ';' { $$ = new CompoundField($2, $1); } |
| 327 | | struct_or_union_declaration ';' { $$ = NULL; } |
| 328 | | enum_declaration ';' { $$ = NULL; } |
| 329 | ; |
| 330 | |
| 331 | opt_storage_type |
| 332 | : /* empty */ { $$ = NULL; } |
Andreas Huber | 8d3ac0c | 2016-08-04 14:49:23 -0700 | [diff] [blame^] | 333 | | ':' fqname |
| 334 | { |
| 335 | $$ = $2; |
| 336 | |
| 337 | if ($$ != NULL && !$$->isValidEnumStorageType()) { |
| 338 | fprintf(stderr, "Invalid enum storage type specified.\n"); |
| 339 | YYABORT; |
| 340 | } |
| 341 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 342 | ; |
| 343 | |
| 344 | opt_comma |
| 345 | : /* empty */ |
| 346 | | ',' |
| 347 | ; |
| 348 | |
| 349 | named_enum_declaration |
| 350 | : ENUM IDENTIFIER opt_storage_type '{' enum_values opt_comma '}' |
| 351 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 352 | EnumType *enumType = new EnumType($5, $3); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 353 | if (!ast->addScopedType($2, enumType)) { |
| 354 | YYERROR; |
| 355 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 356 | } |
| 357 | ; |
| 358 | |
| 359 | enum_declaration |
| 360 | : ENUM '{' enum_values opt_comma '}' |
| 361 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 362 | EnumType *enumType = new EnumType($3); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 363 | if (!ast->addScopedType(NULL /* localName */, enumType)) { |
| 364 | YYERROR; |
| 365 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 366 | |
Andreas Huber | fd4afab | 2016-08-03 13:02:57 -0700 | [diff] [blame] | 367 | $$ = enumType->ref(); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 368 | } |
| 369 | | ENUM IDENTIFIER opt_storage_type '{' enum_values opt_comma '}' |
| 370 | { |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 371 | EnumType *enumType = new EnumType($5, $3); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 372 | if (!ast->addScopedType($2, enumType)) { |
| 373 | YYERROR; |
| 374 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 375 | |
Andreas Huber | fd4afab | 2016-08-03 13:02:57 -0700 | [diff] [blame] | 376 | $$ = enumType->ref(); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 377 | } |
| 378 | ; |
| 379 | |
| 380 | enum_value |
| 381 | : IDENTIFIER { $$ = new EnumValue($1); } |
| 382 | | IDENTIFIER '=' INTEGER { $$ = new EnumValue($1, $3); } |
| 383 | | IDENTIFIER '=' IDENTIFIER { $$ = new EnumValue($1, $3); } |
Andreas Huber | 006189f | 2016-07-29 15:51:17 -0700 | [diff] [blame] | 384 | | IDENTIFIER '=' IDENTIFIER '+' INTEGER |
| 385 | { |
| 386 | $$ = new EnumValue( |
| 387 | $1, strdup( |
| 388 | android::String8::format("%s + %s", $3, $5).string())); |
| 389 | } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 390 | ; |
| 391 | |
| 392 | enum_values |
| 393 | : /* empty */ |
| 394 | { |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 395 | $$ = new std::vector<EnumValue *>; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 396 | } |
| 397 | | enum_value |
| 398 | { |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 399 | $$ = new std::vector<EnumValue *>; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 400 | $$->push_back($1); |
| 401 | } |
| 402 | | enum_values ',' enum_value |
| 403 | { |
| 404 | $$ = $1; |
| 405 | $$->push_back($3); |
| 406 | } |
| 407 | ; |
| 408 | |
| 409 | type |
Andreas Huber | 84f89de | 2016-07-28 15:39:51 -0700 | [diff] [blame] | 410 | : fqname { $$ = $1; } |
| 411 | | fqname '[' INTEGER ']' { $$ = new ArrayType($1, $3); } |
| 412 | | VEC '<' fqname '>' { $$ = new VectorType($3); } |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 413 | | struct_or_union_declaration { $$ = $1; } |
| 414 | | enum_declaration { $$ = $1; } |
| 415 | ; |
| 416 | |
| 417 | optIdentifier |
| 418 | : /* empty */ { $$ = NULL; } |
| 419 | | IDENTIFIER { $$ = $1; } |
| 420 | ; |
| 421 | |
| 422 | %% |