Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rcc22003 rd69f4bb4  
    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 : Wed Aug 29 16:44:17 2018
     13// Update Count     : 4006
    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 ) {
    189193        return new ForCtrl(
     
    290294%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    291295
    292 %token Erange                                                                                   // ~=
     296%token ErangeUpEq       ErangeDown      ErangeDownEq                    // ~=   -~      -~=
    293297%token ATassign                                                                                 // @=
    294298
     
    11381142                                $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
    11391143                        } 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" ) ) ) );
     1144                                $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1145                                                          OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) );
    11421146                        } // if
    11431147                }
    11441148        | 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" ) ) ) ); }
     1149                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); }
    11461150        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11471151                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     
    11541158                        } else {
    11551159                                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" ) ) ) );
     1160                                        $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1161                                                                  OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) );
    11581162                                } else {
    11591163                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11671171                        } else {
    11681172                                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" ) ) ) );
     1173                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) );
    11701174                                } else {
    11711175                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11941198        '~'
    11951199                { $$ = OperKinds::LThan; }
    1196         | Erange
     1200        | ErangeUpEq
    11971201                { $$ = OperKinds::LEThan; }
     1202        | ErangeDown
     1203                { $$ = OperKinds::GThan; }
     1204        | ErangeDownEq
     1205                { $$ = OperKinds::GEThan; }
    11981206        ;
    11991207
Note: See TracChangeset for help on using the changeset viewer.