Changeset 342af53 for src/Parser
- Timestamp:
- Jan 14, 2021, 12:23:14 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8e4aa05
- Parents:
- 4468a70 (diff), ec19b21 (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:
-
- 3 edited
-
DeclarationNode.cc (modified) (2 diffs)
-
ParseNode.h (modified) (2 diffs)
-
parser.yy (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r4468a70 r342af53 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Oct 8 08:03:38 202013 // Update Count : 113 512 // Last Modified On : Mon Jan 11 20:58:07 2021 13 // Update Count : 1137 14 14 // 15 15 … … 1075 1075 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 1076 1076 // otype is internally converted to dtype + otype parameters 1077 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::D type, TypeDecl::Ftype, TypeDecl::Ttype };1078 static_assert( sizeof(kindMap) /sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );1077 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::DStype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::ALtype }; 1078 static_assert( sizeof(kindMap) / sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." ); 1079 1079 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1080 1080 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); -
src/Parser/ParseNode.h
r4468a70 r342af53 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Oct 24 03:53:54 202013 // Update Count : 89 512 // Last Modified On : Sun Jan 3 18:23:01 2021 13 // Update Count : 896 14 14 // 15 15 … … 39 39 struct DeclarationNode; 40 40 class DeclarationWithType; 41 class Initializer; 41 42 class ExpressionNode; 42 class Initializer;43 43 struct StatementNode; 44 44 -
src/Parser/parser.yy
r4468a70 r342af53 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 24 08:21:14 202013 // Update Count : 46 2412 // Last Modified On : Mon Jan 11 21:32:10 2021 13 // Update Count : 4633 14 14 // 15 15 … … 329 329 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 330 330 %type<en> comma_expression comma_expression_opt 331 %type<en> argument_expression_list_opt argument_expression default_initialize _opt331 %type<en> argument_expression_list_opt argument_expression default_initializer_opt 332 332 %type<ifctl> if_control_expression 333 333 %type<fctl> for_control_expression for_control_expression_list … … 424 424 %type<decl> sue_declaration_specifier sue_declaration_specifier_nobody sue_type_specifier sue_type_specifier_nobody 425 425 426 %type<tclass> type_class 426 %type<tclass> type_class new_type_class 427 427 %type<decl> type_declarator type_declarator_name type_declaring_list 428 428 … … 1545 1545 | cfa_function_declaration 1546 1546 | type_declaring_list 1547 { SemanticError( yylloc, "otype declaration is currently unimplemented." ); $$ = nullptr; } 1547 1548 | trait_specifier 1548 1549 ; … … 2223 2224 ; 2224 2225 2225 cfa_parameter_ellipsis_list_opt: // CFA, abstract + real2226 cfa_parameter_ellipsis_list_opt: // CFA, abstract + real 2226 2227 // empty 2227 2228 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 2280 2281 cfa_parameter_declaration: // CFA, new & old style parameter declaration 2281 2282 parameter_declaration 2282 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize _opt2283 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initializer_opt 2283 2284 { $$ = $1->addName( $2 ); } 2284 | cfa_abstract_tuple identifier_or_type_name default_initialize _opt2285 | cfa_abstract_tuple identifier_or_type_name default_initializer_opt 2285 2286 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 2286 2287 { $$ = $1->addName( $2 ); } 2287 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize _opt2288 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initializer_opt 2288 2289 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 2289 2290 | cfa_function_specifier … … 2302 2303 parameter_declaration: 2303 2304 // No SUE declaration in parameter list. 2304 declaration_specifier_nobody identifier_parameter_declarator default_initialize _opt2305 declaration_specifier_nobody identifier_parameter_declarator default_initializer_opt 2305 2306 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 2306 | declaration_specifier_nobody type_parameter_redeclarator default_initialize _opt2307 | declaration_specifier_nobody type_parameter_redeclarator default_initializer_opt 2307 2308 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 2308 2309 ; 2309 2310 2310 2311 abstract_parameter_declaration: 2311 declaration_specifier_nobody default_initialize _opt2312 declaration_specifier_nobody default_initializer_opt 2312 2313 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 2313 | declaration_specifier_nobody abstract_parameter_declarator default_initialize _opt2314 | declaration_specifier_nobody abstract_parameter_declarator default_initializer_opt 2314 2315 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 2315 2316 ; … … 2441 2442 type_class identifier_or_type_name 2442 2443 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2443 type_initializer_opt assertion_list_opt2444 type_initializer_opt assertion_list_opt 2444 2445 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2445 | type_specifier identifier_parameter_declarator 2446 | identifier_or_type_name new_type_class 2447 { typedefTable.addToScope( *$1, TYPEDEFname, "9" ); } 2448 type_initializer_opt assertion_list_opt 2449 { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2450 | '[' identifier_or_type_name ']' 2451 { 2452 typedefTable.addToScope( *$2, TYPEDEFname, "9" ); 2453 $$ = DeclarationNode::newTypeParam( TypeDecl::ALtype, $2 ); 2454 } 2455 // | type_specifier identifier_parameter_declarator 2446 2456 | assertion_list 2447 2457 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2458 ; 2459 2460 new_type_class: // CFA 2461 // empty 2462 { $$ = TypeDecl::Otype; } 2463 | '&' 2464 { $$ = TypeDecl::Dtype; } 2465 | '*' 2466 { $$ = TypeDecl::DStype; } // dtype + sized 2467 | ELLIPSIS 2468 { $$ = TypeDecl::Ttype; } 2448 2469 ; 2449 2470 … … 3476 3497 ; 3477 3498 3478 default_initialize _opt:3499 default_initializer_opt: 3479 3500 // empty 3480 3501 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.