Changeset 702e826 for src/Parser/parser.yy
- Timestamp:
- Mar 9, 2023, 2:37:53 PM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- fed03b3
- Parents:
- a29477f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
ra29477f r702e826 223 223 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->expr.get()); 224 224 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 225 type = new ExpressionNode( new CastExpr( maybeMoveBuild <Expression>(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );225 type = new ExpressionNode( new CastExpr( maybeMoveBuild( type ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 226 226 } // if 227 227 // type = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__for_control_index_constraints__" ) ) ), type ) ); … … 649 649 { $$ = $2; } 650 650 | '(' compound_statement ')' // GCC, lambda expression 651 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild <Statement>($2) ) ) ); }651 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild( $2 ) ) ) ); } 652 652 | type_name '.' identifier // CFA, nested type 653 653 { $$ = new ExpressionNode( build_qualified_expr( $1, build_varref( $3 ) ) ); } … … 657 657 { 658 658 // add the missing control expression to the GenericExpr and return it 659 $5->control = maybeMoveBuild <Expression>( $3 );659 $5->control = maybeMoveBuild( $3 ); 660 660 $$ = new ExpressionNode( $5 ); 661 661 } … … 693 693 { 694 694 // create a GenericExpr wrapper with one association pair 695 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild <Expression>( $3 ) } } );695 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild( $3 ) } } ); 696 696 } 697 697 | DEFAULT ':' assignment_expression 698 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild <Expression>( $3 ) } } ); }698 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild( $3 ) } } ); } 699 699 ; 700 700 … … 751 751 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 752 752 | postfix_expression ICR 753 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::IncrPost, $1 ) ); }753 { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); } 754 754 | postfix_expression DECR 755 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::DecrPost, $1 ) ); }755 { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); } 756 756 | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal 757 757 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } … … 793 793 field_name 794 794 | FLOATING_DECIMALconstant field 795 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild <Expression>( $2 ) ) ); }795 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild( $2 ) ) ); } 796 796 | FLOATING_DECIMALconstant '[' field_name_list ']' 797 797 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); } 798 798 | field_name '.' field 799 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild <Expression>( $3 ) ) ); }799 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild( $3 ) ) ); } 800 800 | field_name '.' '[' field_name_list ']' 801 801 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 802 802 | field_name ARROW field 803 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild <Expression>( $3 ) ) ); }803 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild( $3 ) ) ); } 804 804 | field_name ARROW '[' field_name_list ']' 805 805 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } … … 843 843 switch ( $1 ) { 844 844 case OperKinds::AddressOf: 845 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild <Expression>( $2 ) ) );845 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild( $2 ) ) ); 846 846 break; 847 847 case OperKinds::PointTo: … … 849 849 break; 850 850 case OperKinds::And: 851 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild <Expression>( $2 ) ) ) );851 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild( $2 ) ) ) ); 852 852 break; 853 853 default: … … 858 858 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); } 859 859 | ICR unary_expression 860 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::Incr, $2 ) ); }860 { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); } 861 861 | DECR unary_expression 862 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::Decr, $2 ) ); }862 { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); } 863 863 | SIZEOF unary_expression 864 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild <Expression>( $2 ) ) ); }864 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild( $2 ) ) ); } 865 865 | SIZEOF '(' type_no_function ')' 866 866 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuildType( $3 ) ) ); } 867 867 | ALIGNOF unary_expression // GCC, variable alignment 868 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild <Expression>( $2 ) ) ); }868 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild( $2 ) ) ); } 869 869 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 870 870 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } … … 901 901 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 902 902 | '(' VIRTUAL ')' cast_expression // CFA 903 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild <Expression>( $4 ), maybeMoveBuildType( nullptr ) ) ); }903 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); } 904 904 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 905 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild <Expression>( $5 ), maybeMoveBuildType( $3 ) ) ); }905 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); } 906 906 | '(' RETURN type_no_function ')' cast_expression // CFA 907 907 { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; } … … 1092 1092 assignment_expression 1093 1093 | comma_expression ',' assignment_expression 1094 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1094 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1095 1095 ; 1096 1096 … … 1230 1230 constant_expression { $$ = $1; } 1231 1231 | constant_expression ELLIPSIS constant_expression // GCC, subrange 1232 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1232 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1233 1233 | subrange // CFA, subrange 1234 1234 ; … … 1732 1732 asm_operand: // GCC 1733 1733 string_literal '(' constant_expression ')' 1734 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild <Expression>( $3 ) ) ); }1734 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild( $3 ) ) ); } 1735 1735 | '[' IDENTIFIER ']' string_literal '(' constant_expression ')' 1736 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild <Expression>( $6 ) ) ); }1736 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild( $6 ) ) ); } 1737 1737 ; 1738 1738 … … 2843 2843 { $$ = $3; } 2844 2844 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2845 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $3 ), maybeMoveBuild<Expression>( $5 ) ) ); }2845 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); } 2846 2846 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector 2847 2847 { $$ = $4; } … … 3231 3231 subrange: 3232 3232 constant_expression '~' constant_expression // CFA, integer subrange 3233 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }3233 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 3234 3234 ; 3235 3235
Note: See TracChangeset
for help on using the changeset viewer.