Changeset 3b56166 for src/Parser/parser.yy
- Timestamp:
- Feb 10, 2020, 11:17:38 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3966d9a, 41efd33
- Parents:
- 807a632 (diff), d231700 (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. - File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r807a632 r3b56166 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Aug 4 21:48:23 201913 // Update Count : 4 36412 // Last Modified On : Sat Feb 1 10:04:40 2020 13 // Update Count : 4440 14 14 // 15 15 … … 51 51 using namespace std; 52 52 53 #include "SynTree/Declaration.h" 53 54 #include "ParseNode.h" 54 55 #include "TypedefTable.h" 55 56 #include "TypeData.h" 56 #include " LinkageSpec.h"57 #include "SynTree/LinkageSpec.h" 57 58 #include "Common/SemanticError.h" // error_str 58 59 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 211 212 } // forCtrl 212 213 213 214 214 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 215 215 … … 237 237 ExpressionNode * en; 238 238 DeclarationNode * decl; 239 DeclarationNode::Aggregate aggKey;240 DeclarationNode::TypeClasstclass;239 AggregateDecl::Aggregate aggKey; 240 TypeDecl::Kind tclass; 241 241 StatementNode * sn; 242 242 WaitForStmt * wfs; … … 323 323 %type<op> ptrref_operator unary_operator assignment_operator 324 324 %type<en> primary_expression postfix_expression unary_expression 325 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression325 %type<en> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression 326 326 %type<en> shift_expression relational_expression equality_expression 327 327 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression … … 365 365 %type<decl> abstract_parameter_declaration 366 366 367 %type<aggKey> aggregate_key 367 %type<aggKey> aggregate_key aggregate_data aggregate_control 368 368 %type<decl> aggregate_type aggregate_type_nobody 369 369 … … 579 579 | '(' compound_statement ')' // GCC, lambda expression 580 580 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 581 | constant '`' IDENTIFIER // CFA, postfix call582 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }583 | string_literal '`' IDENTIFIER // CFA, postfix call584 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }585 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call586 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }587 | tuple '`' IDENTIFIER // CFA, postfix call588 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }591 581 | type_name '.' identifier // CFA, nested type 592 582 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } … … 642 632 | postfix_expression '(' argument_expression_list ')' 643 633 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 634 | postfix_expression '`' identifier // CFA, postfix call 635 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 636 | constant '`' identifier // CFA, postfix call 637 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 638 | string_literal '`' identifier // CFA, postfix call 639 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); } 644 640 | postfix_expression '.' identifier 645 641 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } … … 650 646 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 651 647 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 648 | postfix_expression '.' aggregate_control 649 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); } 652 650 | postfix_expression ARROW identifier 653 651 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 664 662 | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal 665 663 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 666 | '^' primary_expression '{' argument_expression_list '}' // CFA 664 | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call 667 665 { 668 666 Token fn; … … 677 675 | argument_expression 678 676 | argument_expression_list ',' argument_expression 679 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }677 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 680 678 ; 681 679 … … 689 687 field_name_list: // CFA, tuple field selector 690 688 field 691 | field_name_list ',' field { $$ = (ExpressionNode *) $1->set_last( $3); }689 | field_name_list ',' field { $$ = (ExpressionNode *)($1->set_last( $3 )); } 692 690 ; 693 691 … … 793 791 | '(' type_no_function ')' cast_expression 794 792 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 795 // keyword cast cannot be grouped because of reduction in aggregate_key 796 | '(' GENERATOR '&' ')' cast_expression // CFA 797 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 798 | '(' COROUTINE '&' ')' cast_expression // CFA 799 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 800 | '(' THREAD '&' ')' cast_expression // CFA 801 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 802 | '(' MONITOR '&' ')' cast_expression // CFA 803 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 793 | '(' aggregate_control '&' ')' cast_expression // CFA 794 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 804 795 // VIRTUAL cannot be opt because of look ahead issues 805 796 | '(' VIRTUAL ')' cast_expression // CFA … … 965 956 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 966 957 | '[' push assignment_expression pop ',' tuple_expression_list ']' 967 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *) $3->set_last( $6 ) )); }958 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); } 968 959 ; 969 960 … … 971 962 assignment_expression_opt 972 963 | tuple_expression_list ',' assignment_expression_opt 973 { $$ = (ExpressionNode *) $1->set_last( $3); }964 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 974 965 ; 975 966 … … 1195 1186 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1196 1187 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1188 | '=' comma_expression // CFA 1189 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1190 OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1197 1191 | comma_expression inclexcl comma_expression // CFA 1198 1192 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1202 1196 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1203 1197 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1198 | comma_expression ';' '=' comma_expression // CFA 1199 { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1200 OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1204 1201 | comma_expression ';' comma_expression inclexcl comma_expression // CFA 1205 1202 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1306 1303 WAITFOR '(' cast_expression ')' 1307 1304 { $$ = $3; } 1308 | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1309 { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1305 // | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1306 // { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1307 | WAITFOR '(' cast_expression_list ':' argument_expression_list ')' 1308 { $$ = (ExpressionNode *)($3->set_last( $5 )); } 1309 ; 1310 1311 cast_expression_list: 1312 cast_expression 1313 | cast_expression_list ',' cast_expression 1314 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1310 1315 ; 1311 1316 … … 1418 1423 asm_operand 1419 1424 | asm_operands_list ',' asm_operand 1420 { $$ = (ExpressionNode *) $1->set_last( $3); }1425 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1421 1426 ; 1422 1427 1423 1428 asm_operand: // GCC 1424 1429 string_literal '(' constant_expression ')' 1425 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }1426 | '[' constant_expression']' string_literal '(' constant_expression ')'1427 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }1430 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); } 1431 | '[' IDENTIFIER ']' string_literal '(' constant_expression ')' 1432 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); } 1428 1433 ; 1429 1434 … … 1434 1439 { $$ = new ExpressionNode( $1 ); } 1435 1440 | asm_clobbers_list_opt ',' string_literal 1436 // set_last returns ParseNode * 1437 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 1441 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); } 1438 1442 ; 1439 1443 … … 2059 2063 2060 2064 aggregate_key: 2065 aggregate_data 2066 | aggregate_control 2067 ; 2068 2069 aggregate_data: 2061 2070 STRUCT 2062 { yyy = true; $$ = DeclarationNode::Struct; }2071 { yyy = true; $$ = AggregateDecl::Struct; } 2063 2072 | UNION 2064 { yyy = true; $$ = DeclarationNode::Union; } 2065 | EXCEPTION 2066 { yyy = true; $$ = DeclarationNode::Exception; } 2067 | GENERATOR 2068 { yyy = true; $$ = DeclarationNode::Coroutine; } 2073 { yyy = true; $$ = AggregateDecl::Union; } 2074 | EXCEPTION // CFA 2075 { yyy = true; $$ = AggregateDecl::Exception; } 2076 ; 2077 2078 aggregate_control: // CFA 2079 GENERATOR 2080 { yyy = true; $$ = AggregateDecl::Coroutine; } 2069 2081 | COROUTINE 2070 { yyy = true; $$ = DeclarationNode::Coroutine; }2082 { yyy = true; $$ = AggregateDecl::Coroutine; } 2071 2083 | MONITOR 2072 { yyy = true; $$ = DeclarationNode::Monitor; }2084 { yyy = true; $$ = AggregateDecl::Monitor; } 2073 2085 | THREAD 2074 { yyy = true; $$ = DeclarationNode::Thread; }2086 { yyy = true; $$ = AggregateDecl::Thread; } 2075 2087 ; 2076 2088 … … 2096 2108 distInl( $3 ); 2097 2109 } 2110 | INLINE aggregate_control ';' // CFA 2111 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; } 2098 2112 | typedef_declaration ';' // CFA 2099 2113 | cfa_field_declaring_list ';' // CFA, new style field declaration … … 2348 2362 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 2349 2363 | initializer_list_opt ',' designation initializer 2350 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) )); }2364 { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); } 2351 2365 ; 2352 2366 … … 2370 2384 designator 2371 2385 | designator_list designator 2372 { $$ = (ExpressionNode *)( $1->set_last( $2 )); }2386 { $$ = (ExpressionNode *)($1->set_last( $2 )); } 2373 2387 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 2374 2388 ; … … 2426 2440 | type_specifier identifier_parameter_declarator 2427 2441 | assertion_list 2428 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2442 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2429 2443 ; 2430 2444 2431 2445 type_class: // CFA 2432 2446 OTYPE 2433 { $$ = DeclarationNode::Otype; }2447 { $$ = TypeDecl::Otype; } 2434 2448 | DTYPE 2435 { $$ = DeclarationNode::Dtype; }2449 { $$ = TypeDecl::Dtype; } 2436 2450 | FTYPE 2437 { $$ = DeclarationNode::Ftype; }2451 { $$ = TypeDecl::Ftype; } 2438 2452 | TTYPE 2439 { $$ = DeclarationNode::Ttype; }2453 { $$ = TypeDecl::Ttype; } 2440 2454 ; 2441 2455 … … 2467 2481 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; } 2468 2482 | type_list ',' type 2469 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }2483 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); } 2470 2484 | type_list ',' assignment_expression 2471 2485 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; } … … 2578 2592 { 2579 2593 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2580 linkage = LinkageSpec:: linkageUpdate( yylloc, linkage, $2 );2594 linkage = LinkageSpec::update( yylloc, linkage, $2 ); 2581 2595 } 2582 2596 '{' up external_definition_list_opt down '}'
Note:
See TracChangeset
for help on using the changeset viewer.