Changeset 1cdfa82 for src/Parser/parser.yy
- Timestamp:
- Apr 25, 2018, 4:55:53 PM (8 years ago)
- Branches:
- new-env, with_gc
- Children:
- 42107b4
- Parents:
- 2efe4b8 (diff), 9d5fb67 (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) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r2efe4b8 r1cdfa82 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 22 17:48:54201813 // Update Count : 3 02812 // Last Modified On : Tue Apr 17 17:10:30 2018 13 // Update Count : 3144 14 14 // 15 15 … … 126 126 } // if 127 127 } // rebindForall 128 129 NameExpr * build_postfix_name( const string * name ) { 130 NameExpr * new_name = build_varref( new string( "?`" + *name ) ); 131 delete name; 132 return new_name; 133 } // build_postfix_name 128 134 129 135 bool forall = false; // aggregate have one or more forall qualifiers ? … … 254 260 %type<sn> statement_decl statement_decl_list statement_list_nodecl 255 261 %type<sn> selection_statement 256 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list262 %type<sn> switch_clause_list_opt switch_clause_list 257 263 %type<en> case_value 258 264 %type<sn> case_clause case_value_list case_label case_label_list 259 %type<sn> fall_through fall_through_opt260 265 %type<sn> iteration_statement jump_statement 261 266 %type<sn> expression_statement asm_statement … … 386 391 %precedence '(' 387 392 388 %locations // support location tracking for error messages393 %locations // support location tracking for error messages 389 394 390 395 %start translation_unit // parse-tree root … … 481 486 | '(' compound_statement ')' // GCC, lambda expression 482 487 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 488 | constant '`' IDENTIFIER // CFA, postfix call 489 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 490 | string_literal '`' IDENTIFIER // CFA, postfix call 491 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); } 492 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call 493 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); } 494 | tuple '`' IDENTIFIER // CFA, postfix call 495 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 496 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 497 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 483 498 | type_name '.' no_attr_identifier // CFA, nested type 484 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 485 500 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 486 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 487 502 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 488 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } 489 504 ; 490 505 … … 535 550 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 536 551 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 552 | '(' type_no_function ')' '@' '{' initializer_list comma_opt '}' // CFA, explicit C compound-literal 553 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 537 554 | '^' primary_expression '{' argument_expression_list '}' // CFA 538 555 { … … 670 687 | '(' type_no_function ')' cast_expression 671 688 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 689 | '(' COROUTINE '&' ')' cast_expression // CFA 690 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 691 | '(' THREAD '&' ')' cast_expression // CFA 692 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 693 | '(' MONITOR '&' ')' cast_expression // CFA 694 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 672 695 // VIRTUAL cannot be opt because of look ahead issues 673 | '(' VIRTUAL ')' cast_expression 696 | '(' VIRTUAL ')' cast_expression // CFA 674 697 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); } 675 | '(' VIRTUAL type_no_function ')' cast_expression 698 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 676 699 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); } 677 700 // | '(' type_no_function ')' tuple … … 765 788 | logical_OR_expression '?' comma_expression ':' conditional_expression 766 789 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 767 // FIX ME: this hackcomputes $1 twice790 // FIX ME: computes $1 twice 768 791 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 769 792 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } … … 780 803 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 804 | unary_expression '=' '{' initializer_list comma_opt '}' 782 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME805 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } 783 806 ; 784 807 … … 850 873 | exception_statement 851 874 | enable_disable_statement 852 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME875 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 853 876 | asm_statement 854 877 ; … … 917 940 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 918 941 | SWITCH '(' comma_expression ')' case_clause 919 { $$ = new StatementNode( build_switch( $3, $5 ) ); }942 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); } 920 943 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 921 944 { 922 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );945 StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) ); 923 946 // The semantics of the declaration list is changed to include associated initialization, which is performed 924 947 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 929 952 } 930 953 | CHOOSE '(' comma_expression ')' case_clause // CFA 931 { $$ = new StatementNode( build_switch( $3, $5 ) ); }932 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA933 { 934 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );954 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } 955 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 956 { 957 StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) ); 935 958 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 936 959 } … … 970 993 ; 971 994 995 //label_list_opt: 996 // // empty 997 // | identifier_or_type_name ':' 998 // | label_list_opt identifier_or_type_name ':' 999 // ; 1000 972 1001 case_label_list: // CFA 973 1002 case_label … … 990 1019 | switch_clause_list case_label_list statement_list_nodecl 991 1020 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 992 ;993 994 choose_clause_list_opt: // CFA995 // empty996 { $$ = nullptr; }997 | choose_clause_list998 ;999 1000 choose_clause_list: // CFA1001 case_label_list fall_through1002 { $$ = $1->append_last_case( $2 ); }1003 | case_label_list statement_list_nodecl fall_through_opt1004 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }1005 | choose_clause_list case_label_list fall_through1006 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }1007 | choose_clause_list case_label_list statement_list_nodecl fall_through_opt1008 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }1009 ;1010 1011 fall_through_opt: // CFA1012 // empty1013 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break1014 | fall_through1015 ;1016 1017 fall_through_name: // CFA1018 FALLTHRU1019 | FALLTHROUGH1020 ;1021 1022 fall_through: // CFA1023 fall_through_name1024 { $$ = nullptr; }1025 | fall_through_name ';'1026 { $$ = nullptr; }1027 1021 ; 1028 1022 … … 1050 1044 // whereas normal operator precedence yields goto (*i)+3; 1051 1045 { $$ = new StatementNode( build_computedgoto( $3 ) ); } 1046 // A semantic check is required to ensure fallthru appears only in the body of a choose statement. 1047 | fall_through_name ';' // CFA 1048 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); } 1049 | fall_through_name identifier_or_type_name ';' // CFA 1050 { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); } 1051 | fall_through_name DEFAULT ';' // CFA 1052 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); } 1052 1053 | CONTINUE ';' 1053 1054 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. … … 1067 1068 { $$ = new StatementNode( build_return( $2 ) ); } 1068 1069 | RETURN '{' initializer_list comma_opt '}' 1069 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME1070 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1070 1071 | THROW assignment_expression_opt ';' // handles rethrow 1071 1072 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1076 1077 ; 1077 1078 1079 fall_through_name: // CFA 1080 FALLTHRU 1081 | FALLTHROUGH 1082 ; 1083 1078 1084 with_statement: 1079 1085 WITH '(' tuple_expression_list ')' statement … … 1086 1092 mutex_statement: 1087 1093 MUTEX '(' argument_expression_list ')' statement 1088 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME1094 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } 1089 1095 ; 1090 1096 1091 1097 when_clause: 1092 WHEN '(' comma_expression ')' 1093 { $$ = $3; } 1098 WHEN '(' comma_expression ')' { $$ = $3; } 1094 1099 ; 1095 1100 … … 1115 1120 1116 1121 timeout: 1117 TIMEOUT '(' comma_expression ')' 1118 { $$ = $3; } 1122 TIMEOUT '(' comma_expression ')' { $$ = $3; } 1119 1123 ; 1120 1124 … … 1159 1163 //empty 1160 1164 { $$ = nullptr; } 1161 | ';' conditional_expression 1162 { $$ = $2; } 1165 | ';' conditional_expression { $$ = $2; } 1163 1166 ; 1164 1167 1165 1168 handler_key: 1166 CATCH 1167 { $$ = CatchStmt::Terminate; } 1168 | CATCHRESUME 1169 { $$ = CatchStmt::Resume; } 1169 CATCH { $$ = CatchStmt::Terminate; } 1170 | CATCHRESUME { $$ = CatchStmt::Resume; } 1170 1171 ; 1171 1172 1172 1173 finally_clause: 1173 FINALLY compound_statement 1174 { 1175 $$ = new StatementNode( build_finally( $2 ) ); 1176 } 1174 FINALLY compound_statement { $$ = new StatementNode( build_finally( $2 ) ); } 1177 1175 ; 1178 1176 … … 1316 1314 static_assert: 1317 1315 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1318 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME1316 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); } 1319 1317 1320 1318 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 1710 1708 | LONG 1711 1709 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1712 | ZERO_T1713 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }1714 | ONE_T1715 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }1716 1710 | VALIST // GCC, __builtin_va_list 1717 1711 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1733 1727 basic_type_specifier: 1734 1728 direct_type 1729 // Cannot have type modifiers, e.g., short, long, etc. 1735 1730 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1736 1731 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } … … 1738 1733 1739 1734 direct_type: 1740 // A semantic check is necessary for conflicting type qualifiers.1741 1735 basic_type_name 1742 1736 | type_qualifier_list basic_type_name … … 1757 1751 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; 1758 1752 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1753 | ZERO_T // CFA 1754 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1755 | ONE_T // CFA 1756 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1759 1757 ; 1760 1758 … … 2413 2411 $$ = $2; 2414 2412 } 2415 | forall'{' external_definition_list '}' // CFA, namespace2413 | type_qualifier_list '{' external_definition_list '}' // CFA, namespace 2416 2414 ; 2417 2415
Note:
See TracChangeset
for help on using the changeset viewer.