Changeset 67d4e37 for src


Ignore:
Timestamp:
Apr 13, 2019, 3:51:58 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b0ccd1c
Parents:
25773cd
Message:

add chained for-control specifiers, update loop test and test output

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r25773cd r67d4e37  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 13 17:36:49 2019
    13 // Update Count     : 867
     12// Last Modified On : Sat Apr 13 15:44:20 2019
     13// Update Count     : 873
    1414//
    1515
     
    132132        void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
    133133
    134         Expression *get_expr() const { return expr.get(); }
     134        Expression * get_expr() const { return expr.get(); }
    135135        template<typename T>
    136136        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
    137137
    138138        Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
     139
     140        std::unique_ptr<Expression> expr;                                       // public because of lifetime implications
    139141  private:
    140142        bool extension = false;
    141         std::unique_ptr<Expression> expr;
    142143}; // ExpressionNode
    143144
  • src/Parser/parser.yy

    r25773cd r67d4e37  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 15 14:25:43 2019
    13 // Update Count     : 4248
     12// Last Modified On : Sat Apr 13 14:00:24 2019
     13// Update Count     : 4285
    1414//
    1515
     
    334334%type<en> subrange
    335335%type<decl> asm_name_opt
    336 %type<en> asm_operands_opt asm_operands_list asm_operand
     336%type<en> asm_operands_opt                              asm_operands_list                       asm_operand
    337337%type<label> label_list
    338338%type<en> asm_clobbers_list_opt
    339339%type<flag> asm_volatile_opt
    340340%type<en> handler_predicate_opt
    341 %type<genexpr> generic_association generic_assoc_list
     341%type<genexpr> generic_association              generic_assoc_list
    342342
    343343// statements
     
    11641164        for_control_expression
    11651165        | for_control_expression_list ':' for_control_expression
    1166                 { $$ = $3; }
     1166                // ForCtrl + ForCtrl:
     1167                //    init + init => multiple declaration statements that are hoisted
     1168                //    condition + condition => (expression) && (expression)
     1169                //    change + change => (expression), (expression)
     1170                {
     1171                        $1->init->set_last( $3->init );
     1172                        if ( $1->condition ) {
     1173                                if ( $3->condition ) {
     1174                                        $1->condition->expr.reset( new LogicalExpr( $1->condition->expr.release(), $3->condition->expr.release(), true ) );
     1175                                } // if
     1176                        } else $1->condition = $3->condition;
     1177                        if ( $1->change ) {
     1178                                if ( $3->change ) {
     1179                                        $1->change->expr.reset( new CommaExpr( $1->change->expr.release(), $3->change->expr.release() ) );
     1180                                } // if
     1181                        } else $1->change = $3->change;
     1182                        $$ = $1;
     1183                }
    11671184        ;
    11681185
     
    11741191        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    11751192                { $$ = new ForCtrl( $1, $2, $4 ); }
     1193
    11761194        | comma_expression                                                                      // CFA
    11771195                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     
    11881206        | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA
    11891207                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); }
     1208
     1209                // There is a S/R conflicit if ~ and -~ are factored out.
     1210        | comma_expression ';' comma_expression '~' '@'         // CFA
     1211                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1212        | comma_expression ';' comma_expression ErangeDown '@' // CFA
     1213                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::GThan, nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11901214        | comma_expression ';' comma_expression '~' '@' '~' comma_expression // CFA
    11911215                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, $7 ); }
Note: See TracChangeset for help on using the changeset viewer.