Changeset d69f4bb


Ignore:
Timestamp:
Aug 29, 2018, 6:09:48 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
933933c
Parents:
bcb14b5
Message:

add downto to for control

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    rbcb14b5 rd69f4bb  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Aug  8 17:23:17 2018
    13  * Update Count     : 685
     12 * Last Modified On : Wed Aug 29 15:02:41 2018
     13 * Update Count     : 686
    1414 */
    1515
     
    410410">>="                   { NAMEDOP_RETURN(RSassign); }
    411411
    412 "~="                    { NAMEDOP_RETURN(Erange); }                             // CFA
    413412"@="                    { NAMEDOP_RETURN(ATassign); }                   // CFA
     413"~="                    { NAMEDOP_RETURN(ErangeUpEq); }                 // CFA
     414"-~"                    { NAMEDOP_RETURN(ErangeDown); }                 // CFA
     415"-~="                   { NAMEDOP_RETURN(ErangeDownEq); }               // CFA
    414416
    415417                                /* CFA, operator identifier */
  • src/Parser/parser.yy

    rbcb14b5 rd69f4bb  
    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
  • tests/.expect/forctrl.txt

    rbcb14b5 rd69f4bb  
    22empty
    33empty
    4 X X X X X X X X X X
    5 Y Y Y Y Y
    6 Z Z Z Z Z
     4A A A A A A A A A A
     5B B B B B
     6C C C C C
     7D D D D D
     8E E E E E
    790 1 2 3 4 5 6 7 8 9
    8100 1 2 3 4 5 6 7 8 9
     112 4 6 8 10
     1210 8 6 4 2
    9130.5 1.5 2.5 3.5 4.5
     145.5 4.5 3.5 2.5 1.5
    10152 4 6 8 10
    11 2 4 6 8 10
     1610 8 6 4 2
    12173 6 9
    1318(0 0)(1 1)(2 2)(3 3)(4 4)(5 5)(6 6)(7 7)(8 8)(9 9)
  • tests/forctrl.c

    rbcb14b5 rd69f4bb  
    1010// Created On       : Wed Aug  8 18:32:59 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 16 09:25:47 2018
    13 // Update Count     : 6
     12// Last Modified On : Wed Aug 29 18:04:15 2018
     13// Update Count     : 26
    1414//
    1515
     
    3333        do { sout | "empty"; break; } while (); sout | endl;
    3434        for () { sout | "empty"; break; }               sout | endl;
    35         for ( 10 ) { sout | "X"; }                              sout | endl;
    36         for ( 0.5 ~ 5.5 ) { sout | "Y"; }               sout | endl;
    37         for ( 2 ~= 10 ~ 2 ) { sout | "Z"; }             sout | endl;
     35
     36        for ( 10 ) { sout | "A"; }                              sout | endl;
     37
     38        for ( 2 ~= 10 ~ 2 ) { sout | "B"; }             sout | endl;
     39        for ( 10 -~= 2 ~ -2 ) { sout | "C"; }   sout | endl;
     40        for ( 0.5 ~ 5.5 ) { sout | "D"; }               sout | endl;
     41        for ( 5.5 -~ 0.5 ) { sout | "E"; }              sout | endl;
     42
    3843        for ( i; 10 ) { sout | i; }                             sout | endl;
    3944        for ( j; 10 ) { sout | j; }                             sout | endl;
     45
     46        //for ( i; 1 ~= 10 ~ 2 ) { sout | i; }  sout | endl;
     47        for ( i; 2 ~= 10 ~ 2 ) { sout | i; }    sout | endl;
     48        for ( i; 10 -~= 2 ~ -2 ) { sout | i; }  sout | endl;
    4049        for ( i; 0.5 ~ 5.5 ) { sout | i; }              sout | endl;
    41         for ( i; 2 ~= 10 ~ 2 ) { sout | i; }    sout | endl;
     50        for ( i; 5.5 -~ 0.5 ) { sout | i; }             sout | endl;
     51
    4252        for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | endl;
     53        for ( ui; 10u -~= 2u ~ -2u ) { sout | ui; } sout | endl;
     54
    4355        int start = 3, comp = 10, inc = 2;
    4456        for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | endl;
Note: See TracChangeset for help on using the changeset viewer.