Ignore:
Timestamp:
Apr 28, 2021, 4:56:50 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8d66610
Parents:
feacef9 (diff), b7fd2db6 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rfeacef9 r5407cdc  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  3 18:30:12 2021
    13 // Update Count     : 4700
     12// Last Modified On : Mon Apr 26 18:41:54 2021
     13// Update Count     : 4990
    1414//
    1515
     
    3232//
    3333// 1. designation with and without '=' (use ':' instead)
    34 // 2. attributes not allowed in parenthesis of declarator
     34
    3535//
    3636// All of the syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall
     
    211211} // forCtrl
    212212
    213 bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     213bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    214214
    215215// https://www.gnu.org/software/bison/manual/bison.html#Location-Type
     
    264264%token RESTRICT                                                                                 // C99
    265265%token ATOMIC                                                                                   // C11
    266 %token FORALL MUTEX VIRTUAL COERCE                                              // CFA
     266%token FORALL MUTEX VIRTUAL VTABLE COERCE                               // CFA
    267267%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    268268%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    270270%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
    271271%token ZERO_T ONE_T                                                                             // CFA
    272 %token VALIST                                                                                   // GCC
    273 %token AUTO_TYPE                                                                                // GCC
    274 %token TYPEOF BASETYPEOF LABEL                                                  // GCC
     272%token SIZEOF TYPEOF VALIST AUTO_TYPE                                   // GCC
     273%token OFFSETOF BASETYPEOF TYPEID                                               // CFA
    275274%token ENUM STRUCT UNION
    276275%token EXCEPTION                                                                                // CFA
    277276%token GENERATOR COROUTINE MONITOR THREAD                               // CFA
    278277%token OTYPE FTYPE DTYPE TTYPE TRAIT                                    // CFA
    279 %token SIZEOF OFFSETOF
    280278// %token RESUME                                                                                        // CFA
     279%token LABEL                                                                                    // GCC
    281280%token SUSPEND                                                                                  // CFA
    282281%token ATTRIBUTE EXTENSION                                                              // GCC
    283282%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    284 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
     283%token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR    // CFA
     284%token DISABLE ENABLE TRY THROW THROWRESUME AT                  // CFA
    285285%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    286286%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
    287287
    288288// names and constants: lexer differentiates between identifier and typedef names
    289 %token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    290 %token<tok> TIMEOUT                             WOR
    291 %token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
     289%token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDEFname             TYPEGENname
     290%token<tok> TIMEOUT                     WOR                                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
     291%token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
    292292%token<tok> DIRECTIVE
    293293// Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and
     
    321321%type<en> constant
    322322%type<en> tuple                                                 tuple_expression_list
    323 %type<op> ptrref_operator                               unary_operator                          assignment_operator
     323%type<op> ptrref_operator                               unary_operator                          assignment_operator                     simple_assignment_operator      compound_assignment_operator
    324324%type<en> primary_expression                    postfix_expression                      unary_expression
    325325%type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
     
    373373
    374374%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
     375%type<decl> vtable vtable_opt default_opt
    375376
    376377%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     
    428429
    429430%type<decl> type_declaration_specifier type_type_specifier type_name typegen_name
    430 %type<decl> typedef typedef_declaration typedef_expression
     431%type<decl> typedef_name typedef_declaration typedef_expression
    431432
    432433%type<decl> variable_type_redeclarator type_ptr type_array type_function
     
    440441
    441442%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
    442 %type<decl> type_specifier type_specifier_nobody enum_specifier_nobody
     443%type<decl> type_specifier type_specifier_nobody
    443444
    444445%type<decl> variable_declarator variable_ptr variable_array variable_function
    445446%type<decl> variable_abstract_declarator variable_abstract_ptr variable_abstract_array variable_abstract_function
    446447
    447 %type<decl> attribute_list_opt attribute_list attribute_opt attribute attribute_name_list attribute_name
     448%type<decl> attribute_list_opt attribute_list attribute attribute_name_list attribute_name
    448449
    449450// initializers
     
    462463// Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left
    463464// associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
    464 %precedence THEN        // rule precedence for IF/WAITFOR statement
    465 %precedence WOR         // token precedence for start of WOR in WAITFOR statement
    466 %precedence TIMEOUT     // token precedence for start of TIMEOUT in WAITFOR statement
    467 %precedence ELSE        // token precedence for start of else clause in IF/WAITFOR statement
     465%precedence THEN                // rule precedence for IF/WAITFOR statement
     466%precedence WOR                 // token precedence for start of WOR in WAITFOR statement
     467%precedence TIMEOUT             // token precedence for start of TIMEOUT in WAITFOR statement
     468%precedence CATCH               // token precedence for start of TIMEOUT in WAITFOR statement
     469%precedence RECOVER             // token precedence for start of TIMEOUT in WAITFOR statement
     470%precedence CATCHRESUME // token precedence for start of TIMEOUT in WAITFOR statement
     471%precedence FIXUP               // token precedence for start of TIMEOUT in WAITFOR statement
     472%precedence FINALLY             // token precedence for start of TIMEOUT in WAITFOR statement
     473%precedence ELSE                // token precedence for start of else clause in IF/WAITFOR statement
     474
    468475
    469476// Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous:
     
    544551        TIMEOUT
    545552        | WOR
     553        | CATCH
     554        | RECOVER
     555        | CATCHRESUME
     556        | FIXUP
     557        | FINALLY
    546558        ;
    547559
     
    774786        | OFFSETOF '(' type_no_function ',' identifier ')'
    775787                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
     788        | TYPEID '(' type_no_function ')'
     789                {
     790                        SemanticError( yylloc, "typeid name is currently unimplemented." ); $$ = nullptr;
     791                        // $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) );
     792                }
    776793        ;
    777794
     
    795812                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    796813        | '(' aggregate_control '&' ')' cast_expression         // CFA
     814                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
     815        | '(' aggregate_control '*' ')' cast_expression         // CFA
    797816                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    798817        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    939958
    940959assignment_operator:
     960        simple_assignment_operator
     961        | compound_assignment_operator
     962        ;
     963
     964simple_assignment_operator:
    941965        '='                                                                                     { $$ = OperKinds::Assign; }
    942         | ATassign                                                                      { $$ = OperKinds::AtAssn; }
    943         | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
     966        | ATassign                                                                      { $$ = OperKinds::AtAssn; } // CFA
     967        ;
     968
     969compound_assignment_operator:
     970        EXPassign                                                                       { $$ = OperKinds::ExpAssn; }
    944971        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    945972        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    10191046                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    10201047        | '{' push
    1021           local_label_declaration_opt                                           // GCC, local labels
     1048          local_label_declaration_opt                                           // GCC, local labels appear at start of block
    10221049          statement_decl_list                                                           // C99, intermix declarations and statements
    10231050          pop '}'
     
    12171244        | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA
    12181245                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); }
     1246
     1247        | comma_expression ';' TYPEDEFname                                      // CFA, array type
     1248                {
     1249                        SemanticError( yylloc, "Array interator is currently unimplemented." ); $$ = nullptr;
     1250                        $$ = forCtrl( new ExpressionNode( build_varref( $3 ) ), $1, nullptr, OperKinds::Range, nullptr, nullptr );
     1251                }
    12191252
    12201253                // There is a S/R conflicit if ~ and -~ are factored out.
     
    13661399
    13671400exception_statement:
    1368         TRY compound_statement handler_clause
     1401        TRY compound_statement handler_clause                                   %prec THEN
    13691402                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    13701403        | TRY compound_statement finally_clause
     
    13891422handler_key:
    13901423        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1424        | RECOVER                                                                       { $$ = CatchStmt::Terminate; }
    13911425        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
     1426        | FIXUP                                                                         { $$ = CatchStmt::Resume; }
    13921427        ;
    13931428
     
    17411776        ;
    17421777
    1743 enum_specifier_nobody:                                                                  // type specifier - {...}
    1744                 // Preclude SUE declarations in restricted scopes (see type_specifier_nobody)
    1745         basic_type_specifier
    1746         | sue_type_specifier_nobody
    1747         ;
    1748 
    17491778type_qualifier_list_opt:                                                                // GCC, used in asm_statement
    17501779        // empty
     
    17661795type_qualifier:
    17671796        type_qualifier_name
    1768         | attribute
     1797        | attribute                                                                                     // trick handles most atrribute locations
    17691798        ;
    17701799
     
    18741903        | AUTO_TYPE
    18751904                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
     1905        | vtable
     1906        ;
     1907
     1908vtable_opt:
     1909        // empty
     1910                { $$ = nullptr; }
     1911        | vtable;
     1912        ;
     1913
     1914vtable:
     1915        VTABLE '(' type_list ')' default_opt
     1916                { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
     1917        ;
     1918
     1919default_opt:
     1920        // empty
     1921                { $$ = nullptr; }
     1922        | DEFAULT
     1923                { SemanticError( yylloc, "vtable default is currently unimplemented." ); $$ = nullptr; }
    18761924        ;
    18771925
     
    20252073          '{' field_declaration_list_opt '}' type_parameters_opt
    20262074                { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); }
    2027         | aggregate_key attribute_list_opt type_name
    2028                 {
    2029                         // for type_name can be a qualified type name S.T, in which case only the last name in the chain needs a typedef (other names in the chain should already have one)
    2030                         typedefTable.makeTypedef( *$3->type->leafName(), forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     2075        | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
     2076                {
     2077                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
    20312078                        forall = false;                                                         // reset
    20322079                }
    20332080          '{' field_declaration_list_opt '}' type_parameters_opt
    2034                 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $8, $6, true )->addQualifiers( $2 ); }
     2081                {
     2082                        DeclarationNode::newFromTypedef( $3 );
     2083                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     2084                }
     2085        | aggregate_key attribute_list_opt TYPEGENname          // unqualified type name
     2086                {
     2087                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     2088                        forall = false;                                                         // reset
     2089                }
     2090          '{' field_declaration_list_opt '}' type_parameters_opt
     2091                {
     2092                        DeclarationNode::newFromTypeGen( $3, nullptr );
     2093                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     2094                }
    20352095        | aggregate_type_nobody
    20362096        ;
     
    20692129
    20702130aggregate_data:
    2071         STRUCT
    2072                 { yyy = true; $$ = AggregateDecl::Struct; }
     2131        STRUCT vtable_opt
     2132                { $$ = AggregateDecl::Struct; }
    20732133        | UNION
    2074                 { yyy = true; $$ = AggregateDecl::Union; }
     2134                { $$ = AggregateDecl::Union; }
    20752135        | EXCEPTION                                                                                     // CFA
    2076                 // { yyy = true; $$ = AggregateDecl::Exception; }
    2077                 { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2136                { $$ = AggregateDecl::Exception; }
     2137          //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20782138        ;
    20792139
    20802140aggregate_control:                                                                              // CFA
    20812141        MONITOR
    2082                 { yyy = true; $$ = AggregateDecl::Monitor; }
     2142                { $$ = AggregateDecl::Monitor; }
    20832143        | MUTEX STRUCT
    2084                 { yyy = true; $$ = AggregateDecl::Monitor; }
     2144                { $$ = AggregateDecl::Monitor; }
    20852145        | GENERATOR
    2086                 { yyy = true; $$ = AggregateDecl::Generator; }
     2146                { $$ = AggregateDecl::Generator; }
    20872147        | MUTEX GENERATOR
    20882148                { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20892149        | COROUTINE
    2090                 { yyy = true; $$ = AggregateDecl::Coroutine; }
     2150                { $$ = AggregateDecl::Coroutine; }
    20912151        | MUTEX COROUTINE
    20922152                { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20932153        | THREAD
    2094                 { yyy = true; $$ = AggregateDecl::Thread; }
     2154                { $$ = AggregateDecl::Thread; }
    20952155        | MUTEX THREAD
    20962156                { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     
    21882248        ;
    21892249
    2190 // Cannot use attribute_list_opt because of ambiguity with enum_specifier_nobody, which already parses attribute.
    2191 // Hence, only a single attribute is allowed after the "ENUM".
    21922250enum_type:                                                                                              // enum
    2193         ENUM attribute_opt '{' enumerator_list comma_opt '}'
     2251        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    21942252                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2195         | ENUM attribute_opt identifier
     2253        | ENUM attribute_list_opt identifier
    21962254                { typedefTable.makeTypedef( *$3 ); }
    21972255          '{' enumerator_list comma_opt '}'
    21982256                { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
    2199         | ENUM attribute_opt typedef                                            // enum cannot be generic
     2257        | ENUM attribute_list_opt typedef_name                          // unqualified type name
    22002258          '{' enumerator_list comma_opt '}'
    22012259                { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }
    2202         | ENUM enum_specifier_nobody '{' enumerator_list comma_opt '}'
    2203                 // { $$ = DeclarationNode::newEnum( nullptr, $4, true ); }
    2204                 { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; }
    2205         | ENUM enum_specifier_nobody declarator '{' enumerator_list comma_opt '}'
    2206                 // {
    2207                 //      typedefTable.makeTypedef( *$3->name );
    2208                 //      $$ = DeclarationNode::newEnum( nullptr, $5, true );
    2209                 // }
    2210                 { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; }
     2260        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
     2261                {
     2262                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     2263                        SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2264                }
     2265        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
     2266                {
     2267                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     2268                        typedefTable.makeTypedef( *$6 );
     2269                }
     2270          '{' enumerator_list comma_opt '}'
     2271                {
     2272                        SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2273                }
     2274        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     2275                {
     2276                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     2277                        typedefTable.makeTypedef( *$6->name );
     2278                        SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2279                }
    22112280        | enum_type_nobody
    22122281        ;
    22132282
    22142283enum_type_nobody:                                                                               // enum - {...}
    2215         ENUM attribute_opt identifier
    2216                 {
    2217                         typedefTable.makeTypedef( *$3 );
    2218                         $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 );
    2219                 }
    2220         | ENUM attribute_opt type_name                                          // enum cannot be generic
    2221                 {
    2222                         typedefTable.makeTypedef( *$3->type->symbolic.name );
    2223                         $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 );
    2224                 }
     2284        ENUM attribute_list_opt identifier
     2285                { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); }
     2286        | ENUM attribute_list_opt type_name                                     // qualified type name
     2287                { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); }
    22252288        ;
    22262289
     
    22282291        identifier_or_type_name enumerator_value_opt
    22292292                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
     2293        | INLINE type_name
     2294                { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); }
    22302295        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    22312296                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
     2297        | enumerator_list ',' INLINE type_name enumerator_value_opt
     2298                { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); }
    22322299        ;
    22332300
     
    22372304        // | '=' constant_expression
    22382305        //      { $$ = $2; }
    2239         | '=' initializer
     2306        | simple_assignment_operator initializer
    22402307                { $$ = $2->get_expression(); }                                  // FIX ME: enum only deals with constant_expression
    22412308        ;
     
    23652432        // empty
    23662433                { $$ = nullptr; }
    2367         | '=' initializer
    2368                 { $$ = $2; }
    2369         | '=' VOID
    2370                 { $$ = new InitializerNode( true ); }
    2371         | ATassign initializer
    2372                 { $$ = $2->set_maybeConstructed( false ); }
     2434        | simple_assignment_operator initializer        { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); }
     2435        | '=' VOID                                                                      { $$ = new InitializerNode( true ); }
    23732436        ;
    23742437
     
    26262689
    26272690external_definition:
    2628         declaration
     2691        DIRECTIVE
     2692                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
     2693        | declaration
    26292694        | external_function_definition
    26302695        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     
    26342699                }
    26352700        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    2636                 {
    2637                         $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );
    2638                 }
     2701                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
    26392702        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
    26402703                {
     
    27822845        ;
    27832846
    2784 attribute_opt:
    2785         // empty
    2786                 { $$ = nullptr; }
    2787         | attribute
    2788         ;
    2789 
    27902847attribute:                                                                                              // GCC
    27912848        ATTRIBUTE '(' '(' attribute_name_list ')' ')'
     
    28492906// declaring an array of functions versus a pointer to an array of functions.
    28502907
     2908paren_identifier:
     2909        identifier
     2910                { $$ = DeclarationNode::newName( $1 ); }
     2911        | '(' paren_identifier ')'                                                      // redundant parenthesis
     2912                { $$ = $2; }
     2913        ;
     2914
    28512915variable_declarator:
    28522916        paren_identifier attribute_list_opt
     
    28592923        ;
    28602924
    2861 paren_identifier:
    2862         identifier
    2863                 { $$ = DeclarationNode::newName( $1 ); }
    2864         | '(' paren_identifier ')'                                                      // redundant parenthesis
    2865                 { $$ = $2; }
    2866         ;
    2867 
    28682925variable_ptr:
    28692926        ptrref_operator variable_declarator
     
    28712928        | ptrref_operator type_qualifier_list variable_declarator
    28722929                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    2873         | '(' variable_ptr ')' attribute_list_opt
    2874                 { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
     2930        | '(' variable_ptr ')' attribute_list_opt                       // redundant parenthesis
     2931                { $$ = $2->addQualifiers( $4 ); }
     2932        | '(' attribute_list variable_ptr ')' attribute_list_opt // redundant parenthesis
     2933                { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
    28752934        ;
    28762935
     
    28802939        | '(' variable_ptr ')' array_dimension
    28812940                { $$ = $2->addArray( $4 ); }
    2882         | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
     2941        | '(' attribute_list variable_ptr ')' array_dimension
     2942                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
     2943        | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
    28832944                { $$ = $2->addArray( $4 ); }
     2945        | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis
     2946                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    28842947        | '(' variable_array ')'                                                        // redundant parenthesis
    28852948                { $$ = $2; }
     2949        | '(' attribute_list variable_array ')'                         // redundant parenthesis
     2950                { $$ = $3->addQualifiers( $2 ); }
    28862951        ;
    28872952
     
    28892954        '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    28902955                { $$ = $2->addParamList( $6 ); }
     2956        | '(' attribute_list variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     2957                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    28912958        | '(' variable_function ')'                                                     // redundant parenthesis
    28922959                { $$ = $2; }
     2960        | '(' attribute_list variable_function ')'                      // redundant parenthesis
     2961                { $$ = $3->addQualifiers( $2 ); }
    28932962        ;
    28942963
     
    29102979        | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')'
    29112980                { $$ = $2->addParamList( $6 ); }
     2981        | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')'
     2982                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    29122983        | '(' function_no_ptr ')'                                                       // redundant parenthesis
    29132984                { $$ = $2; }
     2985        | '(' attribute_list function_no_ptr ')'                        // redundant parenthesis
     2986                { $$ = $3->addQualifiers( $2 ); }
    29142987        ;
    29152988
     
    29192992        | ptrref_operator type_qualifier_list function_declarator
    29202993                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    2921         | '(' function_ptr ')'
    2922                 { $$ = $2; }
     2994        | '(' function_ptr ')' attribute_list_opt
     2995                { $$ = $2->addQualifiers( $4 ); }
     2996        | '(' attribute_list function_ptr ')' attribute_list_opt
     2997                { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
    29232998        ;
    29242999
     
    29263001        '(' function_ptr ')' array_dimension
    29273002                { $$ = $2->addArray( $4 ); }
     3003        | '(' attribute_list function_ptr ')' array_dimension
     3004                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    29283005        | '(' function_array ')' multi_array_dimension          // redundant parenthesis
    29293006                { $$ = $2->addArray( $4 ); }
     3007        | '(' attribute_list function_array ')' multi_array_dimension // redundant parenthesis
     3008                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    29303009        | '(' function_array ')'                                                        // redundant parenthesis
    29313010                { $$ = $2; }
     3011        | '(' attribute_list function_array ')'                         // redundant parenthesis
     3012                { $$ = $3->addQualifiers( $2 ); }
    29323013        ;
    29333014
     
    29503031        | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    29513032                { $$ = $2->addParamList( $6 ); }
     3033        | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
     3034                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    29523035        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    29533036                { $$ = $2; }
     3037        | '(' attribute_list KR_function_no_ptr ')'                     // redundant parenthesis
     3038                { $$ = $3->addQualifiers( $2 ); }
    29543039        ;
    29553040
     
    29613046        | '(' KR_function_ptr ')'
    29623047                { $$ = $2; }
     3048        | '(' attribute_list KR_function_ptr ')'
     3049                { $$ = $3->addQualifiers( $2 ); }
    29633050        ;
    29643051
     
    29663053        '(' KR_function_ptr ')' array_dimension
    29673054                { $$ = $2->addArray( $4 ); }
     3055        | '(' attribute_list KR_function_ptr ')' array_dimension
     3056                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    29683057        | '(' KR_function_array ')' multi_array_dimension       // redundant parenthesis
    29693058                { $$ = $2->addArray( $4 ); }
     3059        | '(' attribute_list KR_function_array ')' multi_array_dimension // redundant parenthesis
     3060                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    29703061        | '(' KR_function_array ')'                                                     // redundant parenthesis
    29713062                { $$ = $2; }
     3063        | '(' attribute_list KR_function_array ')'                      // redundant parenthesis
     3064                { $$ = $3->addQualifiers( $2 ); }
    29723065        ;
    29733066
     
    29813074// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    29823075// and functions versus pointers to arrays and functions.
     3076
     3077paren_type:
     3078        typedef_name
     3079                {
     3080                        // hide type name in enclosing scope by variable name
     3081                        typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );
     3082                }
     3083        | '(' paren_type ')'
     3084                { $$ = $2; }
     3085        ;
    29833086
    29843087variable_type_redeclarator:
     
    29923095        ;
    29933096
    2994 paren_type:
    2995         typedef
    2996                 // hide type name in enclosing scope by variable name
    2997                 {
    2998                         // if ( ! typedefTable.existsCurr( *$1->name ) ) {
    2999                                 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );
    3000                         // } else {
    3001                         //      SemanticError( yylloc, string("'") + *$1->name + "' redeclared as different kind of symbol." ); $$ = nullptr;
    3002                         // } // if
    3003                 }
    3004         | '(' paren_type ')'
    3005                 { $$ = $2; }
    3006         ;
    3007 
    30083097type_ptr:
    30093098        ptrref_operator variable_type_redeclarator
     
    30113100        | ptrref_operator type_qualifier_list variable_type_redeclarator
    30123101                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3013         | '(' type_ptr ')' attribute_list_opt
    3014                 { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
     3102        | '(' type_ptr ')' attribute_list_opt                           // redundant parenthesis
     3103                { $$ = $2->addQualifiers( $4 ); }
     3104        | '(' attribute_list type_ptr ')' attribute_list_opt // redundant parenthesis
     3105                { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
    30153106        ;
    30163107
     
    30203111        | '(' type_ptr ')' array_dimension
    30213112                { $$ = $2->addArray( $4 ); }
     3113        | '(' attribute_list type_ptr ')' array_dimension
     3114                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30223115        | '(' type_array ')' multi_array_dimension                      // redundant parenthesis
    30233116                { $$ = $2->addArray( $4 ); }
     3117        | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis
     3118                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30243119        | '(' type_array ')'                                                            // redundant parenthesis
    30253120                { $$ = $2; }
     3121        | '(' attribute_list type_array ')'                                     // redundant parenthesis
     3122                { $$ = $3->addQualifiers( $2 ); }
    30263123        ;
    30273124
     
    30313128        | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    30323129                { $$ = $2->addParamList( $6 ); }
     3130        | '(' attribute_list type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3131                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    30333132        | '(' type_function ')'                                                         // redundant parenthesis
    30343133                { $$ = $2; }
     3134        | '(' attribute_list type_function ')'                          // redundant parenthesis
     3135                { $$ = $3->addQualifiers( $2 ); }
    30353136        ;
    30363137
     
    30573158        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    30583159                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3059         | '(' identifier_parameter_ptr ')' attribute_list_opt
     3160        | '(' identifier_parameter_ptr ')' attribute_list_opt // redundant parenthesis
    30603161                { $$ = $2->addQualifiers( $4 ); }
    30613162        ;
     
    30913192
    30923193type_parameter_redeclarator:
    3093         typedef attribute_list_opt
     3194        typedef_name attribute_list_opt
    30943195                { $$ = $1->addQualifiers( $2 ); }
    3095         | '&' MUTEX typedef attribute_list_opt
     3196        | '&' MUTEX typedef_name attribute_list_opt
    30963197                { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    30973198        | type_parameter_ptr
     
    31023203        ;
    31033204
    3104 typedef:
     3205typedef_name:
    31053206        TYPEDEFname
    31063207                { $$ = DeclarationNode::newName( $1 ); }
     
    31143215        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    31153216                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3116         | '(' type_parameter_ptr ')' attribute_list_opt
     3217        | '(' type_parameter_ptr ')' attribute_list_opt         // redundant parenthesis
    31173218                { $$ = $2->addQualifiers( $4 ); }
    31183219        ;
    31193220
    31203221type_parameter_array:
    3121         typedef array_parameter_dimension
     3222        typedef_name array_parameter_dimension
    31223223                { $$ = $1->addArray( $2 ); }
    31233224        | '(' type_parameter_ptr ')' array_parameter_dimension
     
    31263227
    31273228type_parameter_function:
    3128         typedef '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
     3229        typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    31293230                { $$ = $1->addParamList( $4 ); }
    31303231        | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     
    32553356        | ptrref_operator type_qualifier_list abstract_parameter_declarator
    32563357                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3257         | '(' abstract_parameter_ptr ')' attribute_list_opt
     3358        | '(' abstract_parameter_ptr ')' attribute_list_opt     // redundant parenthesis
    32583359                { $$ = $2->addQualifiers( $4 ); }
    32593360        ;
     
    33343435        | ptrref_operator type_qualifier_list variable_abstract_declarator
    33353436                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3336         | '(' variable_abstract_ptr ')' attribute_list_opt
     3437        | '(' variable_abstract_ptr ')' attribute_list_opt      // redundant parenthesis
    33373438                { $$ = $2->addQualifiers( $4 ); }
    33383439        ;
Note: See TracChangeset for help on using the changeset viewer.