Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf271bdd rc4f68dc  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  4 09:38:36 2018
    13 // Update Count     : 3986
     12// Last Modified On : Wed Jul 25 15:54:35 2018
     13// Update Count     : 3841
    1414//
    1515
     
    186186} // fieldDecl
    187187
    188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, ExpressionNode * comp, ExpressionNode * inc ) {
    189         return new ForCtrl(
    190                 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    191                 new ExpressionNode( build_binary_val( OperKinds::LThan, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    192                 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
    193 } // forCtrl
    194 
    195 
    196188bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    197189
     
    225217        WaitForStmt * wfs;
    226218        Expression * constant;
    227         IfCtrl * ifctl;
    228         ForCtrl * fctl;
     219        IfCtl * ifctl;
     220        ForCtl * fctl;
    229221        LabelNode * label;
    230222        InitializerNode * in;
     
    10571049if_control_expression:
    10581050        comma_expression
    1059                 { $$ = new IfCtrl( nullptr, $1 ); }
     1051                { $$ = new IfCtl( nullptr, $1 ); }
    10601052        | c_declaration                                                                         // no semi-colon
    1061                 { $$ = new IfCtrl( $1, nullptr ); }
     1053                { $$ = new IfCtl( $1, nullptr ); }
    10621054        | cfa_declaration                                                                       // no semi-colon
    1063                 { $$ = new IfCtrl( $1, nullptr ); }
     1055                { $$ = new IfCtl( $1, nullptr ); }
    10641056        | declaration comma_expression                                          // semi-colon separated
    1065                 { $$ = new IfCtrl( $1, $2 ); }
     1057                { $$ = new IfCtl( $1, $2 ); }
    10661058        ;
    10671059
     
    11191111        WHILE '(' push if_control_expression ')' statement pop
    11201112                { $$ = new StatementNode( build_while( $4, $6 ) ); }
    1121         | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
    1122                 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), $4 ) ); }
    11231113        | DO statement WHILE '(' comma_expression ')' ';'
    11241114                { $$ = new StatementNode( build_do_while( $5, $2 ) ); }
    1125         | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    1126                 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
    11271115        | FOR '(' push for_control_expression ')' statement pop
    11281116                { $$ = new StatementNode( build_for( $4, $6 ) ); }
     
    11301118
    11311119for_control_expression:
    1132         comma_expression_opt                                                            // CFA
    1133                 {
    1134                         if ( ! $1 ) {                                                           // => for ( ;; )
    1135                                 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
    1136                         } else {
    1137                                 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), $1->clone(),
    1138                                                          new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1139                         } // if
    1140                 }
    1141         | constant_expression '~' constant_expression           // CFA
    1142                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1143         | constant_expression '~' constant_expression '~' constant_expression // CFA
    1144                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $3, $5 ); }
    1145         | comma_expression_opt ';' comma_expression                     // CFA
    1146                 {
    1147                         if ( ! $1 ) {
    1148                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1149                         } else if ( ! $3 ) {
    1150                                 SemanticError( yylloc, "Missing loop range." ); $$ = nullptr;
    1151                         } else {
    1152                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1153                                         $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), $3->clone(),
    1154                                                                  new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1155                                 } else {
    1156                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1157                                 } // if
    1158                         } // if
    1159                 }
    1160         | comma_expression_opt ';' constant_expression '~' constant_expression // CFA
    1161                 {
    1162                         if ( ! $1 ) {
    1163                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1164                         } else {
    1165                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1166                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    1167                                 } else {
    1168                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1169                                 } // if
    1170                         } // if
    1171                 }
    1172         | comma_expression_opt ';' constant_expression '~' constant_expression '~' constant_expression // CFA
    1173                 {
    1174                         if ( ! $1 ) {
    1175                                 SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
    1176                         } else {
    1177                                 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1178                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $5, $7 );
    1179                                 } else {
    1180                                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
    1181                                 } // if
    1182                         } // if
    1183                 }
    1184         | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
    1185                 { $$ = new ForCtrl( $1, $3, $5 ); }
    1186         | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    1187                 { $$ = new ForCtrl( $1, $2, $4 ); }
     1120        comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
     1121                { $$ = new ForCtl( $1, $3, $5 ); }
     1122        | declaration comma_expression_opt ';' comma_expression_opt // C99
     1123                { $$ = new ForCtl( $1, $2, $4 ); }
    11881124        ;
    11891125
Note: See TracChangeset for help on using the changeset viewer.