Changes in src/Parser/parser.yy [9a705dc8:a16764a6]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r9a705dc8 ra16764a6 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Apr 17 17:10:30201813 // Update Count : 3 14412 // Last Modified On : Thu Feb 22 17:48:54 2018 13 // Update Count : 3028 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_name134 128 135 129 bool forall = false; // aggregate have one or more forall qualifiers ? … … 260 254 %type<sn> statement_decl statement_decl_list statement_list_nodecl 261 255 %type<sn> selection_statement 262 %type<sn> switch_clause_list_opt switch_clause_list 256 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 263 257 %type<en> case_value 264 258 %type<sn> case_clause case_value_list case_label case_label_list 259 %type<sn> fall_through fall_through_opt 265 260 %type<sn> iteration_statement jump_statement 266 261 %type<sn> expression_statement asm_statement … … 391 386 %precedence '(' 392 387 393 %locations // support location tracking for error messages388 %locations // support location tracking for error messages 394 389 395 390 %start translation_unit // parse-tree root … … 486 481 | '(' compound_statement ')' // GCC, lambda expression 487 482 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 488 | constant '`' IDENTIFIER // CFA, postfix call489 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }490 | string_literal '`' IDENTIFIER // CFA, postfix call491 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }492 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call493 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }494 | tuple '`' IDENTIFIER // CFA, postfix call495 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }496 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call497 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }498 483 | type_name '.' no_attr_identifier // CFA, nested type 499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 484 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 500 485 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 486 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME 502 487 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } 488 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME 504 489 ; 505 490 … … 550 535 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 551 536 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 552 | '(' type_no_function ')' '@' '{' initializer_list comma_opt '}' // CFA, explicit C compound-literal553 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }554 537 | '^' primary_expression '{' argument_expression_list '}' // CFA 555 538 { … … 687 670 | '(' type_no_function ')' cast_expression 688 671 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 689 | '(' COROUTINE '&' ')' cast_expression // CFA690 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }691 | '(' THREAD '&' ')' cast_expression // CFA692 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }693 | '(' MONITOR '&' ')' cast_expression // CFA694 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }695 672 // VIRTUAL cannot be opt because of look ahead issues 696 | '(' VIRTUAL ')' cast_expression // CFA673 | '(' VIRTUAL ')' cast_expression 697 674 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); } 698 | '(' VIRTUAL type_no_function ')' cast_expression // CFA675 | '(' VIRTUAL type_no_function ')' cast_expression 699 676 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); } 700 677 // | '(' type_no_function ')' tuple … … 788 765 | logical_OR_expression '?' comma_expression ':' conditional_expression 789 766 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 790 // FIX ME: computes $1 twice767 // FIX ME: this hack computes $1 twice 791 768 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 792 769 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } … … 803 780 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 804 781 | unary_expression '=' '{' initializer_list comma_opt '}' 805 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } 782 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME 806 783 ; 807 784 … … 873 850 | exception_statement 874 851 | enable_disable_statement 875 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 852 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 876 853 | asm_statement 877 854 ; … … 940 917 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 941 918 | SWITCH '(' comma_expression ')' case_clause 942 { $$ = new StatementNode( build_switch( true,$3, $5 ) ); }919 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 943 920 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 944 921 { 945 StatementNode *sw = new StatementNode( build_switch( true,$3, $8 ) );922 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 946 923 // The semantics of the declaration list is changed to include associated initialization, which is performed 947 924 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 952 929 } 953 930 | CHOOSE '(' comma_expression ')' case_clause // CFA 954 { $$ = new StatementNode( build_switch( false,$3, $5 ) ); }955 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA956 { 957 StatementNode *sw = new StatementNode( build_switch( false,$3, $8 ) );931 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 932 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA 933 { 934 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 958 935 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 959 936 } … … 993 970 ; 994 971 995 //label_list_opt:996 // // empty997 // | identifier_or_type_name ':'998 // | label_list_opt identifier_or_type_name ':'999 // ;1000 1001 972 case_label_list: // CFA 1002 973 case_label … … 1019 990 | switch_clause_list case_label_list statement_list_nodecl 1020 991 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 992 ; 993 994 choose_clause_list_opt: // CFA 995 // empty 996 { $$ = nullptr; } 997 | choose_clause_list 998 ; 999 1000 choose_clause_list: // CFA 1001 case_label_list fall_through 1002 { $$ = $1->append_last_case( $2 ); } 1003 | case_label_list statement_list_nodecl fall_through_opt 1004 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); } 1005 | choose_clause_list case_label_list fall_through 1006 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); } 1007 | choose_clause_list case_label_list statement_list_nodecl fall_through_opt 1008 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); } 1009 ; 1010 1011 fall_through_opt: // CFA 1012 // empty 1013 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break 1014 | fall_through 1015 ; 1016 1017 fall_through_name: // CFA 1018 FALLTHRU 1019 | FALLTHROUGH 1020 ; 1021 1022 fall_through: // CFA 1023 fall_through_name 1024 { $$ = nullptr; } 1025 | fall_through_name ';' 1026 { $$ = nullptr; } 1021 1027 ; 1022 1028 … … 1044 1050 // whereas normal operator precedence yields goto (*i)+3; 1045 1051 { $$ = 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 ';' // CFA1048 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }1049 | fall_through_name identifier_or_type_name ';' // CFA1050 { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }1051 | fall_through_name DEFAULT ';' // CFA1052 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }1053 1052 | CONTINUE ';' 1054 1053 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. … … 1068 1067 { $$ = new StatementNode( build_return( $2 ) ); } 1069 1068 | RETURN '{' initializer_list comma_opt '}' 1070 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1069 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME 1071 1070 | THROW assignment_expression_opt ';' // handles rethrow 1072 1071 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1077 1076 ; 1078 1077 1079 fall_through_name: // CFA1080 FALLTHRU1081 | FALLTHROUGH1082 ;1083 1084 1078 with_statement: 1085 1079 WITH '(' tuple_expression_list ')' statement … … 1092 1086 mutex_statement: 1093 1087 MUTEX '(' argument_expression_list ')' statement 1094 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } 1088 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 1095 1089 ; 1096 1090 1097 1091 when_clause: 1098 WHEN '(' comma_expression ')' { $$ = $3; } 1092 WHEN '(' comma_expression ')' 1093 { $$ = $3; } 1099 1094 ; 1100 1095 … … 1120 1115 1121 1116 timeout: 1122 TIMEOUT '(' comma_expression ')' { $$ = $3; } 1117 TIMEOUT '(' comma_expression ')' 1118 { $$ = $3; } 1123 1119 ; 1124 1120 … … 1163 1159 //empty 1164 1160 { $$ = nullptr; } 1165 | ';' conditional_expression { $$ = $2; } 1161 | ';' conditional_expression 1162 { $$ = $2; } 1166 1163 ; 1167 1164 1168 1165 handler_key: 1169 CATCH { $$ = CatchStmt::Terminate; } 1170 | CATCHRESUME { $$ = CatchStmt::Resume; } 1166 CATCH 1167 { $$ = CatchStmt::Terminate; } 1168 | CATCHRESUME 1169 { $$ = CatchStmt::Resume; } 1171 1170 ; 1172 1171 1173 1172 finally_clause: 1174 FINALLY compound_statement { $$ = new StatementNode( build_finally( $2 ) ); } 1173 FINALLY compound_statement 1174 { 1175 $$ = new StatementNode( build_finally( $2 ) ); 1176 } 1175 1177 ; 1176 1178 … … 1314 1316 static_assert: 1315 1317 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1316 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }1318 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME 1317 1319 1318 1320 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 1708 1710 | LONG 1709 1711 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1712 | ZERO_T 1713 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1714 | ONE_T 1715 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1710 1716 | VALIST // GCC, __builtin_va_list 1711 1717 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1727 1733 basic_type_specifier: 1728 1734 direct_type 1729 // Cannot have type modifiers, e.g., short, long, etc.1730 1735 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1731 1736 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } … … 1733 1738 1734 1739 direct_type: 1740 // A semantic check is necessary for conflicting type qualifiers. 1735 1741 basic_type_name 1736 1742 | type_qualifier_list basic_type_name … … 1751 1757 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; 1752 1758 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1753 | ZERO_T // CFA1754 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }1755 | ONE_T // CFA1756 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }1757 1759 ; 1758 1760 … … 2411 2413 $$ = $2; 2412 2414 } 2413 | type_qualifier_list'{' external_definition_list '}' // CFA, namespace2415 | forall '{' external_definition_list '}' // CFA, namespace 2414 2416 ; 2415 2417
Note:
See TracChangeset
for help on using the changeset viewer.