Changeset 63be3387 for src/Parser
- Timestamp:
- Nov 14, 2022, 11:52:44 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 7d9598d8
- Parents:
- b77f0e1 (diff), 19a8c40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 5 edited
-
DeclarationNode.cc (modified) (2 diffs)
-
ExpressionNode.cc (modified) (1 diff)
-
ParseNode.h (modified) (2 diffs)
-
TypeData.cc (modified) (1 diff)
-
parser.yy (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rb77f0e1 r63be3387 27 27 #include "SynTree/LinkageSpec.h" // for Spec, linkageName, Cforall 28 28 #include "SynTree/Attribute.h" // for Attribute 29 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, Declaration29 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, InlineMemberDecl, Declaration 30 30 #include "SynTree/Expression.h" // for Expression, ConstantExpr 31 31 #include "SynTree/Statement.h" // for AsmStmt … … 1165 1165 SemanticError( this, "invalid function specifier for " ); 1166 1166 } // if 1167 if ( enumInLine ) { 1168 return new InlineMemberDecl( *name, storageClasses, linkage, nullptr ); 1169 } // if 1167 1170 assertf( name, "ObjectDecl must a have name\n" ); 1168 1171 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension ); -
src/Parser/ExpressionNode.cc
rb77f0e1 r63be3387 519 519 } 520 520 } 521 auto ret = new QualifiedNameExpr( newDecl, name->name ); 522 if ( auto e = dynamic_cast<EnumDecl*>(newDecl) ) { 523 auto enumInst = new EnumInstType( Type::Qualifiers(), e ); 524 auto obj = new ObjectDecl( name->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, enumInst, nullptr ); 525 } 526 return ret; 521 return new QualifiedNameExpr( newDecl, name->name ); 527 522 } 528 523 -
src/Parser/ParseNode.h
rb77f0e1 r63be3387 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 18 16:22:15202213 // Update Count : 93 712 // Last Modified On : Wed Nov 2 21:27:07 2022 13 // Update Count : 939 14 14 // 15 15 … … 168 168 Ctor, Dtor, 169 169 }; // OperKinds 170 171 enum class EnumHiding { Visible, Hide }; 170 172 171 173 struct LabelNode { -
src/Parser/TypeData.cc
rb77f0e1 r63be3387 925 925 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 926 926 if ( cur->enumInLine ) { 927 // Tell the compiler this is a inline value placeholder 928 ObjectDecl * member = dynamic_cast< ObjectDecl* >(* members); 929 member->enumInLine = true; 930 } 931 if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) { 927 // Do Nothing 928 } else if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) { 932 929 SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." ); 933 930 } else if ( cur->has_enumeratorValue() ) { -
src/Parser/parser.yy
rb77f0e1 r63be3387 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 14 14:04:43202213 // Update Count : 5 75112 // Last Modified On : Wed Nov 2 21:31:21 2022 13 // Update Count : 5810 14 14 // 15 15 … … 278 278 279 279 // Types declaration for productions 280 280 281 %union { 281 282 Token tok; … … 290 291 CondCtl * ifctl; 291 292 ForCtrl * fctl; 292 enumOperKinds compop;293 OperKinds compop; 293 294 LabelNode * label; 294 295 InitializerNode * in; … … 296 297 std::string * str; 297 298 bool flag; 299 EnumHiding hide; 298 300 CatchStmt::Kind catch_kind; 299 301 GenericExpr * genexpr; … … 364 366 %type<constant> string_literal 365 367 %type<str> string_literal_list 368 369 %type<hide> hide_opt visible_hide_opt 366 370 367 371 // expressions … … 2553 2557 | ENUM attribute_list_opt identifier 2554 2558 { typedefTable.makeTypedef( *$3 ); } 2555 '{' enumerator_list comma_opt '}'2556 { $$ = DeclarationNode::newEnum( $3, $6, true, false )->addQualifiers( $2 ); }2559 hide_opt '{' enumerator_list comma_opt '}' 2560 { $$ = DeclarationNode::newEnum( $3, $7, true, false )->addQualifiers( $2 ); } 2557 2561 | ENUM attribute_list_opt typedef_name // unqualified type name 2558 '{' enumerator_list comma_opt '}'2559 { $$ = DeclarationNode::newEnum( $3->name, $ 5, true, false )->addQualifiers( $2 ); }2562 hide_opt '{' enumerator_list comma_opt '}' 2563 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false )->addQualifiers( $2 ); } 2560 2564 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2561 2565 { … … 2574 2578 typedefTable.makeTypedef( *$6 ); 2575 2579 } 2576 '{' enumerator_list comma_opt '}'2577 { 2578 $$ = DeclarationNode::newEnum( $6, $1 0, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );2580 hide_opt '{' enumerator_list comma_opt '}' 2581 { 2582 $$ = DeclarationNode::newEnum( $6, $11, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2579 2583 } 2580 2584 | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt 2581 '{' enumerator_list comma_opt '}' 2582 { 2583 $$ = DeclarationNode::newEnum( $5, $8, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2584 } 2585 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' 2586 { 2587 $$ = DeclarationNode::newEnum( $6->name, $9, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2588 } 2589 | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' 2590 { 2591 $$ = DeclarationNode::newEnum( $5->name, $8, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2585 hide_opt '{' enumerator_list comma_opt '}' 2586 { 2587 $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2588 } 2589 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt 2590 hide_opt '{' enumerator_list comma_opt '}' 2591 { 2592 $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2593 } 2594 | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt 2595 hide_opt '{' enumerator_list comma_opt '}' 2596 { 2597 $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2592 2598 } 2593 2599 | enum_type_nobody 2600 ; 2601 2602 hide_opt: 2603 // empty 2604 { $$ = EnumHiding::Visible; } 2605 | '!' 2606 { $$ = EnumHiding::Hide; } 2594 2607 ; 2595 2608 … … 2602 2615 2603 2616 enumerator_list: 2604 identifier_or_type_name enumerator_value_opt2605 { $$ = DeclarationNode::newEnumValueGeneric( $ 1, $2); }2617 visible_hide_opt identifier_or_type_name enumerator_value_opt 2618 { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); } 2606 2619 | INLINE type_name 2607 2620 { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); } 2608 | enumerator_list ',' identifier_or_type_name enumerator_value_opt2609 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $ 3, $4) ); }2621 | enumerator_list ',' visible_hide_opt identifier_or_type_name enumerator_value_opt 2622 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $4, $5 ) ); } 2610 2623 | enumerator_list ',' INLINE type_name enumerator_value_opt 2611 2624 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); } 2625 ; 2626 2627 visible_hide_opt: 2628 hide_opt 2629 | '^' 2630 { $$ = EnumHiding::Visible; } 2612 2631 ; 2613 2632
Note:
See TracChangeset
for help on using the changeset viewer.