Changeset 9f4af04
- Timestamp:
- Mar 6, 2024, 1:59:33 PM (2 months ago)
- Branches:
- master
- Children:
- 169496e1
- Parents:
- e72fc60 (diff), b93c544 (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
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
re72fc60 r9f4af04 763 763 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 764 764 // Current: Commas in subscripts make tuples. 765 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }765 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, $3->set_last( $5 ) ) ) ) ); } 766 766 | postfix_expression '[' assignment_expression ']' 767 767 // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a … … 778 778 Token fn; 779 779 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 780 $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );780 $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), $1->set_last( $3 ) ) ) ); 781 781 } 782 782 | postfix_expression '(' argument_expression_list_opt ')' … … 784 784 | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')' 785 785 // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; } 786 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg" ) ) ),787 (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }786 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg" ) ) ), 787 $3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) ) ) ); } 788 788 | postfix_expression '`' identifier // CFA, postfix call 789 789 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); } … … 843 843 Token fn; 844 844 fn.str = new string( "^?{}" ); // location undefined 845 $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );845 $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), $2->set_last( $4 ) ) ); 846 846 } 847 847 ; … … 856 856 argument_expression 857 857 | argument_expression_list_opt ',' argument_expression 858 { $$ = (ExpressionNode *)($1->set_last( $3 )); }858 { $$ = $1->set_last( $3 ); } 859 859 ; 860 860 … … 868 868 field_name_list: // CFA, tuple field selector 869 869 field 870 | field_name_list ',' field { $$ = (ExpressionNode *)($1->set_last( $3 )); }870 | field_name_list ',' field { $$ = $1->set_last( $3 ); } 871 871 ; 872 872 … … 1162 1162 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 1163 1163 '[' ',' tuple_expression_list ']' 1164 { $$ = new ExpressionNode( build_tuple( yylloc, ( ExpressionNode *)(new ExpressionNode( nullptr ))->set_last( $3 ) ) ); }1164 { $$ = new ExpressionNode( build_tuple( yylloc, (new ExpressionNode( nullptr ))->set_last( $3 ) ) ); } 1165 1165 | '[' push assignment_expression pop ',' tuple_expression_list ']' 1166 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $6 ) ) )); }1166 { $$ = new ExpressionNode( build_tuple( yylloc, $3->set_last( $6 ) ) ); } 1167 1167 ; 1168 1168 … … 1172 1172 { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; } 1173 1173 | tuple_expression_list ',' assignment_expression 1174 { $$ = (ExpressionNode *)($1->set_last( $3 )); }1174 { $$ = $1->set_last( $3 ); } 1175 1175 | tuple_expression_list ',' '@' 1176 1176 { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; } … … 1307 1307 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 1308 1308 // statement. 1309 $$ = $7 ? new StatementNode( build_compound( yylloc, ( StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;1309 $$ = $7 ? new StatementNode( build_compound( yylloc, (new StatementNode( $7 ))->set_last( sw ) ) ) : sw; 1310 1310 } 1311 1311 | SWITCH '(' comma_expression ')' '{' error '}' // CFA, invalid syntax rule error … … 1316 1316 { 1317 1317 StatementNode *sw = new StatementNode( build_switch( yylloc, false, $3, $8 ) ); 1318 $$ = $7 ? new StatementNode( build_compound( yylloc, ( StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;1318 $$ = $7 ? new StatementNode( build_compound( yylloc, (new StatementNode( $7 ))->set_last( sw ) ) ) : sw; 1319 1319 } 1320 1320 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA, invalid syntax rule … … 1718 1718 cast_expression 1719 1719 | cast_expression_list ',' cast_expression 1720 // { $$ = (ExpressionNode *)($1->set_last( $3 )); }1721 1720 { SemanticError( yylloc, "List of mutex member is currently unimplemented." ); $$ = nullptr; } 1722 1721 ; … … 1734 1733 { $$ = $3; } 1735 1734 | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')' 1736 { $$ = (ExpressionNode *)($3->set_last( $5 )); }1735 { $$ = $3->set_last( $5 ); } 1737 1736 ; 1738 1737 … … 1890 1889 asm_operand 1891 1890 | asm_operands_list ',' asm_operand 1892 { $$ = (ExpressionNode *)($1->set_last( $3 )); }1891 { $$ = $1->set_last( $3 ); } 1893 1892 ; 1894 1893 … … 1909 1908 { $$ = $1; } 1910 1909 | asm_clobbers_list_opt ',' string_literal 1911 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }1910 { $$ = $1->set_last( $3 ); } 1912 1911 ; 1913 1912 … … 2975 2974 | initializer 2976 2975 | designation initializer { $$ = $2->set_designators( $1 ); } 2977 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 )); }2978 | initializer_list_opt ',' designation initializer { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }2976 | initializer_list_opt ',' initializer { $$ = $1->set_last( $3 ); } 2977 | initializer_list_opt ',' designation initializer { $$ = $1->set_last( $4->set_designators( $3 ) ); } 2979 2978 ; 2980 2979 … … 2998 2997 designator 2999 2998 | designator_list designator 3000 { $$ = (ExpressionNode *)($1->set_last( $2 )); }2999 { $$ = $1->set_last( $2 ); } 3001 3000 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 3002 3001 ; … … 3127 3126 | assignment_expression 3128 3127 | type_list ',' type 3129 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }3128 { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); } 3130 3129 | type_list ',' assignment_expression 3131 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }3130 { $$ = $1->set_last( $3 ); } 3132 3131 ; 3133 3132 … … 3966 3965 | assignment_expression upupeq assignment_expression 3967 3966 | array_type_list ',' basic_type_name 3968 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }3967 { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); } 3969 3968 | array_type_list ',' type_name 3970 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }3969 { $$ = $1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) ); } 3971 3970 | array_type_list ',' assignment_expression upupeq assignment_expression 3972 3971 ;
Note: See TracChangeset
for help on using the changeset viewer.