Changeset 55ba259e


Ignore:
Timestamp:
Jun 26, 2024, 10:25:26 AM (3 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
01afd8d
Parents:
d5efcb7
Message:

clarify for-control for enumerations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rd5efcb7 r55ba259e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 25 18:44:14 2024
    13 // Update Count     : 6692
     12// Last Modified On : Wed Jun 26 09:37:28 2024
     13// Update Count     : 6700
    1414//
    1515
     
    16071607        | comma_expression ';' enum_key                                         // CFA, enum type
    16081608                {
    1609                         $$ = enumRangeCtrl( $1, OperKinds::LThan, new ExpressionNode( new ast::TypeExpr( yylloc, $3->buildType() ) ) );
     1609                        $$ = enumRangeCtrl( $1, OperKinds::LEThan, new ExpressionNode( new ast::TypeExpr( yylloc, $3->buildType() ) ) );
    16101610                }
    16111611        | comma_expression ';' downupdowneq enum_key            // CFA, enum type, reverse direction
    16121612                {
    1613                         if ( $3 == OperKinds::LEThan || $3 == OperKinds::GEThan ) {
    1614                                 SemanticError( yylloc, "illegal syntax, all enumeration ranges are equal (all values). Remove \"=~\"." ); $$ = nullptr;
    1615                         }
     1613                        if ( $3 == OperKinds::GThan ) {
     1614                                SemanticError( yylloc, "all enumeration ranges are equal (all values). Add an equal, e.g., ~=, -~=." ); $$ = nullptr;
     1615                                $3 = OperKinds::GEThan;
     1616                        } // if
    16161617                        $$ = enumRangeCtrl( $1, $3, new ExpressionNode( new ast::TypeExpr( yylloc, $4->buildType() ) ) );
    16171618                }
     
    16271628        ;
    16281629
     1630// This rule exists to handle the ambiguity with unary operator '~'. The rule is the same as updowneq minus the '~'.
     1631// Specifically, "for ( ~5 )" means the complement of 5, not loop 0..4. Hence, in this case "for ( ~= 5 )", i.e., 0..5,
     1632// it is not possible to just remove the '='. The entire '~=' must be removed.
    16291633downupdowneq:
    16301634        ErangeDown
Note: See TracChangeset for help on using the changeset viewer.