Changeset b7d6a36 for src/Parser/parser.yy
- Timestamp:
- Feb 20, 2020, 4:15:51 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 6a490b2
- Parents:
- dca5802 (diff), 2cbfe92 (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) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rdca5802 rb7d6a36 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 10 23:07:17 201913 // Update Count : 44 0012 // Last Modified On : Sun Feb 16 08:22:14 2020 13 // Update Count : 4461 14 14 // 15 15 … … 55 55 #include "TypedefTable.h" 56 56 #include "TypeData.h" 57 #include " LinkageSpec.h"57 #include "SynTree/LinkageSpec.h" 58 58 #include "Common/SemanticError.h" // error_str 59 59 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 166 166 } // rebindForall 167 167 168 NameExpr * build_postfix_name( const string * name ) { 169 NameExpr * new_name = build_varref( new string( "?`" + *name ) ); 170 delete name; 171 return new_name; 168 string * build_postfix_name( string * name ) { 169 *name = string("__postfix_func_") + *name; 170 return name; 172 171 } // build_postfix_name 173 172 … … 238 237 DeclarationNode * decl; 239 238 AggregateDecl::Aggregate aggKey; 240 DeclarationNode::TypeClasstclass;239 TypeDecl::Kind tclass; 241 240 StatementNode * sn; 242 241 WaitForStmt * wfs; … … 323 322 %type<op> ptrref_operator unary_operator assignment_operator 324 323 %type<en> primary_expression postfix_expression unary_expression 325 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression324 %type<en> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression 326 325 %type<en> shift_expression relational_expression equality_expression 327 326 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression … … 579 578 | '(' compound_statement ')' // GCC, lambda expression 580 579 { $$ = 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 580 | type_name '.' identifier // CFA, nested type 592 581 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } … … 642 631 | postfix_expression '(' argument_expression_list ')' 643 632 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 633 | postfix_expression '`' identifier // CFA, postfix call 634 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); } 635 | constant '`' identifier // CFA, postfix call 636 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); } 637 | string_literal '`' identifier // CFA, postfix call 638 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); } 644 639 | postfix_expression '.' identifier 645 640 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } … … 666 661 | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal 667 662 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 668 | '^' primary_expression '{' argument_expression_list '}' // CFA 663 | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call 669 664 { 670 665 Token fn; … … 679 674 | argument_expression 680 675 | argument_expression_list ',' argument_expression 681 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }676 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 682 677 ; 683 678 … … 691 686 field_name_list: // CFA, tuple field selector 692 687 field 693 | field_name_list ',' field { $$ = (ExpressionNode *) $1->set_last( $3); }688 | field_name_list ',' field { $$ = (ExpressionNode *)($1->set_last( $3 )); } 694 689 ; 695 690 … … 960 955 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 961 956 | '[' push assignment_expression pop ',' tuple_expression_list ']' 962 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *) $3->set_last( $6 ) )); }957 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); } 963 958 ; 964 959 … … 966 961 assignment_expression_opt 967 962 | tuple_expression_list ',' assignment_expression_opt 968 { $$ = (ExpressionNode *) $1->set_last( $3); }963 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 969 964 ; 970 965 … … 1190 1185 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1191 1186 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1187 | '=' comma_expression // CFA 1188 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1189 OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1192 1190 | comma_expression inclexcl comma_expression // CFA 1193 1191 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1197 1195 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1198 1196 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1197 | comma_expression ';' '=' comma_expression // CFA 1198 { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1199 OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1199 1200 | comma_expression ';' comma_expression inclexcl comma_expression // CFA 1200 1201 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } … … 1301 1302 WAITFOR '(' cast_expression ')' 1302 1303 { $$ = $3; } 1303 | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1304 { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1304 // | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1305 // { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1306 | WAITFOR '(' cast_expression_list ':' argument_expression_list ')' 1307 { $$ = (ExpressionNode *)($3->set_last( $5 )); } 1308 ; 1309 1310 cast_expression_list: 1311 cast_expression 1312 | cast_expression_list ',' cast_expression 1313 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1305 1314 ; 1306 1315 … … 1413 1422 asm_operand 1414 1423 | asm_operands_list ',' asm_operand 1415 { $$ = (ExpressionNode *) $1->set_last( $3); }1424 { $$ = (ExpressionNode *)($1->set_last( $3 )); } 1416 1425 ; 1417 1426 … … 1429 1438 { $$ = new ExpressionNode( $1 ); } 1430 1439 | asm_clobbers_list_opt ',' string_literal 1431 // set_last returns ParseNode * 1432 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 1440 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); } 1433 1441 ; 1434 1442 … … 2353 2361 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 2354 2362 | initializer_list_opt ',' designation initializer 2355 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) )); }2363 { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); } 2356 2364 ; 2357 2365 … … 2375 2383 designator 2376 2384 | designator_list designator 2377 { $$ = (ExpressionNode *)( $1->set_last( $2 )); }2385 { $$ = (ExpressionNode *)($1->set_last( $2 )); } 2378 2386 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 2379 2387 ; … … 2431 2439 | type_specifier identifier_parameter_declarator 2432 2440 | assertion_list 2433 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2441 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2434 2442 ; 2435 2443 2436 2444 type_class: // CFA 2437 2445 OTYPE 2438 { $$ = DeclarationNode::Otype; }2446 { $$ = TypeDecl::Otype; } 2439 2447 | DTYPE 2440 { $$ = DeclarationNode::Dtype; }2448 { $$ = TypeDecl::Dtype; } 2441 2449 | FTYPE 2442 { $$ = DeclarationNode::Ftype; }2450 { $$ = TypeDecl::Ftype; } 2443 2451 | TTYPE 2444 { $$ = DeclarationNode::Ttype; }2452 { $$ = TypeDecl::Ttype; } 2445 2453 ; 2446 2454 … … 2472 2480 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; } 2473 2481 | type_list ',' type 2474 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }2482 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); } 2475 2483 | type_list ',' assignment_expression 2476 2484 { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; } … … 2583 2591 { 2584 2592 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2585 linkage = LinkageSpec:: linkageUpdate( yylloc, linkage, $2 );2593 linkage = LinkageSpec::update( yylloc, linkage, $2 ); 2586 2594 } 2587 2595 '{' up external_definition_list_opt down '}'
Note:
See TracChangeset
for help on using the changeset viewer.