Changeset a8ced63


Ignore:
Timestamp:
Jun 20, 2024, 9:40:22 PM (12 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
9d6082c
Parents:
07771bc
Message:

parse countof pseduo-function, update for-loop for enumeration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r07771bc ra8ced63  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 17 21:43:02 2024
    13 // Update Count     : 6643
     12// Last Modified On : Thu Jun 20 21:34:49 2024
     13// Update Count     : 6654
    1414//
    1515
     
    302302                } // if
    303303        } else {
    304                 SemanticError( yylloc, "syntax error, loop-index name missing. Expression disallowed." ); return nullptr;
     304                assert( false );
    305305        } // if
    306306} // enumRangeCtrl
     
    390390%token DECIMAL32 DECIMAL64 DECIMAL128                                   // GCC
    391391%token ZERO_T ONE_T                                                                             // CFA
    392 %token SIZEOF TYPEOF VA_LIST VA_ARG AUTO_TYPE COUNT             // GCC
     392%token SIZEOF TYPEOF VA_LIST VA_ARG AUTO_TYPE COUNTOF   // GCC
    393393%token OFFSETOF BASETYPEOF TYPEID                                               // CFA
    394394%token ENUM STRUCT UNION
     
    508508%type<decl> elaborated_type elaborated_type_nobody
    509509
    510 %type<decl> enumerator_list enum_type enum_type_nobody enumerator_type
     510%type<decl> enumerator_list enum_type enum_type_nobody enum_key enumerator_type
    511511%type<init> enumerator_value_opt
    512512
     
    990990                        // $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) );
    991991                }
    992         | COUNT '(' type ')'
    993                 {
    994                         // SemanticError( yylloc, "Count is currently unimplemented. "); $$ = nullptr;
    995                         $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuildType( $3 ) ) );
    996                 }
     992        | COUNTOF '(' type_no_function ')'
     993                { $$ = new ExpressionNode( new ast::CountExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     994        | COUNTOF unary_expression
     995                { SemanticError( yylloc, "countof for expressions is currently unimplemented. "); $$ = nullptr; }
    997996        ;
    998997
     
    16261625                { SemanticError( yylloc, "syntax error, missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    16271626
    1628         | comma_expression ';' enum_type                                        // CFA, enum type
    1629                 {
    1630                         $$ = enumRangeCtrl( $1, new ExpressionNode( new ast::TypeExpr(yylloc, $3->buildType() ) ) );
    1631                 }
    1632         | comma_expression ';' downupdowneq enum_type           // CFA, enum type, reverse direction
     1627        | comma_expression ';' enum_key                                         // CFA, enum type
     1628                {
     1629                        $$ = enumRangeCtrl( $1, new ExpressionNode( new ast::TypeExpr( yylloc, $3->buildType() ) ) );
     1630                }
     1631        | comma_expression ';' downupdowneq enum_key            // CFA, enum type, reverse direction
    16331632                {
    16341633                        if ( $3 == OperKinds::LEThan || $3 == OperKinds::GEThan ) {
     
    16371636                        SemanticError( yylloc, "Type iterator is currently unimplemented." ); $$ = nullptr;
    16381637                }
     1638        ;
     1639
     1640enum_key:
     1641        type_name
     1642                { $$ = DeclarationNode::newEnum( $1->symbolic.name, nullptr, false, false ); }
     1643        | ENUM identifier
     1644                { $$ = DeclarationNode::newEnum( $2, nullptr, false, false ); }
     1645        | ENUM type_name
     1646                { $$ = DeclarationNode::newEnum( $2->symbolic.name, nullptr, false, false ); }
    16391647        ;
    16401648
Note: See TracChangeset for help on using the changeset viewer.