Changeset 4fee301


Ignore:
Timestamp:
Aug 23, 2022, 6:39:46 AM (3 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master, pthread-emulation
Children:
0c40bfe
Parents:
e116db3
Message:

update compiler error messages for-loop control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    re116db3 r4fee301  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 12 07:59:58 2022
    13 // Update Count     : 5649
     12// Last Modified On : Mon Aug 22 23:05:55 2022
     13// Update Count     : 5651
    1414//
    1515
     
    200200#define NEW_ONE  new ExpressionNode( build_constantInteger( *new string( "1" ) ) )
    201201#define UPDOWN( compop, left, right ) (compop == OperKinds::LThan || compop == OperKinds::LEThan ? left : right)
     202#define MISSING_ANON_FIELD "Missing loop fields with an anonymous loop index is meaningless as loop index is unavailable in loop body."
     203#define MISSING_LOW "Missing low value for up-to range so index is uninitialized."
     204#define MISSING_HIGH "Missing high value for down-to range so index is uninitialized."
    202205
    203206ForCtrl * forCtrl( DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     
    13311334        | '@' updowneq comma_expression                                         // CFA
    13321335                {
    1333                         if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1336                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    13341337                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
    13351338                }
    13361339        | comma_expression updowneq '@'                                         // CFA
    13371340                {
    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; }
     1341                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
     1342                        else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    13401343                }
    13411344        | comma_expression updowneq comma_expression '~' comma_expression // CFA
     
    13431346        | '@' updowneq comma_expression '~' comma_expression // CFA
    13441347                {
    1345                         if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1348                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    13461349                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
    13471350                }
    13481351        | comma_expression updowneq '@' '~' comma_expression // CFA
    13491352                {
    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; }
     1353                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
     1354                        else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    13521355                }
    13531356        | comma_expression updowneq comma_expression '~' '@' // CFA, error
    1354                 { SemanticError( yylloc, "Missing increment ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1357                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
     1358        | '@' updowneq '@'                                                                      // CFA, error
     1359                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    13551360        | '@' updowneq comma_expression '~' '@'                         // CFA, error
    1356                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1361                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    13571362        | comma_expression updowneq '@' '~' '@'                         // CFA, error
    1358                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1363                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    13591364        | '@' updowneq '@' '~' '@'                                                      // CFA, error
    1360                 { SemanticError( yylloc, "Missing loop fields ('@') with an anonymous loop index is meaningless." ); $$ = nullptr; }
     1365                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    13611366
    13621367        | comma_expression ';' comma_expression                         // CFA
     
    13691374        | comma_expression ';' '@' updowneq comma_expression // CFA
    13701375                {
    1371                         if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1376                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    13721377                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
    13731378                }
    13741379        | comma_expression ';' comma_expression updowneq '@' // CFA
    13751380                {
    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; }
     1381                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1382                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    13781383                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
    13791384                }
    13801385        | comma_expression ';' '@' updowneq '@'                         // CFA, error
    1381                 { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1386                { SemanticError( yylloc, "Missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    13821387
    13831388        | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA
     
    13851390        | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, error
    13861391                {
    1387                         if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1392                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    13881393                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, $7 );
    13891394                }
    13901395        | comma_expression ';' comma_expression updowneq '@' '~' comma_expression // CFA
    13911396                {
    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; }
     1397                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1398                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    13941399                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, $7 );
    13951400                }
     
    13981403        | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, error
    13991404                {
    1400                         if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1405                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    14011406                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, nullptr );
    14021407                }
    14031408        | comma_expression ';' comma_expression updowneq '@' '~' '@' // CFA
    14041409                {
    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; }
     1410                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1411                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    14071412                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, nullptr );
    14081413                }
    14091414        | comma_expression ';' '@' updowneq '@' '~' '@' // CFA
    1410                 { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1415                { SemanticError( yylloc, "Missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    14111416
    14121417        | declaration comma_expression                                          // CFA
     
    14191424        | declaration '@' updowneq comma_expression                     // CFA
    14201425                {
    1421                         if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1426                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    14221427                        else $$ = forCtrl( $1, $4, $3, nullptr, NEW_ONE );
    14231428                }
    14241429        | declaration comma_expression updowneq '@'                     // CFA
    14251430                {
    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; }
     1431                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1432                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    14281433                        else $$ = forCtrl( $1, $2, $3, nullptr, NEW_ONE );
    14291434                }
     
    14331438        | declaration '@' updowneq comma_expression '~' comma_expression // CFA
    14341439                {
    1435                         if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1440                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    14361441                        else $$ = forCtrl( $1, $4, $3, nullptr, $6 );
    14371442                }
    14381443        | declaration comma_expression updowneq '@' '~' comma_expression // CFA
    14391444                {
    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; }
     1445                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1446                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    14421447                        else $$ = forCtrl( $1, $2, $3, nullptr, $6 );
    14431448                }
     
    14461451        | declaration '@' updowneq comma_expression '~' '@' // CFA
    14471452                {
    1448                         if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1453                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    14491454                        else $$ = forCtrl( $1, $4, $3, nullptr, nullptr );
    14501455                }
    14511456        | declaration comma_expression updowneq '@' '~' '@'     // CFA
    14521457                {
    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; }
     1458                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
     1459                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    14551460                        else $$ = forCtrl( $1, $2, $3, nullptr, nullptr );
    14561461                }
    14571462        | declaration '@' updowneq '@' '~' '@'                          // CFA, error
    1458                 { SemanticError( yylloc, "Missing start value so cannot compare." ); $$ = nullptr; }
     1463                { SemanticError( yylloc, "Missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    14591464
    14601465        | comma_expression ';' TYPEDEFname                                      // CFA, array type
Note: See TracChangeset for help on using the changeset viewer.