Ignore:
Timestamp:
Aug 12, 2022, 9:05:32 AM (19 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
283876d
Parents:
4962741
Message:

update for-control with corrected @ usage for negative range

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r4962741 rdbedd71  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug  9 17:21:46 2022
    13 // Update Count     : 5629
     12// Last Modified On : Fri Aug 12 07:59:58 2022
     13// Update Count     : 5649
    1414//
    1515
     
    13291329        | comma_expression updowneq comma_expression            // CFA
    13301330                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }
    1331         | '@' updowneq comma_expression                                         // CFA, error
    1332                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
     1331        | '@' updowneq comma_expression                                         // CFA
     1332                {
     1333                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1334                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
     1335                }
    13331336        | comma_expression updowneq '@'                                         // CFA
    1334                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
    1335 
     1337                {
     1338                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing comparison ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1339                        else { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1340                }
    13361341        | comma_expression updowneq comma_expression '~' comma_expression // CFA
    13371342                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }
    1338         | '@' updowneq comma_expression '~' comma_expression // CFA, error
    1339                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
    1340         | comma_expression updowneq '@' '~' comma_expression // CFA, error
    1341                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
     1343        | '@' updowneq comma_expression '~' comma_expression // CFA
     1344                {
     1345                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1346                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
     1347                }
     1348        | comma_expression updowneq '@' '~' comma_expression // CFA
     1349                {
     1350                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing comparison ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1351                        else { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1352                }
    13421353        | comma_expression updowneq comma_expression '~' '@' // CFA, error
    1343                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
     1354                { SemanticError( yylloc, "Missing increment ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
    13441355        | '@' updowneq comma_expression '~' '@'                         // CFA, error
    1345                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
     1356                { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
    13461357        | comma_expression updowneq '@' '~' '@'                         // CFA, error
    1347                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is not useful." ); $$ = nullptr; }
     1358                { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1359        | '@' updowneq '@' '~' '@'                                                      // CFA, error
     1360                { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
    13481361
    13491362        | comma_expression ';' comma_expression                         // CFA
     
    13541367        | comma_expression ';' comma_expression updowneq comma_expression // CFA
    13551368                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }
    1356         | comma_expression ';' '@' updowneq comma_expression // CFA, error
     1369        | comma_expression ';' '@' updowneq comma_expression // CFA
     1370                {
     1371                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1372                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
     1373                }
     1374        | comma_expression ';' comma_expression updowneq '@' // CFA
     1375                {
     1376                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1377                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
     1378                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
     1379                }
     1380        | comma_expression ';' '@' updowneq '@'                         // CFA, error
    13571381                { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
    1358         | comma_expression ';' comma_expression updowneq '@' // CFA
    1359                 {
    1360                         if ( $4 == OperKinds::LEThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Decrement with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    1361                         else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
    1362                 }
    13631382
    13641383        | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA
    13651384                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
    13661385        | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, error
    1367                 { SemanticError( yylloc, "Missing start declaration so cannot compare." ); $$ = nullptr; }
     1386                {
     1387                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1388                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, $7 );
     1389                }
    13681390        | comma_expression ';' comma_expression updowneq '@' '~' comma_expression // CFA
    13691391                {
    1370                         if ( $4 == OperKinds::LEThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Equal for comparison is meaningless with missing comparison. Use \"~\"." ); $$ = nullptr; }
     1392                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1393                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    13711394                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, $7 );
    13721395                }
     
    13741397                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
    13751398        | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, error
    1376                 { SemanticError( yylloc, "Missing start declaration so cannot compare." ); $$ = nullptr; }
     1399                {
     1400                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1401                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, nullptr );
     1402                }
    13771403        | comma_expression ';' comma_expression updowneq '@' '~' '@' // CFA
    13781404                {
    1379                         if ( $4 == OperKinds::GThan ) { SemanticError( yylloc, "Negative range \"-~\" is meaningless when comparison and iterator are empty. Use \"~\"." ); $$ = nullptr; }
    1380                         else if ( $4 == OperKinds::LEThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Equal for comparison is meaningless with missing comparison. Use \"~\"." ); $$ = nullptr; }
     1405                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1406                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    13811407                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, nullptr );
    13821408                }
     1409        | comma_expression ';' '@' updowneq '@' '~' '@' // CFA
     1410                { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
    13831411
    13841412        | declaration comma_expression                                          // CFA
     
    13891417        | declaration comma_expression updowneq comma_expression // CFA
    13901418                { $$ = forCtrl( $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }
    1391         | declaration '@' updowneq comma_expression                     // CFA, error
    1392                 { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1419        | declaration '@' updowneq comma_expression                     // CFA
     1420                {
     1421                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1422                        else $$ = forCtrl( $1, $4, $3, nullptr, NEW_ONE );
     1423                }
    13931424        | declaration comma_expression updowneq '@'                     // CFA
    13941425                {
    1395                         if ( $3 == OperKinds::LEThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Decrement with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
     1426                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1427                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    13961428                        else $$ = forCtrl( $1, $2, $3, nullptr, NEW_ONE );
    13971429                }
     
    13991431        | declaration comma_expression updowneq comma_expression '~' comma_expression // CFA
    14001432                { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }
    1401         | declaration '@' updowneq comma_expression '~' comma_expression // CFA, error
    1402                 { SemanticError( yylloc, "Missing start declaration so cannot compare." ); $$ = nullptr; }
     1433        | declaration '@' updowneq comma_expression '~' comma_expression // CFA
     1434                {
     1435                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1436                        else $$ = forCtrl( $1, $4, $3, nullptr, $6 );
     1437                }
    14031438        | declaration comma_expression updowneq '@' '~' comma_expression // CFA
    14041439                {
    1405                         if ( $3 == OperKinds::LEThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Equal for comparison is meaningless with missing comparison. Use \"~\"." ); $$ = nullptr; }
     1440                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1441                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    14061442                        else $$ = forCtrl( $1, $2, $3, nullptr, $6 );
    14071443                }
    14081444        | declaration comma_expression updowneq comma_expression '~' '@' // CFA
    14091445                { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }
    1410         | declaration '@' updowneq comma_expression '~' '@' // CFA, error
    1411                 { SemanticError( yylloc, "Missing start declaration so cannot compare." ); $$ = nullptr; }
     1446        | declaration '@' updowneq comma_expression '~' '@' // CFA
     1447                {
     1448                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1449                        else $$ = forCtrl( $1, $4, $3, nullptr, nullptr );
     1450                }
    14121451        | declaration comma_expression updowneq '@' '~' '@'     // CFA
    14131452                {
    1414                         if ( $3 == OperKinds::GThan ) { SemanticError( yylloc, "Negative range \"-~\" is meaningless when comparison and iterator are empty. Use \"~\"." ); $$ = nullptr; }
    1415                         else if ( $3 == OperKinds::LEThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Equal for comparison is meaningless with missing comparison. Use \"~\"." ); $$ = nullptr; }
     1453                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1454                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing comparison is meaningless. Use \"~\"." ); $$ = nullptr; }
    14161455                        else $$ = forCtrl( $1, $2, $3, nullptr, nullptr );
    14171456                }
     1457        | declaration '@' updowneq '@' '~' '@'                          // CFA, error
     1458                { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
    14181459
    14191460        | comma_expression ';' TYPEDEFname                                      // CFA, array type
Note: See TracChangeset for help on using the changeset viewer.