Ignore:
Timestamp:
Dec 12, 2018, 3:52:19 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
1b8f13f0
Parents:
cdc02f2 (diff), 85acec94 (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.
Message:

Merge branch 'master' into shared_library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rcdc02f2 r515a037  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 21 08:27:29 2018
    13 // Update Count     : 4045
     12// Last Modified On : Thu Nov  8 18:08:23 2018
     13// Update Count     : 4052
    1414//
    1515
     
    187187
    188188ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    189         ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr());
     189        ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->get_expr());
    190190        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
    191191        type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
    192192        } // if
    193193        return new ForCtrl(
    194                 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     194                distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    195195                new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    196196                new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto
    197197                                                                                          OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
     198<<<<<<< HEAD
     199=======
     200} // forCtrl
     201
     202ForCtrl * forCtrl( ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     203        if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) {
     204                return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
     205        } else {
     206                SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     207        } // if
     208>>>>>>> master
    198209} // forCtrl
    199210
     
    11321143        | FOR '(' push for_control_expression ')' statement pop
    11331144                { $$ = new StatementNode( build_for( $4, $6 ) ); }
     1145        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     1146                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), $4 ) ); }
    11341147        ;
    11351148
    11361149for_control_expression:
     1150<<<<<<< HEAD
    11371151        comma_expression_opt                                                            // CFA
    11381152                {
     
    11441158                        } // if
    11451159                }
     1160=======
     1161        comma_expression                                                                        // CFA
     1162                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1163                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1164>>>>>>> master
    11461165        | constant_expression inclexcl constant_expression      // CFA
    11471166                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11481167        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11491168                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     1169<<<<<<< HEAD
    11501170        | comma_expression_opt ';' comma_expression                     // CFA
    11511171                {
     
    11881208                }
    11891209        | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
     1210=======
     1211        | comma_expression ';' comma_expression                         // CFA
     1212                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1213                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1214        | comma_expression ';' constant_expression inclexcl constant_expression // CFA
     1215                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1216        | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA
     1217                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); }
     1218        | comma_expression ';' comma_expression_opt ';' comma_expression_opt
     1219>>>>>>> master
    11901220                { $$ = new ForCtrl( $1, $3, $5 ); }
     1221        | ';' comma_expression_opt ';' comma_expression_opt
     1222                { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
    11911223        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    11921224                { $$ = new ForCtrl( $1, $2, $4 ); }
     
    18501882
    18511883indirect_type:
    1852         TYPEOF '(' type ')'                                                                     // GCC: typeof(x) y;
     1884        TYPEOF '(' type ')'                                                                     // GCC: typeof( x ) y;
    18531885                { $$ = $3; }
    1854         | TYPEOF '(' comma_expression ')'                                       // GCC: typeof(a+b) y;
     1886        | TYPEOF '(' comma_expression ')'                                       // GCC: typeof( a+b ) y;
    18551887                { $$ = DeclarationNode::newTypeof( $3 ); }
     1888<<<<<<< HEAD
    18561889        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof(x) y;
    18571890                { $$ = $3; }
     
    18591892                { $$ = DeclarationNode::newTypeof( $3 ); }
    18601893        | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type(x) y;
     1894=======
     1895        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof( x ) y;
     1896                { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ), true ); }
     1897        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
     1898                { $$ = DeclarationNode::newTypeof( $3, true ); }
     1899        | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type( x ) y;
     1900>>>>>>> master
    18611901                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    1862         | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
     1902        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type( a+b ) y;
    18631903                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    18641904        | ZERO_T                                                                                        // CFA
Note: See TracChangeset for help on using the changeset viewer.