Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r0982a056 rcc22003  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 30 17:02:25 2018
    13 // Update Count     : 4029
     12// Last Modified On : Wed Aug  8 17:50:07 2018
     13// Update Count     : 3998
    1414//
    1515
     
    186186} // fieldDecl
    187187
    188 ExpressionNode *forInc( const OperKinds op ) {
    189         return new ExpressionNode( build_constantInteger( *new string( op == OperKinds::LThan || op == OperKinds::LEThan ? "1" : "-1" ) ) );
    190 } // forInc
    191 
    192188ForCtrl * 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
    197189        return new ForCtrl(
    198190                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     
    222214
    223215// Types declaration for productions
    224 %union {
     216%union
     217{
    225218        Token tok;
    226219        ParseNode * pn;
     
    297290%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    298291
    299 %token ErangeUpEq       ErangeDown      ErangeDownEq                    // ~=   -~      -~=
     292%token Erange                                                                                   // ~=
    300293%token ATassign                                                                                 // @=
    301294
     
    11451138                                $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
    11461139                        } else {
    1147                                 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1148                                                           OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) );
     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" ) ) ) );
    11491142                        } // if
    11501143                }
    11511144        | constant_expression inclexcl constant_expression      // CFA
    1152                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); }
     1145                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11531146        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11541147                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     
    11611154                        } else {
    11621155                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1163                                         $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1164                                                                   OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) );
     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" ) ) ) );
    11651158                                } else {
    11661159                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11741167                        } else {
    11751168                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1176                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) );
     1169                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    11771170                                } else {
    11781171                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    12011194        '~'
    12021195                { $$ = OperKinds::LThan; }
    1203         | ErangeUpEq
     1196        | Erange
    12041197                { $$ = OperKinds::LEThan; }
    1205         | ErangeDown
    1206                 { $$ = OperKinds::GThan; }
    1207         | ErangeDownEq
    1208                 { $$ = OperKinds::GEThan; }
    12091198        ;
    12101199
Note: See TracChangeset for help on using the changeset viewer.