Changeset 1d9dc9c


Ignore:
Timestamp:
Jul 12, 2023, 11:41:01 AM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
e0069bd
Parents:
ed274fe (diff), 71a422a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    red274fe r1d9dc9c  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 15 08:27:24 2022
    13 // Update Count     : 275
     12// Last Modified On : Wed Jul 12 06:11:28 2023
     13// Update Count     : 276
    1414//
    1515
     
    1717#include "TypedefTable.h"
    1818
    19 #include <cassert>                                // for assert
    20 #include <string>                                 // for string
    21 #include <iostream>                               // for iostream
     19#include <cassert>                                                                              // for assert
     20#include <string>                                                                               // for string
     21#include <iostream>                                                                             // for iostream
    2222
    23 #include "ExpressionNode.h"                       // for LabelNode
    24 #include "ParserTypes.h"                          // for Token
    25 #include "StatementNode.h"                        // for CondCtl, ForCtrl
     23#include "ExpressionNode.h"                                                             // for LabelNode
     24#include "ParserTypes.h"                                                                // for Token
     25#include "StatementNode.h"                                                              // for CondCtl, ForCtrl
    2626// This (generated) header must come late as it is missing includes.
    27 #include "parser.hh"              // for IDENTIFIER, TYPEDEFname, TYPEGENname
     27#include "parser.hh"                                                                    // for IDENTIFIER, TYPEDEFname, TYPEGENname
    2828
    2929using namespace std;
     
    7272// "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if the
    7373// name is explicitly used.
    74 void TypedefTable::makeTypedef( const string & name, int kind ) {
     74void TypedefTable::makeTypedef( const string & name, int kind, const char * locn __attribute__((unused)) ) {
    7575//    Check for existence is necessary to handle:
    7676//        struct Fred {};
     
    8080//           Fred();
    8181//        }
     82        debugPrint( cerr << "Make typedef at " << locn << " \"" << name << "\" as " << kindName( kind ) << " scope " << kindTable.currentScope() << endl );
    8283        if ( ! typedefTable.exists( name ) ) {
    8384                typedefTable.addToEnclosingScope( name, kind, "MTD" );
     
    8586} // TypedefTable::makeTypedef
    8687
    87 void TypedefTable::makeTypedef( const string & name ) {
    88         return makeTypedef( name, TYPEDEFname );
     88void TypedefTable::makeTypedef( const string & name, const char * locn __attribute__((unused)) ) {
     89        debugPrint( cerr << "Make typedef at " << locn << " \"" << name << " scope " << kindTable.currentScope() << endl );
     90        return makeTypedef( name, TYPEDEFname, "makeTypede" );
    8991} // TypedefTable::makeTypedef
    9092
    9193void TypedefTable::addToScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    9294        KindTable::size_type scope = kindTable.currentScope();
    93         debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
     95        debugPrint( cerr << "Adding current at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << endl );
    9496        kindTable.insertAt( scope, identifier, kind );
    9597} // TypedefTable::addToScope
     
    98100        KindTable::size_type scope = kindTable.currentScope() - 1 - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    99101//      size_type scope = level - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    100         debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );
     102        debugPrint( cerr << "Adding enclosing at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );
    101103        pair< KindTable::iterator, bool > ret = kindTable.insertAt( scope, identifier, kind );
    102104        if ( ! ret.second ) ret.first->second = kind;           // exists => update
  • src/Parser/TypedefTable.h

    red274fe r1d9dc9c  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 15 08:06:37 2020
    13 // Update Count     : 117
     12// Last Modified On : Wed Jul 12 06:09:37 2023
     13// Update Count     : 118
    1414//
    1515
     
    2121
    2222class TypedefTable {
    23         struct Note { size_t level; bool forall; };
     23        struct Note {
     24                size_t level;
     25                bool forall;
     26        };
    2427        typedef ScopedMap< std::string, int, Note > KindTable;
    2528        KindTable kindTable;
     
    3134        bool existsCurr( const std::string & identifier ) const;
    3235        int isKind( const std::string & identifier ) const;
    33         void makeTypedef( const std::string & name, int kind );
    34         void makeTypedef( const std::string & name );
     36        void makeTypedef( const std::string & name, int kind, const char * );
     37        void makeTypedef( const std::string & name, const char * );
    3538        void addToScope( const std::string & identifier, int kind, const char * );
    3639        void addToEnclosingScope( const std::string & identifier, int kind, const char * );
  • src/Parser/parser.yy

    red274fe r1d9dc9c  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 30 12:32:36 2023
    13 // Update Count     : 6364
     12// Last Modified On : Wed Jul 12 06:14:16 2023
     13// Update Count     : 6382
    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 //  int f( forall(T) T (*f1) T , forall( S ) S (*f2)( S ) );
     603//  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    604604//      push               pop   push                   pop
    605605
     
    17151715        | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
    17161716                { $$ = 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 ) ) ) ); }
     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 ) ) ) ); }
    17201720        ;
    17211721
     
    17241724                // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement.
    17251725                {
    1726             $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) );
    1727             // $$ = new StatementNode( build_compound( yylloc, nullptr ) );
    1728         }
     1726                        $$ = new StatementNode( build_waituntil_stmt( yylloc, $1 ) );
     1727                        // $$ = new StatementNode( build_compound( yylloc, nullptr ) );
     1728                }
    17291729        ;
    17301730
     
    20072007        TYPEDEF cfa_variable_specifier
    20082008                {
    2009                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" );
     2009                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "cfa_typedef_declaration 1" );
    20102010                        $$ = $2->addTypedef();
    20112011                }
    20122012        | TYPEDEF cfa_function_specifier
    20132013                {
    2014                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" );
     2014                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "cfa_typedef_declaration 2" );
    20152015                        $$ = $2->addTypedef();
    20162016                }
    20172017        | cfa_typedef_declaration pop ',' push identifier
    20182018                {
    2019                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     2019                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "cfa_typedef_declaration 3" );
    20202020                        $$ = $1->appendList( $1->cloneType( $5 ) );
    20212021                }
     
    20282028        TYPEDEF type_specifier declarator
    20292029                {
    2030                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
     2030                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "typedef_declaration 1" );
    20312031                        if ( $2->type->forall || ($2->type->kind == TypeData::Aggregate && $2->type->aggregate.params) ) {
    20322032                                SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr;
     
    20352035        | typedef_declaration pop ',' push declarator
    20362036                {
    2037                         typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" );
     2037                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "typedef_declaration 2" );
    20382038                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    20392039                }
     
    24652465        | aggregate_key attribute_list_opt identifier
    24662466                {
    2467                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     2467                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 1" );
    24682468                        forall = false;                                                         // reset
    24692469                }
     
    24742474        | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
    24752475                {
    2476                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     2476                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 2" );
    24772477                        forall = false;                                                         // reset
    24782478                }
     
    24842484        | aggregate_key attribute_list_opt TYPEGENname          // unqualified type name
    24852485                {
    2486                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     2486                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type: 3" );
    24872487                        forall = false;                                                         // reset
    24882488                }
     
    25052505        aggregate_key attribute_list_opt identifier
    25062506                {
    2507                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     2507                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname, "aggregate_type_nobody" );
    25082508                        forall = false;                                                         // reset
    25092509                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     
    26832683                { SemanticError( yylloc, "syntax error, hiding '!' the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    26842684        | ENUM attribute_list_opt identifier
    2685                 { typedefTable.makeTypedef( *$3 ); }
     2685                { typedefTable.makeTypedef( *$3, "enum_type 1" ); }
    26862686          hide_opt '{' enumerator_list comma_opt '}'
    26872687                { $$ = DeclarationNode::newEnum( $3, $7, true, false, nullptr, $5 )->addQualifiers( $2 ); }
     
    27082708                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    27092709                        }
    2710                         typedefTable.makeTypedef( *$6 );
     2710                        typedefTable.makeTypedef( *$6, "enum_type 2" );
    27112711                }
    27122712          hide_opt '{' enumerator_list comma_opt '}'
     
    27382738enum_type_nobody:                                                                               // enum - {...}
    27392739        ENUM attribute_list_opt identifier
    2740                 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); }
     2740                {
     2741                        typedefTable.makeTypedef( *$3, "enum_type_nobody 1" );
     2742                        $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 );
     2743                }
    27412744        | ENUM attribute_list_opt type_name
    2742                 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); }
     2745                {
     2746                        typedefTable.makeTypedef( *$3->type->symbolic.name, "enum_type_nobody 2" );
     2747                        $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 );
     2748                }
    27432749        ;
    27442750
     
    28082814                { $$ = nullptr; }
    28092815        | parameter_list
    2810         | parameter_list pop ',' push ELLIPSIS
     2816        | parameter_list ',' ELLIPSIS
    28112817                { $$ = $1->addVarArgs(); }
    28122818        ;
     
    28152821        abstract_parameter_declaration
    28162822        | parameter_declaration
    2817         | parameter_list pop ',' push abstract_parameter_declaration
    2818                 { $$ = $1->appendList( $5 ); }
    2819         | parameter_list pop ',' push parameter_declaration
    2820                 { $$ = $1->appendList( $5 ); }
     2823        | parameter_list ',' abstract_parameter_declaration
     2824                { $$ = $1->appendList( $3 ); }
     2825        | parameter_list ',' parameter_declaration
     2826                { $$ = $1->appendList( $3 ); }
    28212827        ;
    28222828
     
    29832989        type_class identifier_or_type_name
    29842990                {
    2985                         typedefTable.addToScope( *$2, TYPEDEFname, "9" );
     2991                        typedefTable.addToScope( *$2, TYPEDEFname, "type_parameter 1" );
    29862992                        if ( $1 == ast::TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }
    29872993                        if ( $1 == ast::TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }
     
    29912997                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    29922998        | identifier_or_type_name new_type_class
    2993                 { typedefTable.addToScope( *$1, TYPEDEFname, "9" ); }
     2999                { typedefTable.addToScope( *$1, TYPEDEFname, "type_parameter 2" ); }
    29943000          type_initializer_opt assertion_list_opt
    29953001                { $$ = DeclarationNode::newTypeParam( $2, $1 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    29963002        | '[' identifier_or_type_name ']'
    29973003                {
    2998                         typedefTable.addToScope( *$2, TYPEDIMname, "9" );
     3004                        typedefTable.addToScope( *$2, TYPEDIMname, "type_parameter 3" );
    29993005                        $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 );
    30003006                }
     
    30783084        identifier_or_type_name
    30793085                {
    3080                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
     3086                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "type_declarator_name 1" );
    30813087                        $$ = DeclarationNode::newTypeDecl( $1, nullptr );
    30823088                }
    30833089        | identifier_or_type_name '(' type_parameter_list ')'
    30843090                {
    3085                         typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     3091                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "type_declarator_name 2" );
    30863092                        $$ = DeclarationNode::newTypeDecl( $1, $3 );
    30873093                }
     
    34723478
    34733479variable_function:
    3474         '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3475                 { $$ = $2->addParamList( $6 ); }
    3476         | '(' attribute_list variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3477                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3480        '(' variable_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3481                { $$ = $2->addParamList( $5 ); }
     3482        | '(' attribute_list variable_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3483                { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
    34783484        | '(' variable_function ')'                                                     // redundant parenthesis
    34793485                { $$ = $2; }
     
    34953501
    34963502function_no_ptr:
    3497         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3498                 { $$ = $1->addParamList( $4 ); }
    3499         | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')'
    3500                 { $$ = $2->addParamList( $6 ); }
    3501         | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')'
    3502                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3503        paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3504                { $$ = $1->addParamList( $3 ); }
     3505        | '(' function_ptr ')' '(' parameter_type_list_opt ')'
     3506                { $$ = $2->addParamList( $5 ); }
     3507        | '(' attribute_list function_ptr ')' '(' parameter_type_list_opt ')'
     3508                { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
    35033509        | '(' function_no_ptr ')'                                                       // redundant parenthesis
    35043510                { $$ = $2; }
     
    35493555        paren_identifier '(' identifier_list ')'                        // function_declarator handles empty parameter
    35503556                { $$ = $1->addIdList( $3 ); }
    3551         | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    3552                 { $$ = $2->addParamList( $6 ); }
    3553         | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    3554                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3557        | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')'
     3558                { $$ = $2->addParamList( $5 ); }
     3559        | '(' attribute_list KR_function_ptr ')' '(' parameter_type_list_opt ')'
     3560                { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
    35553561        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    35563562                { $$ = $2; }
     
    35963602                {
    35973603                        // hide type name in enclosing scope by variable name
    3598                         typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );
     3604                        typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "paren_type" );
    35993605                }
    36003606        | '(' paren_type ')'
     
    36413647
    36423648variable_type_function:
    3643         '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3644                 { $$ = $2->addParamList( $6 ); }
    3645         | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3646                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3649        '(' variable_type_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3650                { $$ = $2->addParamList( $5 ); }
     3651        | '(' attribute_list variable_type_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3652                { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
    36473653        | '(' variable_type_function ')'                                        // redundant parenthesis
    36483654                { $$ = $2; }
     
    36643670
    36653671function_type_no_ptr:
    3666         paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3667                 { $$ = $1->addParamList( $4 ); }
    3668         | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
    3669                 { $$ = $2->addParamList( $6 ); }
    3670         | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
    3671                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3672        paren_type '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3673                { $$ = $1->addParamList( $3 ); }
     3674        | '(' function_type_ptr ')' '(' parameter_type_list_opt ')'
     3675                { $$ = $2->addParamList( $5 ); }
     3676        | '(' attribute_list function_type_ptr ')' '(' parameter_type_list_opt ')'
     3677                { $$ = $3->addQualifiers( $2 )->addParamList( $6 ); }
    36723678        | '(' function_type_no_ptr ')'                                          // redundant parenthesis
    36733679                { $$ = $2; }
     
    37403746
    37413747identifier_parameter_function:
    3742         paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3743                 { $$ = $1->addParamList( $4 ); }
    3744         | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3745                 { $$ = $2->addParamList( $6 ); }
     3748        paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3749                { $$ = $1->addParamList( $3 ); }
     3750        | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3751                { $$ = $2->addParamList( $5 ); }
    37463752        | '(' identifier_parameter_function ')'                         // redundant parenthesis
    37473753                { $$ = $2; }
     
    37933799
    37943800type_parameter_function:
    3795         typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3796                 { $$ = $1->addParamList( $4 ); }
    3797         | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3798                 { $$ = $2->addParamList( $6 ); }
     3801        typedef_name '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3802                { $$ = $1->addParamList( $3 ); }
     3803        | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3804                { $$ = $2->addParamList( $5 ); }
    37993805        ;
    38003806
     
    38433849
    38443850abstract_function:
    3845         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    3846                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    3847         | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3848                 { $$ = $2->addParamList( $6 ); }
     3851        '(' parameter_type_list_opt ')'                 // empty parameter list OBSOLESCENT (see 3)
     3852                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     3853        | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3854                { $$ = $2->addParamList( $5 ); }
    38493855        | '(' abstract_function ')'                                                     // redundant parenthesis
    38503856                { $$ = $2; }
     
    39663972
    39673973abstract_parameter_function:
    3968         '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    3969                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    3970         | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    3971                 { $$ = $2->addParamList( $6 ); }
     3974        '(' parameter_type_list_opt ')'                 // empty parameter list OBSOLESCENT (see 3)
     3975                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); }
     3976        | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     3977                { $$ = $2->addParamList( $5 ); }
    39723978        | '(' abstract_parameter_function ')'                           // redundant parenthesis
    39733979                { $$ = $2; }
     
    40064012// This pattern parses a declaration of an abstract variable, but does not allow "int ()" for a function pointer.
    40074013//
    4008 //              struct S {
    4009 //          int;
    4010 //          int *;
    4011 //          int [10];
    4012 //          int (*)();
    4013 //      };
     4014//   struct S {
     4015//       int;
     4016//       int *;
     4017//       int [10];
     4018//       int (*)();
     4019//   };
    40144020
    40154021variable_abstract_declarator:
     
    40454051
    40464052variable_abstract_function:
    4047         '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    4048                 { $$ = $2->addParamList( $6 ); }
     4053        '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3)
     4054                { $$ = $2->addParamList( $5 ); }
    40494055        | '(' variable_abstract_function ')'                            // redundant parenthesis
    40504056                { $$ = $2; }
Note: See TracChangeset for help on using the changeset viewer.