Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r24711a3 r6a99803  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 26 18:41:54 2021
    13 // Update Count     : 4990
     12// Last Modified On : Wed Feb  3 18:30:12 2021
     13// Update Count     : 4700
    1414//
    1515
     
    3232//
    3333// 1. designation with and without '=' (use ':' instead)
    34 
     34// 2. attributes not allowed in parenthesis of declarator
    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;                                                                    // aggregate have one or more forall qualifiers ?
     213bool forall = false, yyy = 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 VTABLE COERCE                               // CFA
     266%token FORALL MUTEX VIRTUAL 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 SIZEOF TYPEOF VALIST AUTO_TYPE                                   // GCC
    273 %token OFFSETOF BASETYPEOF TYPEID                                               // CFA
     272%token VALIST                                                                                   // GCC
     273%token AUTO_TYPE                                                                                // GCC
     274%token TYPEOF BASETYPEOF LABEL                                                  // GCC
    274275%token ENUM STRUCT UNION
    275276%token EXCEPTION                                                                                // CFA
    276277%token GENERATOR COROUTINE MONITOR THREAD                               // CFA
    277278%token OTYPE FTYPE DTYPE TTYPE TRAIT                                    // CFA
     279%token SIZEOF OFFSETOF
    278280// %token RESUME                                                                                        // CFA
    279 %token LABEL                                                                                    // GCC
    280281%token SUSPEND                                                                                  // CFA
    281282%token ATTRIBUTE EXTENSION                                                              // GCC
    282283%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    283 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR    // CFA
    284 %token DISABLE ENABLE TRY THROW THROWRESUME AT                  // CFA
     284%token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // 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                                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
    291 %token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
     289%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
     290%token<tok> TIMEOUT                             WOR
     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                     simple_assignment_operator      compound_assignment_operator
     323%type<op> ptrref_operator                               unary_operator                          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
    376375
    377376%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     
    429428
    430429%type<decl> type_declaration_specifier type_type_specifier type_name typegen_name
    431 %type<decl> typedef_name typedef_declaration typedef_expression
     430%type<decl> typedef typedef_declaration typedef_expression
    432431
    433432%type<decl> variable_type_redeclarator type_ptr type_array type_function
     
    441440
    442441%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
    443 %type<decl> type_specifier type_specifier_nobody
     442%type<decl> type_specifier type_specifier_nobody enum_specifier_nobody
    444443
    445444%type<decl> variable_declarator variable_ptr variable_array variable_function
    446445%type<decl> variable_abstract_declarator variable_abstract_ptr variable_abstract_array variable_abstract_function
    447446
    448 %type<decl> attribute_list_opt attribute_list attribute attribute_name_list attribute_name
     447%type<decl> attribute_list_opt attribute_list attribute_opt attribute attribute_name_list attribute_name
    449448
    450449// initializers
     
    463462// Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left
    464463// associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
    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 
     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
    475468
    476469// Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous:
     
    551544        TIMEOUT
    552545        | WOR
    553         | CATCH
    554         | RECOVER
    555         | CATCHRESUME
    556         | FIXUP
    557         | FINALLY
    558546        ;
    559547
     
    786774        | OFFSETOF '(' type_no_function ',' identifier ')'
    787775                { $$ = 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                 }
    793776        ;
    794777
     
    812795                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    813796        | '(' aggregate_control '&' ')' cast_expression         // CFA
    814                 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    815         | '(' aggregate_control '*' ')' cast_expression         // CFA
    816797                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    817798        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    958939
    959940assignment_operator:
    960         simple_assignment_operator
    961         | compound_assignment_operator
    962         ;
    963 
    964 simple_assignment_operator:
    965941        '='                                                                                     { $$ = OperKinds::Assign; }
    966         | ATassign                                                                      { $$ = OperKinds::AtAssn; } // CFA
    967         ;
    968 
    969 compound_assignment_operator:
    970         EXPassign                                                                       { $$ = OperKinds::ExpAssn; }
     942        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
     943        | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    971944        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    972945        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    10461019                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    10471020        | '{' push
    1048           local_label_declaration_opt                                           // GCC, local labels appear at start of block
     1021          local_label_declaration_opt                                           // GCC, local labels
    10491022          statement_decl_list                                                           // C99, intermix declarations and statements
    10501023          pop '}'
     
    12441217        | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA
    12451218                { $$ = 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                 }
    12521219
    12531220                // There is a S/R conflicit if ~ and -~ are factored out.
     
    13991366
    14001367exception_statement:
    1401         TRY compound_statement handler_clause                                   %prec THEN
     1368        TRY compound_statement handler_clause
    14021369                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    14031370        | TRY compound_statement finally_clause
     
    14221389handler_key:
    14231390        CATCH                                                                           { $$ = CatchStmt::Terminate; }
    1424         | RECOVER                                                                       { $$ = CatchStmt::Terminate; }
    14251391        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
    1426         | FIXUP                                                                         { $$ = CatchStmt::Resume; }
    14271392        ;
    14281393
     
    17761741        ;
    17771742
     1743enum_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
    17781749type_qualifier_list_opt:                                                                // GCC, used in asm_statement
    17791750        // empty
     
    17951766type_qualifier:
    17961767        type_qualifier_name
    1797         | attribute                                                                                     // trick handles most atrribute locations
     1768        | attribute
    17981769        ;
    17991770
     
    19031874        | AUTO_TYPE
    19041875                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
    1905         | vtable
    1906         ;
    1907 
    1908 vtable_opt:
    1909         // empty
    1910                 { $$ = nullptr; }
    1911         | vtable;
    1912         ;
    1913 
    1914 vtable:
    1915         VTABLE '(' type_list ')' default_opt
    1916                 { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
    1917         ;
    1918 
    1919 default_opt:
    1920         // empty
    1921                 { $$ = nullptr; }
    1922         | DEFAULT
    1923                 { SemanticError( yylloc, "vtable default is currently unimplemented." ); $$ = nullptr; }
    19241876        ;
    19251877
     
    20732025          '{' field_declaration_list_opt '}' type_parameters_opt
    20742026                { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); }
    2075         | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
    2076                 {
    2077                         typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     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
    20782031                        forall = false;                                                         // reset
    20792032                }
    20802033          '{' field_declaration_list_opt '}' type_parameters_opt
    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                 }
     2034                { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $8, $6, true )->addQualifiers( $2 ); }
    20952035        | aggregate_type_nobody
    20962036        ;
     
    21292069
    21302070aggregate_data:
    2131         STRUCT vtable_opt
    2132                 { $$ = AggregateDecl::Struct; }
     2071        STRUCT
     2072                { yyy = true; $$ = AggregateDecl::Struct; }
    21332073        | UNION
    2134                 { $$ = AggregateDecl::Union; }
     2074                { yyy = true; $$ = AggregateDecl::Union; }
    21352075        | EXCEPTION                                                                                     // CFA
    2136                 { $$ = AggregateDecl::Exception; }
    2137           //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2076                // { yyy = true; $$ = AggregateDecl::Exception; }
     2077                { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    21382078        ;
    21392079
    21402080aggregate_control:                                                                              // CFA
    21412081        MONITOR
    2142                 { $$ = AggregateDecl::Monitor; }
     2082                { yyy = true; $$ = AggregateDecl::Monitor; }
    21432083        | MUTEX STRUCT
    2144                 { $$ = AggregateDecl::Monitor; }
     2084                { yyy = true; $$ = AggregateDecl::Monitor; }
    21452085        | GENERATOR
    2146                 { $$ = AggregateDecl::Generator; }
     2086                { yyy = true; $$ = AggregateDecl::Generator; }
    21472087        | MUTEX GENERATOR
    21482088                { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    21492089        | COROUTINE
    2150                 { $$ = AggregateDecl::Coroutine; }
     2090                { yyy = true; $$ = AggregateDecl::Coroutine; }
    21512091        | MUTEX COROUTINE
    21522092                { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    21532093        | THREAD
    2154                 { $$ = AggregateDecl::Thread; }
     2094                { yyy = true; $$ = AggregateDecl::Thread; }
    21552095        | MUTEX THREAD
    21562096                { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     
    22482188        ;
    22492189
     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".
    22502192enum_type:                                                                                              // enum
    2251         ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
     2193        ENUM attribute_opt '{' enumerator_list comma_opt '}'
    22522194                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2253         | ENUM attribute_list_opt identifier
     2195        | ENUM attribute_opt identifier
    22542196                { typedefTable.makeTypedef( *$3 ); }
    22552197          '{' enumerator_list comma_opt '}'
    22562198                { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
    2257         | ENUM attribute_list_opt typedef_name                          // unqualified type name
     2199        | ENUM attribute_opt typedef                                            // enum cannot be generic
    22582200          '{' enumerator_list comma_opt '}'
    22592201                { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }
    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                 }
     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; }
    22802211        | enum_type_nobody
    22812212        ;
    22822213
    22832214enum_type_nobody:                                                                               // enum - {...}
    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 ); }
     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                }
    22882225        ;
    22892226
     
    22912228        identifier_or_type_name enumerator_value_opt
    22922229                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    2293         | INLINE type_name
    2294                 { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); }
    22952230        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    22962231                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    2297         | enumerator_list ',' INLINE type_name enumerator_value_opt
    2298                 { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); }
    22992232        ;
    23002233
     
    23042237        // | '=' constant_expression
    23052238        //      { $$ = $2; }
    2306         | simple_assignment_operator initializer
     2239        | '=' initializer
    23072240                { $$ = $2->get_expression(); }                                  // FIX ME: enum only deals with constant_expression
    23082241        ;
     
    24322365        // empty
    24332366                { $$ = nullptr; }
    2434         | simple_assignment_operator initializer        { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); }
    2435         | '=' VOID                                                                      { $$ = new InitializerNode( true ); }
     2367        | '=' initializer
     2368                { $$ = $2; }
     2369        | '=' VOID
     2370                { $$ = new InitializerNode( true ); }
     2371        | ATassign initializer
     2372                { $$ = $2->set_maybeConstructed( false ); }
    24362373        ;
    24372374
     
    26892626
    26902627external_definition:
    2691         DIRECTIVE
    2692                 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
    2693         | declaration
     2628        declaration
    26942629        | external_function_definition
    26952630        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
     
    26992634                }
    27002635        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    2701                 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
     2636                {
     2637                        $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );
     2638                }
    27022639        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
    27032640                {
     
    28452782        ;
    28462783
     2784attribute_opt:
     2785        // empty
     2786                { $$ = nullptr; }
     2787        | attribute
     2788        ;
     2789
    28472790attribute:                                                                                              // GCC
    28482791        ATTRIBUTE '(' '(' attribute_name_list ')' ')'
     
    29062849// declaring an array of functions versus a pointer to an array of functions.
    29072850
    2908 paren_identifier:
    2909         identifier
    2910                 { $$ = DeclarationNode::newName( $1 ); }
    2911         | '(' paren_identifier ')'                                                      // redundant parenthesis
    2912                 { $$ = $2; }
    2913         ;
    2914 
    29152851variable_declarator:
    29162852        paren_identifier attribute_list_opt
     
    29232859        ;
    29242860
     2861paren_identifier:
     2862        identifier
     2863                { $$ = DeclarationNode::newName( $1 ); }
     2864        | '(' paren_identifier ')'                                                      // redundant parenthesis
     2865                { $$ = $2; }
     2866        ;
     2867
    29252868variable_ptr:
    29262869        ptrref_operator variable_declarator
     
    29282871        | ptrref_operator type_qualifier_list variable_declarator
    29292872                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    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 ); }
     2873        | '(' variable_ptr ')' attribute_list_opt
     2874                { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
    29342875        ;
    29352876
     
    29392880        | '(' variable_ptr ')' array_dimension
    29402881                { $$ = $2->addArray( $4 ); }
    2941         | '(' attribute_list variable_ptr ')' array_dimension
    2942                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    2943         | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
     2882        | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
    29442883                { $$ = $2->addArray( $4 ); }
    2945         | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis
    2946                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    29472884        | '(' variable_array ')'                                                        // redundant parenthesis
    29482885                { $$ = $2; }
    2949         | '(' attribute_list variable_array ')'                         // redundant parenthesis
    2950                 { $$ = $3->addQualifiers( $2 ); }
    29512886        ;
    29522887
     
    29542889        '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    29552890                { $$ = $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 ); }
    29582891        | '(' variable_function ')'                                                     // redundant parenthesis
    29592892                { $$ = $2; }
    2960         | '(' attribute_list variable_function ')'                      // redundant parenthesis
    2961                 { $$ = $3->addQualifiers( $2 ); }
    29622893        ;
    29632894
     
    29792910        | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')'
    29802911                { $$ = $2->addParamList( $6 ); }
    2981         | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')'
    2982                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    29832912        | '(' function_no_ptr ')'                                                       // redundant parenthesis
    29842913                { $$ = $2; }
    2985         | '(' attribute_list function_no_ptr ')'                        // redundant parenthesis
    2986                 { $$ = $3->addQualifiers( $2 ); }
    29872914        ;
    29882915
     
    29922919        | ptrref_operator type_qualifier_list function_declarator
    29932920                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    2994         | '(' function_ptr ')' attribute_list_opt
    2995                 { $$ = $2->addQualifiers( $4 ); }
    2996         | '(' attribute_list function_ptr ')' attribute_list_opt
    2997                 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
     2921        | '(' function_ptr ')'
     2922                { $$ = $2; }
    29982923        ;
    29992924
     
    30012926        '(' function_ptr ')' array_dimension
    30022927                { $$ = $2->addArray( $4 ); }
    3003         | '(' attribute_list function_ptr ')' array_dimension
    3004                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30052928        | '(' function_array ')' multi_array_dimension          // redundant parenthesis
    30062929                { $$ = $2->addArray( $4 ); }
    3007         | '(' attribute_list function_array ')' multi_array_dimension // redundant parenthesis
    3008                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30092930        | '(' function_array ')'                                                        // redundant parenthesis
    30102931                { $$ = $2; }
    3011         | '(' attribute_list function_array ')'                         // redundant parenthesis
    3012                 { $$ = $3->addQualifiers( $2 ); }
    30132932        ;
    30142933
     
    30312950        | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    30322951                { $$ = $2->addParamList( $6 ); }
    3033         | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'
    3034                 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    30352952        | '(' KR_function_no_ptr ')'                                            // redundant parenthesis
    30362953                { $$ = $2; }
    3037         | '(' attribute_list KR_function_no_ptr ')'                     // redundant parenthesis
    3038                 { $$ = $3->addQualifiers( $2 ); }
    30392954        ;
    30402955
     
    30462961        | '(' KR_function_ptr ')'
    30472962                { $$ = $2; }
    3048         | '(' attribute_list KR_function_ptr ')'
    3049                 { $$ = $3->addQualifiers( $2 ); }
    30502963        ;
    30512964
     
    30532966        '(' KR_function_ptr ')' array_dimension
    30542967                { $$ = $2->addArray( $4 ); }
    3055         | '(' attribute_list KR_function_ptr ')' array_dimension
    3056                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30572968        | '(' KR_function_array ')' multi_array_dimension       // redundant parenthesis
    30582969                { $$ = $2->addArray( $4 ); }
    3059         | '(' attribute_list KR_function_array ')' multi_array_dimension // redundant parenthesis
    3060                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    30612970        | '(' KR_function_array ')'                                                     // redundant parenthesis
    30622971                { $$ = $2; }
    3063         | '(' attribute_list KR_function_array ')'                      // redundant parenthesis
    3064                 { $$ = $3->addQualifiers( $2 ); }
    30652972        ;
    30662973
     
    30742981// The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    30752982// and functions versus pointers to arrays and functions.
    3076 
    3077 paren_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         ;
    30862983
    30872984variable_type_redeclarator:
     
    30952992        ;
    30962993
     2994paren_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
    30973008type_ptr:
    30983009        ptrref_operator variable_type_redeclarator
     
    31003011        | ptrref_operator type_qualifier_list variable_type_redeclarator
    31013012                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    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 ); }
     3013        | '(' type_ptr ')' attribute_list_opt
     3014                { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
    31063015        ;
    31073016
     
    31113020        | '(' type_ptr ')' array_dimension
    31123021                { $$ = $2->addArray( $4 ); }
    3113         | '(' attribute_list type_ptr ')' array_dimension
    3114                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    31153022        | '(' type_array ')' multi_array_dimension                      // redundant parenthesis
    31163023                { $$ = $2->addArray( $4 ); }
    3117         | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis
    3118                 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    31193024        | '(' type_array ')'                                                            // redundant parenthesis
    31203025                { $$ = $2; }
    3121         | '(' attribute_list type_array ')'                                     // redundant parenthesis
    3122                 { $$ = $3->addQualifiers( $2 ); }
    31233026        ;
    31243027
     
    31283031        | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    31293032                { $$ = $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 ); }
    31323033        | '(' type_function ')'                                                         // redundant parenthesis
    31333034                { $$ = $2; }
    3134         | '(' attribute_list type_function ')'                          // redundant parenthesis
    3135                 { $$ = $3->addQualifiers( $2 ); }
    31363035        ;
    31373036
     
    31583057        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    31593058                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3160         | '(' identifier_parameter_ptr ')' attribute_list_opt // redundant parenthesis
     3059        | '(' identifier_parameter_ptr ')' attribute_list_opt
    31613060                { $$ = $2->addQualifiers( $4 ); }
    31623061        ;
     
    31923091
    31933092type_parameter_redeclarator:
    3194         typedef_name attribute_list_opt
     3093        typedef attribute_list_opt
    31953094                { $$ = $1->addQualifiers( $2 ); }
    3196         | '&' MUTEX typedef_name attribute_list_opt
     3095        | '&' MUTEX typedef attribute_list_opt
    31973096                { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    31983097        | type_parameter_ptr
     
    32033102        ;
    32043103
    3205 typedef_name:
     3104typedef:
    32063105        TYPEDEFname
    32073106                { $$ = DeclarationNode::newName( $1 ); }
     
    32153114        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    32163115                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3217         | '(' type_parameter_ptr ')' attribute_list_opt         // redundant parenthesis
     3116        | '(' type_parameter_ptr ')' attribute_list_opt
    32183117                { $$ = $2->addQualifiers( $4 ); }
    32193118        ;
    32203119
    32213120type_parameter_array:
    3222         typedef_name array_parameter_dimension
     3121        typedef array_parameter_dimension
    32233122                { $$ = $1->addArray( $2 ); }
    32243123        | '(' type_parameter_ptr ')' array_parameter_dimension
     
    32273126
    32283127type_parameter_function:
    3229         typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3128        typedef '(' push parameter_type_list_opt pop ')'        // empty parameter list OBSOLESCENT (see 3)
    32303129                { $$ = $1->addParamList( $4 ); }
    32313130        | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     
    33563255        | ptrref_operator type_qualifier_list abstract_parameter_declarator
    33573256                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3358         | '(' abstract_parameter_ptr ')' attribute_list_opt     // redundant parenthesis
     3257        | '(' abstract_parameter_ptr ')' attribute_list_opt
    33593258                { $$ = $2->addQualifiers( $4 ); }
    33603259        ;
     
    34353334        | ptrref_operator type_qualifier_list variable_abstract_declarator
    34363335                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3437         | '(' variable_abstract_ptr ')' attribute_list_opt      // redundant parenthesis
     3336        | '(' variable_abstract_ptr ')' attribute_list_opt
    34383337                { $$ = $2->addQualifiers( $4 ); }
    34393338        ;
Note: See TracChangeset for help on using the changeset viewer.