Changes in src/Parser/parser.yy [d824715:374cb117]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rd824715 r374cb117 380 380 381 381 %type<decl> enumerator_list enum_type enum_type_nobody 382 %type< en> enumerator_value_opt382 %type<in> enumerator_value_opt 383 383 384 384 %type<decl> external_definition external_definition_list external_definition_list_opt … … 2303 2303 ; 2304 2304 2305 enum_type: // enum2305 enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); // enum 2306 2306 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2307 2307 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } … … 2315 2315 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2316 2316 { 2317 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2318 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2319 } 2320 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2317 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) 2318 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2319 2320 $$ = DeclarationNode::newEnum( nullptr, $7, true ) ->addQualifiers( $5 ) -> addEnumBase( $3 ); 2321 } 2322 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier 2321 2323 { 2322 2324 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } … … 2325 2327 '{' enumerator_list comma_opt '}' 2326 2328 { 2327 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;2329 $$ = DeclarationNode::newEnum( $6, $10, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2328 2330 } 2329 2331 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2331 2333 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2332 2334 typedefTable.makeTypedef( *$6->name ); 2333 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;2335 $$ = DeclarationNode::newEnum( $6->name, $9, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2334 2336 } 2335 2337 | enum_type_nobody … … 2345 2347 enumerator_list: 2346 2348 identifier_or_type_name enumerator_value_opt 2347 { $$ = DeclarationNode::newEnum Constant( $1, $2 ); }2349 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); } 2348 2350 | INLINE type_name 2349 { $$ = DeclarationNode::newEnum Constant( new string("inline"), nullptr ); }2351 { $$ = DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ); } 2350 2352 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2351 { $$ = $1->appendList( DeclarationNode::newEnum Constant( $3, $4 ) ); }2353 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); } 2352 2354 | enumerator_list ',' INLINE type_name enumerator_value_opt 2353 { $$ = $1->appendList( DeclarationNode::newEnum Constant( new string("inline"), nullptr ) ); }2355 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); } 2354 2356 ; 2355 2357 … … 2360 2362 // { $$ = $2; } 2361 2363 | simple_assignment_operator initializer 2362 { $$ = $ 2->get_expression(); } // FIX ME: enum only deals with constant_expression2364 { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); } 2363 2365 ; 2364 2366
Note:
See TracChangeset
for help on using the changeset viewer.