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