Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf259682 r92355883  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 18 22:51:30 2023
    13 // Update Count     : 6391
     12// Last Modified On : Sat Jun 17 18:53:24 2023
     13// Update Count     : 6347
    1414//
    1515
     
    385385%type<str> string_literal_list
    386386
    387 %type<enum_hiding> hide_opt                             visible_hide_opt
     387%type<enum_hiding> hide_opt                                     visible_hide_opt
    388388
    389389// expressions
    390390%type<expr> constant
    391 %type<expr> tuple                                               tuple_expression_list
     391%type<expr> tuple                                                       tuple_expression_list
    392392%type<oper> ptrref_operator                             unary_operator                          assignment_operator                     simple_assignment_operator      compound_assignment_operator
    393393%type<expr> primary_expression                  postfix_expression                      unary_expression
    394 %type<expr> cast_expression_list                cast_expression                         exponential_expression          multiplicative_expression       additive_expression
    395 %type<expr> shift_expression                    relational_expression           equality_expression
     394%type<expr> cast_expression_list                        cast_expression                         exponential_expression          multiplicative_expression       additive_expression
     395%type<expr> shift_expression                            relational_expression           equality_expression
    396396%type<expr> AND_expression                              exclusive_OR_expression         inclusive_OR_expression
    397397%type<expr> logical_AND_expression              logical_OR_expression
    398398%type<expr> conditional_expression              constant_expression                     assignment_expression           assignment_expression_opt
    399 %type<expr> comma_expression                    comma_expression_opt
    400 %type<expr> argument_expression_list_opt argument_expression_list       argument_expression                     default_initializer_opt
     399%type<expr> comma_expression                            comma_expression_opt
     400%type<expr> argument_expression_list_opt        argument_expression_list        argument_expression                     default_initializer_opt
    401401%type<ifctl> conditional_declaration
    402 %type<forctl> for_control_expression    for_control_expression_list
     402%type<forctl> for_control_expression            for_control_expression_list
    403403%type<oper> upupeq updown updowneq downupdowneq
    404404%type<expr> subrange
    405405%type<decl> asm_name_opt
    406 %type<expr> asm_operands_opt                    asm_operands_list                       asm_operand
     406%type<expr> asm_operands_opt                            asm_operands_list                       asm_operand
    407407%type<labels> label_list
    408408%type<expr> asm_clobbers_list_opt
     
    412412
    413413// statements
    414 %type<stmt> statement                                   labeled_statement                       compound_statement
     414%type<stmt> statement                                           labeled_statement                       compound_statement
    415415%type<stmt> statement_decl                              statement_decl_list                     statement_list_nodecl
    416416%type<stmt> selection_statement                 if_statement
    417 %type<clause> switch_clause_list_opt    switch_clause_list
     417%type<clause> switch_clause_list_opt            switch_clause_list
    418418%type<expr> case_value
    419 %type<clause> case_clause                               case_value_list                         case_label      case_label_list
     419%type<clause> case_clause                               case_value_list                         case_label                                      case_label_list
    420420%type<stmt> iteration_statement                 jump_statement
    421 %type<stmt> expression_statement                asm_statement
     421%type<stmt> expression_statement                        asm_statement
    422422%type<stmt> with_statement
    423423%type<expr> with_clause_opt
     
    427427%type<stmt> mutex_statement
    428428%type<expr> when_clause                                 when_clause_opt                         waitfor         waituntil               timeout
    429 %type<stmt> waitfor_statement                   waituntil_statement
     429%type<stmt> waitfor_statement                           waituntil_statement
    430430%type<wfs> wor_waitfor_clause
    431431%type<wucn> waituntil_clause                    wand_waituntil_clause       wor_waituntil_clause
     
    601601// around the list separator.
    602602//
    603 //  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     603//  int f( forall(T) T (*f1) T , forall( S ) S (*f2)( S ) );
    604604//      push               pop   push                   pop
    605605
     
    689689        // | RESUME '(' comma_expression ')' compound_statement
    690690        //      { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; }
    691         | IDENTIFIER IDENTIFIER                                                         // invalid syntax rule
     691        | IDENTIFIER IDENTIFIER                                                         // invalid syntax rules
    692692                { IdentifierBeforeIdentifier( *$1.str, *$2.str, "n expression" ); $$ = nullptr; }
    693         | IDENTIFIER type_qualifier                                                     // invalid syntax rule
     693        | IDENTIFIER type_qualifier                                                     // invalid syntax rules
    694694                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
    695         | IDENTIFIER storage_class                                                      // invalid syntax rule
     695        | IDENTIFIER storage_class                                                      // invalid syntax rules
    696696                { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; }
    697         | IDENTIFIER basic_type_name                                            // invalid syntax rule
     697        | IDENTIFIER basic_type_name                                            // invalid syntax rules
    698698                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    699         | IDENTIFIER TYPEDEFname                                                        // invalid syntax rule
     699        | IDENTIFIER TYPEDEFname                                                        // invalid syntax rules
    700700                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    701         | IDENTIFIER TYPEGENname                                                        // invalid syntax rule
     701        | IDENTIFIER TYPEGENname                                                        // invalid syntax rules
    702702                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    703703        ;
     
    12751275        | DEFAULT ':'                                                           { $$ = new ClauseNode( build_default( yylloc ) ); }
    12761276                // A semantic check is required to ensure only one default clause per switch/choose statement.
    1277         | DEFAULT error                                                                         //  invalid syntax rule
     1277        | DEFAULT error                                                                         //  invalid syntax rules
    12781278                { SemanticError( yylloc, "syntax error, colon missing after default." ); $$ = nullptr; }
    12791279        ;
     
    14051405                        else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14061406                }
    1407         | comma_expression updowneq comma_expression '~' '@' // CFA, invalid syntax rule
     1407        | comma_expression updowneq comma_expression '~' '@' // CFA, invalid syntax rules
    14081408                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1409         | '@' updowneq '@'                                                                      // CFA, invalid syntax rule
     1409        | '@' updowneq '@'                                                                      // CFA, invalid syntax rules
    14101410                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1411         | '@' updowneq comma_expression '~' '@'                         // CFA, invalid syntax rule
     1411        | '@' updowneq comma_expression '~' '@'                         // CFA, invalid syntax rules
    14121412                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1413         | comma_expression updowneq '@' '~' '@'                         // CFA, invalid syntax rule
     1413        | comma_expression updowneq '@' '~' '@'                         // CFA, invalid syntax rules
    14141414                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1415         | '@' updowneq '@' '~' '@'                                                      // CFA, invalid syntax rule
     1415        | '@' updowneq '@' '~' '@'                                                      // CFA, invalid syntax rules
    14161416                { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    14171417
     
    14341434                        else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
    14351435                }
    1436         | comma_expression ';' '@' updowneq '@'                         // CFA, invalid syntax rule
     1436        | comma_expression ';' '@' updowneq '@'                         // CFA, invalid syntax rules
    14371437                { SemanticError( yylloc, "syntax error, missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    14381438
    14391439        | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA
    14401440                { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
    1441         | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, invalid syntax rule
     1441        | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, invalid syntax rules
    14421442                {
    14431443                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
     
    14521452        | comma_expression ';' comma_expression updowneq comma_expression '~' '@' // CFA
    14531453                { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
    1454         | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rule
     1454        | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, invalid syntax rules
    14551455                {
    14561456                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
     
    15111511                        else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, nullptr );
    15121512                }
    1513         | declaration '@' updowneq '@' '~' '@'                          // CFA, invalid syntax rule
     1513        | declaration '@' updowneq '@' '~' '@'                          // CFA, invalid syntax rules
    15141514                { SemanticError( yylloc, "syntax error, missing low/high value for up/down-to range so index is uninitialized." ); $$ = nullptr; }
    15151515
     
    16661666                { $$ = build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); }
    16671667        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    1668         | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rule
     1668        | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rules
    16691669                { SemanticError( yylloc, "syntax error, else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    16701670        | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
     
    17081708        | wor_waituntil_clause wor when_clause_opt ELSE statement
    17091709                { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_else( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
     1710        | wor_waituntil_clause wor when_clause_opt timeout statement    %prec THEN
     1711                { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1, build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ) ); }
     1712        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
     1713        | wor_waituntil_clause wor when_clause_opt timeout statement wor ELSE statement // invalid syntax rules
     1714                { SemanticError( yylloc, "syntax error, else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
     1715        | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
     1716                { $$ = new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::LEFT_OR, $1,
     1717                new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::OR,
     1718                    build_waituntil_timeout( yylloc, $3, $4, maybe_build_compound( yylloc, $5 ) ),
     1719                    build_waituntil_else( yylloc, $7, maybe_build_compound( yylloc, $9 ) ) ) ); }
    17101720        ;
    17111721
    17121722waituntil_statement:
    17131723        wor_waituntil_clause                                                            %prec THEN
    1714                 { $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) ); }
     1724                // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement.
     1725                {
     1726            $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) );
     1727            // $$ = new StatementNode( build_compound( yylloc, nullptr ) );
     1728        }
    17151729        ;
    17161730
     
    18541868
    18551869KR_parameter_list:
    1856         c_declaration ';'
    1857                 { $$ = $1; }
    1858         | KR_parameter_list c_declaration ';'
    1859                 { $$ = $1->appendList( $2 ); }
     1870        push c_declaration pop ';'
     1871                { $$ = $2; }
     1872        | KR_parameter_list push c_declaration pop ';'
     1873                { $$ = $1->appendList( $3 ); }
    18601874        ;
    18611875
     
    19932007        TYPEDEF cfa_variable_specifier
    19942008                {
    1995                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "cfa_typedef_declaration 1" );
     2009                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" );
    19962010                        $$ = $2->addTypedef();
    19972011                }
    19982012        | TYPEDEF cfa_function_specifier
    19992013                {
    2000                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "cfa_typedef_declaration 2" );
     2014                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" );
    20012015                        $$ = $2->addTypedef();
    20022016                }
    20032017        | cfa_typedef_declaration pop ',' push identifier
    20042018                {
    2005                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "cfa_typedef_declaration 3" );
     2019                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
    20062020                        $$ = $1->appendList( $1->cloneType( $5 ) );
    20072021                }
     
    20142028        TYPEDEF type_specifier declarator
    20152029                {
    2016                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "typedef_declaration 1" );
     2030                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    20172031                        if ( $2->type->forall || ($2->type->kind == TypeData::Aggregate && $2->type->aggregate.params) ) {
    20182032                                SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr;
    20192033                        } else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3
    20202034                }
    2021         | typedef_declaration ',' declarator
    2022                 {
    2023                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "typedef_declaration 2" );
    2024                         $$ = $1->appendList( $1->cloneBaseType( $3 )->addTypedef() );
     2035        | typedef_declaration pop ',' push declarator
     2036                {
     2037                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" );
     2038                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    20252039                }
    20262040        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
     
    20382052                        SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
    20392053                }
    2040         | typedef_expression ',' identifier '=' assignment_expression
     2054        | typedef_expression pop ',' push identifier '=' assignment_expression
    20412055                {
    20422056                        SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
     
    24512465        | aggregate_key attribute_list_opt identifier
    24522466                {
    2453                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 1" );
     2467                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    24542468                        forall = false;                                                         // reset
    24552469                }
     
    24602474        | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
    24612475                {
    2462                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 2" );
     2476                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    24632477                        forall = false;                                                         // reset
    24642478                }
     
    24702484        | aggregate_key attribute_list_opt TYPEGENname          // unqualified type name
    24712485                {
    2472                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 3" );
     2486                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    24732487                        forall = false;                                                         // reset
    24742488                }
     
    24912505        aggregate_key attribute_list_opt identifier
    24922506                {
    2493                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type_nobody" );
     2507                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
    24942508                        forall = false;                                                         // reset
    24952509                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     
    26662680        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    26672681                { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); }
    2668         | ENUM attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
    2669                 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    26702682        | ENUM attribute_list_opt identifier
    2671                 { typedefTable.makeTypedef( *$3, "enum_type 1" ); }
     2683                { typedefTable.makeTypedef( *$3 ); }
    26722684          hide_opt '{' enumerator_list comma_opt '}'
    26732685                { $$ = DeclarationNode::newEnum( $3, $7, true, false, nullptr, $5 )->addQualifiers( $2 ); }
    2674         | ENUM attribute_list_opt typedef_name hide_opt '{' enumerator_list comma_opt '}' // unqualified type name
     2686        | ENUM attribute_list_opt typedef_name                          // unqualified type name
     2687          hide_opt '{' enumerator_list comma_opt '}'
    26752688                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); }
    26762689        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
     
    26812694                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
    26822695                }
    2683         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // unqualified type name
    2684                 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    2685         | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2686                 {
    2687                         $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );
    2688                 }
    2689         | ENUM '(' ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
    2690                 { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    26912696        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    26922697                {
    2693                         if ( $3->storageClasses.any() || $3->type->qualifiers.val != 0 ) {
     2698                        if ( $3 && ($3->storageClasses.any() || $3->type->qualifiers.val != 0 )) {
    26942699                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    26952700                        }
    2696                         typedefTable.makeTypedef( *$6, "enum_type 2" );
     2701                        typedefTable.makeTypedef( *$6 );
    26972702                }
    26982703          hide_opt '{' enumerator_list comma_opt '}'
     
    27002705                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    27012706                }
    2702         | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2703                 {
    2704                         $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    2705                 }
    2706         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2707        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt
     2708          hide_opt '{' enumerator_list comma_opt '}'
    27072709                {
    27082710                        $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 );
    2709                 }
    2710         | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2711                 {
    2712                         $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    27132711                }
    27142712        | enum_type_nobody
     
    27242722enum_type_nobody:                                                                               // enum - {...}
    27252723        ENUM attribute_list_opt identifier
    2726                 {
    2727                         typedefTable.makeTypedef( *$3, "enum_type_nobody 1" );
    2728                         $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 );
    2729                 }
     2724                { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); }
    27302725        | ENUM attribute_list_opt type_name
    2731                 {
    2732                         typedefTable.makeTypedef( *$3->type->symbolic.name, "enum_type_nobody 2" );
    2733                         $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 );
    2734                 }
     2726                { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); }
    27352727        ;
    27362728
     
    28002792                { $$ = nullptr; }
    28012793        | parameter_list
    2802         | parameter_list ',' ELLIPSIS
     2794        | parameter_list pop ',' push ELLIPSIS
    28032795                { $$ = $1->addVarArgs(); }
    28042796        ;
     
    28072799        abstract_parameter_declaration
    28082800        | parameter_declaration
    2809         | parameter_list ',' abstract_parameter_declaration
    2810                 { $$ = $1->appendList( $3 ); }
    2811         | parameter_list ',' parameter_declaration
    2812                 { $$ = $1->appendList( $3 ); }
     2801        | parameter_list pop ',' push abstract_parameter_declaration
     2802                { $$ = $1->appendList( $5 ); }
     2803        | parameter_list pop ',' push parameter_declaration
     2804                { $$ = $1->appendList( $5 ); }
    28132805        ;
    28142806
     
    28292821
    28302822cfa_abstract_parameter_declaration:                                             // CFA, new & old style parameter declaration
    2831         abstract_parameter_declaration
     2823        // empty
     2824                { $$ = nullptr; }
     2825        | abstract_parameter_declaration
    28322826        | cfa_identifier_parameter_declarator_no_tuple
    28332827        | cfa_abstract_tuple
     
    29752969        type_class identifier_or_type_name
    29762970                {
    2977                         typedefTable.addToScope( *$2, TYPEDEFname, "type_parameter 1" );
     2971                        typedefTable.addToScope( *$2, TYPEDEFname, "9" );
    29782972                        if ( $1 == ast::TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }
    29792973                        if ( $1 == ast::TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }
     
    29832977                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    29842978        | identifier_or_type_name new_type_class
    2985                 { typedefTable.addToScope( *$1, TYPEDEFname, "type_parameter 2" ); }
     2979                { typedefTable.addToScope( *$1, TYPEDEFname, "9" ); }
    29862980          type_initializer_opt assertion_list_opt
    29872981                { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    29882982        | '[' identifier_or_type_name ']'
    29892983                {
    2990                         typedefTable.addToScope( *$2, TYPEDIMname, "type_parameter 3" );
     2984                        typedefTable.addToScope( *$2, TYPEDIMname, "9" );
    29912985                        $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 );
    29922986                }
     
    30703064        identifier_or_type_name
    30713065                {
    3072                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "type_declarator_name 1" );
     3066                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    30733067                        $$ = DeclarationNode::newTypeDecl( $1, nullptr );
    30743068                }
    30753069        | identifier_or_type_name '(' type_parameter_list ')'
    30763070                {
    3077                         typedefTable.addToEnclosingScope( *$1, TYPEGENname, "type_declarator_name 2" );
     3071                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
    30783072                        $$ = DeclarationNode::newTypeDecl( $1, $3 );
    30793073                }
     
    31693163        | IDENTIFIER IDENTIFIER
    31703164                { IdentifierBeforeIdentifier( *$1.str, *$2.str, " declaration" ); $$ = nullptr; }
    3171         | IDENTIFIER type_qualifier                                                     // invalid syntax rule
     3165        | IDENTIFIER type_qualifier                                                     // invalid syntax rules
    31723166                { IdentifierBeforeType( *$1.str, "type qualifier" ); $$ = nullptr; }
    3173         | IDENTIFIER storage_class                                                      // invalid syntax rule
     3167        | IDENTIFIER storage_class                                                      // invalid syntax rules
    31743168                { IdentifierBeforeType( *$1.str, "storage class" ); $$ = nullptr; }
    3175         | IDENTIFIER basic_type_name                                            // invalid syntax rule
     3169        | IDENTIFIER basic_type_name                                            // invalid syntax rules
    31763170                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    3177         | IDENTIFIER TYPEDEFname                                                        // invalid syntax rule
     3171        | IDENTIFIER TYPEDEFname                                                        // invalid syntax rules
    31783172                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    3179         | IDENTIFIER TYPEGENname                                                        // invalid syntax rule
     3173        | IDENTIFIER TYPEGENname                                                        // invalid syntax rules
    31803174                { IdentifierBeforeType( *$1.str, "type" ); $$ = nullptr; }
    31813175        | external_function_definition
     
    34643458
    34653459variable_function:
    3466         '(' variable_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3467                 { $$ = $2->addParamList( $5 ); }
    3468         | '(' attribute_list variable_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3469                 { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
     3460        '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3461                { $$ = $2->addParamList( $6 ); }
     3462        | '(' attribute_list variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3463                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    34703464        | '(' variable_function ')'                                                     // redundant parenthesis
    34713465                { $$ = $2; }
     
    34873481
    34883482function_no_ptr:
    3489         paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3490                 { $$ = $1->addParamList( $3 ); }
    3491         | '(' function_ptr ')' '(' parameter_type_list_opt ')'
    3492                 { $$ = $2->addParamList( $5 ); }
    3493         | '(' attribute_list function_ptr ')' '(' parameter_type_list_opt ')'
    3494                 { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
     3483        paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3484                { $$ = $1->addParamList( $4 ); }
     3485        | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')'
     3486                { $$ = $2->addParamList( $6 ); }
     3487        | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')'
     3488                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    34953489        | '(' function_no_ptr ')'                                                       // redundant parenthesis
    34963490                { $$ = $2; }
     
    35413535        paren_identifier '(' identifier_list ')'                        // function_declarator handles empty parameter
    35423536                { $$ = $1->addIdList( $3 ); }
    3543         | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')'
    3544                 { $$ = $2->addParamList( $5 ); }
    3545         | '(' attribute_list KR_function_ptr ')' '(' parameter_type_list_opt ')'
    3546                 { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
     3537        | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
     3538                { $$ = $2->addParamList( $6 ); }
     3539        | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
     3540                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    35473541        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    35483542                { $$ = $2; }
     
    35883582                {
    35893583                        // hide type name in enclosing scope by variable name
    3590                         typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "paren_type" );
     3584                        typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );
    35913585                }
    35923586        | '(' paren_type ')'
     
    36333627
    36343628variable_type_function:
    3635         '(' variable_type_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3636                 { $$ = $2->addParamList( $5 ); }
    3637         | '(' attribute_list variable_type_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3638                 { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
     3629        '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3630                { $$ = $2->addParamList( $6 ); }
     3631        | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3632                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    36393633        | '(' variable_type_function ')'                                        // redundant parenthesis
    36403634                { $$ = $2; }
     
    36563650
    36573651function_type_no_ptr:
    3658         paren_type '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3659                 { $$ = $1->addParamList( $3 ); }
    3660         | '(' function_type_ptr ')' '(' parameter_type_list_opt ')'
    3661                 { $$ = $2->addParamList( $5 ); }
    3662         | '(' attribute_list function_type_ptr ')' '(' parameter_type_list_opt ')'
    3663                 { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
     3652        paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3653                { $$ = $1->addParamList( $4 ); }
     3654        | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
     3655                { $$ = $2->addParamList( $6 ); }
     3656        | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
     3657                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    36643658        | '(' function_type_no_ptr ')'                                          // redundant parenthesis
    36653659                { $$ = $2; }
     
    37323726
    37333727identifier_parameter_function:
    3734         paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3735                 { $$ = $1->addParamList( $3 ); }
    3736         | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3737                 { $$ = $2->addParamList( $5 ); }
     3728        paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3729                { $$ = $1->addParamList( $4 ); }
     3730        | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3731                { $$ = $2->addParamList( $6 ); }
    37383732        | '(' identifier_parameter_function ')'                         // redundant parenthesis
    37393733                { $$ = $2; }
     
    37853779
    37863780type_parameter_function:
    3787         typedef_name '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3788                 { $$ = $1->addParamList( $3 ); }
    3789         | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3790                 { $$ = $2->addParamList( $5 ); }
     3781        typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3782                { $$ = $1->addParamList( $4 ); }
     3783        | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3784                { $$ = $2->addParamList( $6 ); }
    37913785        ;
    37923786
     
    38353829
    38363830abstract_function:
    3837         '(' parameter_type_list_opt ')'                 // empty parameter list OBSOLESCENT (see 3)
    3838                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
    3839         | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3840                 { $$ = $2->addParamList( $5 ); }
     3831        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
     3832                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
     3833        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3834                { $$ = $2->addParamList( $6 ); }
    38413835        | '(' abstract_function ')'                                                     // redundant parenthesis
    38423836                { $$ = $2; }
     
    38543848                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    38553849        | '[' push array_type_list pop ']'                                      // CFA
    3856                 { SemanticError( yylloc, "Type array dimension is currently unimplemented." ); $$ = nullptr; }
     3850                { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
    38573851        | multi_array_dimension
    38583852        ;
     
    39583952
    39593953abstract_parameter_function:
    3960         '(' parameter_type_list_opt ')'                 // empty parameter list OBSOLESCENT (see 3)
    3961                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
    3962         | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    3963                 { $$ = $2->addParamList( $5 ); }
     3954        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
     3955                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
     3956        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3957                { $$ = $2->addParamList( $6 ); }
    39643958        | '(' abstract_parameter_function ')'                           // redundant parenthesis
    39653959                { $$ = $2; }
     
    39983992// This pattern parses a declaration of an abstract variable, but does not allow "int ()" for a function pointer.
    39993993//
    4000 //   struct S {
    4001 //       int;
    4002 //       int *;
    4003 //       int [10];
    4004 //       int (*)();
    4005 //   };
     3994//              struct S {
     3995//          int;
     3996//          int *;
     3997//          int [10];
     3998//          int (*)();
     3999//      };
    40064000
    40074001variable_abstract_declarator:
     
    40374031
    40384032variable_abstract_function:
    4039         '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
    4040                 { $$ = $2->addParamList( $5 ); }
     4033        '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     4034                { $$ = $2->addParamList( $6 ); }
    40414035        | '(' variable_abstract_function ')'                            // redundant parenthesis
    40424036                { $$ = $2; }
Note: See TracChangeset for help on using the changeset viewer.