Ignore:
Timestamp:
Sep 10, 2018, 5:17:34 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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:
67982887, 9fce933a
Parents:
0cf9ffd (diff), e15ba975 (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' of plg2.cs.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r0cf9ffd rbedb40e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  8 17:50:07 2018
    13 // Update Count     : 3998
     12// Last Modified On : Thu Aug 30 17:02:25 2018
     13// Update Count     : 4029
    1414//
    1515
     
    186186} // fieldDecl
    187187
     188ExpressionNode *forInc( const OperKinds op ) {
     189        return new ExpressionNode( build_constantInteger( *new string( op == OperKinds::LThan || op == OperKinds::LEThan ? "1" : "-1" ) ) );
     190} // forInc
     191
    188192ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     193        ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr());
     194        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
     195        type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
     196        } // if
    189197        return new ForCtrl(
    190198                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     
    214222
    215223// Types declaration for productions
    216 %union
    217 {
     224%union {
    218225        Token tok;
    219226        ParseNode * pn;
     
    290297%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    291298
    292 %token Erange                                                                                   // ~=
     299%token ErangeUpEq       ErangeDown      ErangeDownEq                    // ~=   -~      -~=
    293300%token ATassign                                                                                 // @=
    294301
     
    11381145                                $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
    11391146                        } else {
    1140                                 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(),
    1141                                                          new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1147                                $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1148                                                          OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) );
    11421149                        } // if
    11431150                }
    11441151        | constant_expression inclexcl constant_expression      // CFA
    1145                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1152                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); }
    11461153        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11471154                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     
    11541161                        } else {
    11551162                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1156                                         $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(),
    1157                                                                  new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1163                                        $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1164                                                                  OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) );
    11581165                                } else {
    11591166                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11671174                        } else {
    11681175                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1169                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1176                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) );
    11701177                                } else {
    11711178                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11941201        '~'
    11951202                { $$ = OperKinds::LThan; }
    1196         | Erange
     1203        | ErangeUpEq
    11971204                { $$ = OperKinds::LEThan; }
     1205        | ErangeDown
     1206                { $$ = OperKinds::GThan; }
     1207        | ErangeDownEq
     1208                { $$ = OperKinds::GEThan; }
    11981209        ;
    11991210
Note: See TracChangeset for help on using the changeset viewer.