Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r9335ecc rce8c12f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // parser.yy --
     7// cfa.y --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 22:11:22 2017
    13 // Update Count     : 2414
     12// Last Modified On : Thu Mar 30 15:42:32 2017
     13// Update Count     : 2318
    1414//
    1515
     
    4848#include <cstdio>
    4949#include <stack>
     50#include "lex.h"
     51#include "parser.h"
    5052#include "ParseNode.h"
    5153#include "TypedefTable.h"
     
    8385        } // for
    8486} // distExt
    85 
    86 bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    8787%}
    88 
    89 // Types declaration
    90 %union
    91 {
    92         Token tok;
    93         ParseNode * pn;
    94         ExpressionNode * en;
    95         DeclarationNode * decl;
    96         DeclarationNode::Aggregate aggKey;
    97         DeclarationNode::TypeClass tclass;
    98         StatementNode * sn;
    99         ConstantExpr * constant;
    100         ForCtl * fctl;
    101         LabelNode * label;
    102         InitializerNode * in;
    103         OperKinds op;
    104         std::string * str;
    105         bool flag;
    106 }
    10788
    10889//************************* TERMINAL TOKENS ********************************
     
    157138%token ATassign                                                                                 // @=
    158139
    159 %type<tok> identifier  no_attr_identifier  zero_one
    160 %type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
     140// Types declaration
     141%union
     142{
     143        Token tok;
     144        ParseNode * pn;
     145        ExpressionNode * en;
     146        DeclarationNode * decl;
     147        DeclarationNode::Aggregate aggKey;
     148        DeclarationNode::TypeClass tclass;
     149        StatementNode * sn;
     150        ConstantExpr * constant;
     151        ForCtl * fctl;
     152        LabelNode * label;
     153        InitializerNode * in;
     154        OperKinds op;
     155        std::string * str;
     156        bool flag;
     157}
     158
     159%type<tok> identifier  no_01_identifier  no_attr_identifier zero_one
     160%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  no_01_identifier_or_type_name  attr_name
    161161%type<constant> string_literal
    162162%type<str> string_literal_list
     
    191191%type<sn> case_value_list                               case_label                                      case_label_list
    192192%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    193 %type<sn> /* handler_list */                    handler_clause                          finally_clause
     193%type<sn> handler_list                                  handler_clause                          finally_clause
    194194
    195195// declarations
     
    205205%type<en>   bit_subrange_size_opt bit_subrange_size
    206206
    207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
     207%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name
    208208
    209209%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     
    259259%type<decl> type_declarator type_declarator_name type_declaring_list
    260260
    261 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name
    262 %type<decl> typedef typedef_declaration typedef_expression
     261%type<decl> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression
    263262
    264263%type<decl> variable_type_redeclarator type_ptr type_array type_function
    265264
    266265%type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function
    267 
    268 %type<decl> type type_no_function
    269 %type<decl> type_parameter type_parameter_list type_initializer_opt
    270 
    271 %type<en> type_list
     266%type<decl> typegen_declaration_specifier typegen_type_specifier typegen_name
     267
     268%type<decl> type_name type_name_no_function
     269%type<decl> type_parameter type_parameter_list
     270
     271%type<en> type_name_list
    272272
    273273%type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list
     
    349349        IDENTIFIER
    350350        | ATTR_IDENTIFIER                                                                       // CFA
     351        | zero_one                                                                                      // CFA
     352        ;
     353
     354no_01_identifier:
     355        IDENTIFIER
     356        | ATTR_IDENTIFIER                                                                       // CFA
    351357        ;
    352358
    353359no_attr_identifier:
    354360        IDENTIFIER
     361        | zero_one                                                                                      // CFA
    355362        ;
    356363
     
    358365        ZERO
    359366        | ONE
    360         ;
     367        ;
    361368
    362369string_literal:
     
    386393        | '(' compound_statement ')'                                            // GCC, lambda expression
    387394                { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    388         | primary_expression '{' argument_expression_list '}' // CFA, constructor call
     395        | primary_expression '{' argument_expression_list '}' // CFA
    389396                {
    390397                        Token fn;
     
    392399                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    393400                }
    394         | type_name '.' no_attr_identifier                                      // CFA, nested type
    395                 { $$ = nullptr; }                                                               // FIX ME
    396         | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    397                 { $$ = nullptr; }                                                               // FIX ME
    398401        ;
    399402
     
    426429        | postfix_expression DECR
    427430                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
    428         | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
     431        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    429432                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
    430433        | '^' primary_expression '{' argument_expression_list '}' // CFA
     
    478481        | no_attr_identifier fraction_constants
    479482                {
    480                         $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    481                 }
    482         | zero_one fraction_constants
    483                 {
    484                         $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
     483                        if( (*$1) == "0" || (*$1) == "1" ) {
     484                                $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
     485                        } else {
     486                                $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     487                        }
    485488                }
    486489        ;
     
    530533        | SIZEOF unary_expression
    531534                { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); }
    532         | SIZEOF '(' type_no_function ')'
     535        | SIZEOF '(' type_name_no_function ')'
    533536                { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); }
    534537        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    535538                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
    536         | ALIGNOF '(' type_no_function ')'                              // GCC, type alignment
     539        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    537540                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    538         | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     541        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
    539542                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    540543        | ATTR_IDENTIFIER
     
    542545        | ATTR_IDENTIFIER '(' argument_expression ')'
    543546                { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); }
    544         | ATTR_IDENTIFIER '(' type ')'
     547        | ATTR_IDENTIFIER '(' type_name ')'
    545548                { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); }
    546549//      | ANDAND IDENTIFIER                                                                     // GCC, address of label
    547 //              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); }
     550//              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); }
    548551        ;
    549552
     
    564567cast_expression:
    565568        unary_expression
    566         | '(' type_no_function ')' cast_expression
     569        | '(' type_name_no_function ')' cast_expression
    567570                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    568 //      | '(' type_no_function ')' tuple
     571//      | '(' type_name_no_function ')' tuple
    569572//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    570573        ;
     
    653656        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    654657                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     658//      | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
     659//              { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    655660        ;
    656661
     
    664669        | unary_expression assignment_operator assignment_expression
    665670                { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
     671//      | tuple assignment_opt                                                          // CFA, tuple expression
     672//              { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
    666673        ;
    667674
     
    929936                { $$ = new StatementNode( build_throw( $2 ) ); }
    930937        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
    931                 { $$ = new StatementNode( build_resume( $2 ) ); }
     938                { $$ = new StatementNode( build_throw( $2 ) ); }
    932939        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    933                 { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
     940                { $$ = new StatementNode( build_throw( $2 ) ); }
    934941        ;
    935942
    936943exception_statement:
    937         TRY compound_statement handler_clause
     944        TRY compound_statement handler_list
    938945                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    939946        | TRY compound_statement finally_clause
    940947                { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
    941         | TRY compound_statement handler_clause finally_clause
     948        | TRY compound_statement handler_list finally_clause
    942949                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
    943950        ;
    944951
    945 //handler_list:
    946 //      handler_clause
    947 //              // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    948 //      | CATCH '(' ELLIPSIS ')' compound_statement
    949 //              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    950 //      | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    951 //              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    952 //      | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    953 //              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    954 //      | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    955 //              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    956 //      ;
     952handler_list:
     953        handler_clause
     954                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
     955        | CATCH '(' ELLIPSIS ')' compound_statement
     956                { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     957        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
     958                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     959        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
     960                { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     961        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
     962                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     963        ;
    957964
    958965handler_clause:
    959         // TEMPORARY, TEST EXCEPTIONS
    960         CATCH '(' push push INTEGERconstant pop ')' compound_statement pop
    961                 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
    962         | handler_clause CATCH '(' push push INTEGERconstant pop ')' compound_statement pop
    963                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
    964 
    965         | CATCH '(' push push exception_declaration pop ')' compound_statement pop
    966                 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); }
     966        CATCH '(' push push exception_declaration pop ')' compound_statement pop
     967                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    967968        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    968                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); }
     969                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    969970        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    970                 { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); }
     971                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    971972        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    972                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); }
     973                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    973974        ;
    974975
     
    13491350        basic_declaration_specifier
    13501351        | sue_declaration_specifier
    1351         | type_declaration_specifier
     1352        | typedef_declaration_specifier
     1353        | typegen_declaration_specifier
    13521354        ;
    13531355
     
    13601362        basic_declaration_specifier
    13611363        | sue_declaration_specifier_nobody
    1362         | type_declaration_specifier
     1364        | typedef_declaration_specifier
     1365        | typegen_declaration_specifier
    13631366        ;
    13641367
     
    13661369        basic_type_specifier
    13671370        | sue_type_specifier
    1368         | type_type_specifier
     1371        | typedef_type_specifier
     1372        | typegen_type_specifier
    13691373        ;
    13701374
     
    13771381        basic_type_specifier
    13781382        | sue_type_specifier_nobody
    1379         | type_type_specifier
     1383        | typedef_type_specifier
     1384        | typegen_type_specifier
    13801385        ;
    13811386
     
    15121517
    15131518basic_type_specifier:
    1514         direct_type
    1515         | type_qualifier_list_opt indirect_type type_qualifier_list_opt
     1519        direct_type_name
     1520        | type_qualifier_list_opt indirect_type_name type_qualifier_list_opt
    15161521                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
    15171522        ;
    15181523
    1519 direct_type:
     1524direct_type_name:
    15201525                // A semantic check is necessary for conflicting type qualifiers.
    15211526        basic_type_name
    15221527        | type_qualifier_list basic_type_name
    15231528                { $$ = $2->addQualifiers( $1 ); }
    1524         | direct_type type_qualifier
    1525                 { $$ = $1->addQualifiers( $2 ); }
    1526         | direct_type basic_type_name
     1529        | direct_type_name type_qualifier
     1530                { $$ = $1->addQualifiers( $2 ); }
     1531        | direct_type_name basic_type_name
    15271532                { $$ = $1->addType( $2 ); }
    15281533        ;
    15291534
    1530 indirect_type:
    1531         TYPEOF '(' type ')'                                                                     // GCC: typeof(x) y;
     1535indirect_type_name:
     1536        TYPEOF '(' type_name ')'                                                        // GCC: typeof(x) y;
    15321537                { $$ = $3; }
    15331538        | TYPEOF '(' comma_expression ')'                                       // GCC: typeof(a+b) y;
    15341539                { $$ = DeclarationNode::newTypeof( $3 ); }
    1535         | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type(x) y;
     1540        | ATTR_TYPEGENname '(' type_name ')'                            // CFA: e.g., @type(x) y;
    15361541                { $$ = DeclarationNode::newAttr( $1, $3 ); }
    15371542        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
     
    15511556sue_type_specifier:                                                                             // struct, union, enum + type specifier
    15521557        elaborated_type
    1553         | type_qualifier_list
    1554                 { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type
    1555           elaborated_type
    1556                 { $$ = $3->addQualifiers( $1 ); }
     1558        | type_qualifier_list elaborated_type
     1559                { $$ = $2->addQualifiers( $1 ); }
    15571560        | sue_type_specifier type_qualifier
    15581561                { $$ = $1->addQualifiers( $2 ); }
     
    15771580        ;
    15781581
    1579 type_declaration_specifier:
    1580         type_type_specifier
    1581         | declaration_qualifier_list type_type_specifier
     1582typedef_declaration_specifier:
     1583        typedef_type_specifier
     1584        | declaration_qualifier_list typedef_type_specifier
    15821585                { $$ = $2->addQualifiers( $1 ); }
    1583         | type_declaration_specifier storage_class                      // remaining OBSOLESCENT (see 2)
    1584                 { $$ = $1->addQualifiers( $2 ); }
    1585         | type_declaration_specifier storage_class type_qualifier_list
     1586        | typedef_declaration_specifier storage_class           // remaining OBSOLESCENT (see 2)
     1587                { $$ = $1->addQualifiers( $2 ); }
     1588        | typedef_declaration_specifier storage_class type_qualifier_list
    15861589                { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }
    15871590        ;
    15881591
    1589 type_type_specifier:                                                                    // typedef types
    1590         type_name
    1591         | type_qualifier_list type_name
    1592                 { $$ = $2->addQualifiers( $1 ); }
    1593         | type_type_specifier type_qualifier
    1594                 { $$ = $1->addQualifiers( $2 ); }
    1595         ;
    1596 
    1597 type_name:
     1592typedef_type_specifier:                                                                 // typedef types
    15981593        TYPEDEFname
    15991594                { $$ = DeclarationNode::newFromTypedef( $1 ); }
    1600         | '.' TYPEDEFname
    1601                 { $$ = DeclarationNode::newFromTypedef( $2 ); } // FIX ME
    1602         | type_name '.' TYPEDEFname
    1603                 { $$ = DeclarationNode::newFromTypedef( $3 ); } // FIX ME
    1604         | typegen_name
    1605         | '.' typegen_name
    1606                 { $$ = $2; }                                                                    // FIX ME
    1607         | type_name '.' typegen_name
    1608                 { $$ = $3; }                                                                    // FIX ME
    1609         ;
    1610 
    1611 typegen_name:                                                                                   // CFA
    1612         TYPEGENname '(' ')'
    1613                 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
    1614         | TYPEGENname '(' type_list ')'
    1615                 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
     1595        | type_qualifier_list TYPEDEFname
     1596                { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); }
     1597        | typedef_type_specifier type_qualifier
     1598                { $$ = $1->addQualifiers( $2 ); }
    16161599        ;
    16171600
     
    16301613                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }
    16311614        | aggregate_key attribute_list_opt no_attr_identifier_or_type_name
    1632                 {
    1633                         typedefTable.makeTypedef( *$3 );                        // create typedef
    1634                         if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update
    1635                         forall = false;                                                         // reset
    1636                 }
     1615                { typedefTable.makeTypedef( *$3 ); }
    16371616          '{' field_declaration_list '}'
    16381617                { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); }
    1639         | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list '}' // CFA
     1618        | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    16401619                { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }
    16411620        | aggregate_type_nobody
     
    16431622
    16441623aggregate_type_nobody:                                                                  // struct, union - {...}
    1645         aggregate_key attribute_list_opt no_attr_identifier
     1624        aggregate_key attribute_list_opt no_attr_identifier_or_type_name
    16461625                {
    16471626                        typedefTable.makeTypedef( *$3 );
    16481627                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    16491628                }
    1650         | aggregate_key attribute_list_opt TYPEDEFname
    1651                 {
    1652                         typedefTable.makeTypedef( *$3 );
    1653                         $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    1654                 }
    1655         | aggregate_key attribute_list_opt typegen_name         // CFA
     1629        | aggregate_key attribute_list_opt typegen_name         // CFA, S/R conflict
    16561630                { $$ = $3->addQualifiers( $2 ); }
    16571631        ;
     
    18911865        ;
    18921866
     1867no_01_identifier_or_type_name:
     1868        no_01_identifier
     1869        | TYPEDEFname
     1870        | TYPEGENname
     1871        ;
     1872
    18931873no_attr_identifier_or_type_name:
    18941874        no_attr_identifier
     
    18971877        ;
    18981878
    1899 type_no_function:                                                                               // sizeof, alignof, cast (constructor)
     1879type_name_no_function:                                                                  // sizeof, alignof, cast (constructor)
    19001880        cfa_abstract_declarator_tuple                                           // CFA
    19011881        | type_specifier
     
    19041884        ;
    19051885
    1906 type:                                                                                                   // typeof, assertion
    1907         type_no_function
     1886type_name:                                                                                              // typeof, assertion
     1887        type_name_no_function
    19081888        | cfa_abstract_function                                                         // CFA
    19091889        ;
     
    19451925designation:
    19461926        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    1947         | no_attr_identifier ':'                                                        // GCC, field name
     1927        | no_attr_identifier_or_type_name ':'                           // GCC, field name
    19481928                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    19491929        ;
     
    19571937
    19581938designator:
    1959         '.' no_attr_identifier                                                          // C99, field name
     1939        '.' no_attr_identifier_or_type_name                                     // C99, field name
    19601940                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    19611941        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    19881968//     on type arguments of polymorphic functions.
    19891969
     1970typegen_declaration_specifier:                                                  // CFA
     1971        typegen_type_specifier
     1972        | declaration_qualifier_list typegen_type_specifier
     1973                { $$ = $2->addQualifiers( $1 ); }
     1974        | typegen_declaration_specifier storage_class           // remaining OBSOLESCENT (see 2)
     1975                { $$ = $1->addQualifiers( $2 ); }
     1976        | typegen_declaration_specifier storage_class type_qualifier_list
     1977                { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }
     1978        ;
     1979
     1980typegen_type_specifier:                                                                 // CFA
     1981        typegen_name
     1982        | type_qualifier_list typegen_name
     1983                { $$ = $2->addQualifiers( $1 ); }
     1984        | typegen_type_specifier type_qualifier
     1985                { $$ = $1->addQualifiers( $2 ); }
     1986        ;
     1987
     1988typegen_name:                                                                                   // CFA
     1989        TYPEGENname '(' type_name_list ')'
     1990                { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
     1991        ;
     1992
    19901993type_parameter_list:                                                                    // CFA
    1991         type_parameter
    1992                 { $$ = $1; }
    1993         | type_parameter_list ',' type_parameter
     1994        type_parameter assignment_opt
     1995        | type_parameter_list ',' type_parameter assignment_opt
    19941996                { $$ = $1->appendList( $3 ); }
    1995         ;
    1996 
    1997 type_initializer_opt:                                                                   // CFA
    1998         // empty
    1999                 { $$ = nullptr; }
    2000         | '=' type
    2001                 { $$ = $2; }
    20021997        ;
    20031998
     
    20052000        type_class no_attr_identifier_or_type_name
    20062001                { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); }
    2007           type_initializer_opt assertion_list_opt
    2008                 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     2002          assertion_list_opt
     2003                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); }
    20092004        | type_specifier identifier_parameter_declarator
    20102005        ;
     
    20292024
    20302025assertion:                                                                                              // CFA
    2031         '|' no_attr_identifier_or_type_name '(' type_list ')'
     2026        '|' no_attr_identifier_or_type_name '(' type_name_list ')'
    20322027                {
    20332028                        typedefTable.openTrait( *$2 );
     
    20362031        | '|' '{' push trait_declaration_list '}'
    20372032                { $$ = $4; }
    2038         | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'
     2033        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
    20392034                { $$ = nullptr; }
    20402035        ;
    20412036
    2042 type_list:                                                                                              // CFA
    2043         type
     2037type_name_list:                                                                                 // CFA
     2038        type_name
    20442039                { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
    20452040        | assignment_expression
    2046         | type_list ',' type
     2041        | type_name_list ',' type_name
    20472042                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
    2048         | type_list ',' assignment_expression
     2043        | type_name_list ',' assignment_expression
    20492044                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    20502045        ;
     
    20622057        type_declarator_name assertion_list_opt
    20632058                { $$ = $1->addAssertions( $2 ); }
    2064         | type_declarator_name assertion_list_opt '=' type
     2059        | type_declarator_name assertion_list_opt '=' type_name
    20652060                { $$ = $1->addAssertions( $2 )->addType( $4 ); }
    20662061        ;
     
    20722067                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    20732068                }
    2074         | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')'
     2069        | no_01_identifier_or_type_name '(' push type_parameter_list pop ')'
    20752070                {
    20762071                        typedefTable.addToEnclosingScope( *$1, TypedefTable::TG );
     
    20982093        ;
    20992094
    2100 trait_declaration_list:                                                                 // CFA
     2095trait_declaration_list:                                                         // CFA
    21012096        trait_declaration
    21022097        | trait_declaration_list push trait_declaration
     
    21042099        ;
    21052100
    2106 trait_declaration:                                                                              // CFA
     2101trait_declaration:                                                                      // CFA
    21072102        cfa_trait_declaring_list pop ';'
    21082103        | trait_declaring_list pop ';'
     
    23822377variable_ptr:
    23832378        ptrref_operator variable_declarator
    2384                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2379                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    23852380        | ptrref_operator type_qualifier_list variable_declarator
    2386                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2381                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    23872382        | '(' variable_ptr ')' attribute_list_opt
    23882383                { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
     
    24302425function_ptr:
    24312426        ptrref_operator function_declarator
    2432                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2427                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    24332428        | ptrref_operator type_qualifier_list function_declarator
    2434                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2429                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    24352430        | '(' function_ptr ')'
    24362431                { $$ = $2; }
     
    24702465KR_function_ptr:
    24712466        ptrref_operator KR_function_declarator
    2472                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2467                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    24732468        | ptrref_operator type_qualifier_list KR_function_declarator
    2474                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2469                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    24752470        | '(' KR_function_ptr ')'
    24762471                { $$ = $2; }
     
    25142509type_ptr:
    25152510        ptrref_operator variable_type_redeclarator
    2516                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2511                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    25172512        | ptrref_operator type_qualifier_list variable_type_redeclarator
    2518                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2513                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    25192514        | '(' type_ptr ')' attribute_list_opt
    25202515                { $$ = $2->addQualifiers( $4 ); }
     
    25582553identifier_parameter_ptr:
    25592554        ptrref_operator identifier_parameter_declarator
    2560                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2555                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    25612556        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    2562                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2557                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    25632558        | '(' identifier_parameter_ptr ')' attribute_list_opt
    25642559                { $$ = $2->addQualifiers( $4 ); }
     
    26182613type_parameter_ptr:
    26192614        ptrref_operator type_parameter_redeclarator
    2620                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2615                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    26212616        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    2622                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2617                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    26232618        | '(' type_parameter_ptr ')' attribute_list_opt
    26242619                { $$ = $2->addQualifiers( $4 ); }
     
    26612656abstract_ptr:
    26622657        ptrref_operator
    2663                 { $$ = DeclarationNode::newPointer( 0 ); }
     2658                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    26642659        | ptrref_operator type_qualifier_list
    2665                 { $$ = DeclarationNode::newPointer( $2 ); }
     2660                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    26662661        | ptrref_operator abstract_declarator
    2667                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2662                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    26682663        | ptrref_operator type_qualifier_list abstract_declarator
    2669                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2664                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    26702665        | '(' abstract_ptr ')' attribute_list_opt
    26712666                { $$ = $2->addQualifiers( $4 ); }
     
    27502745abstract_parameter_ptr:
    27512746        ptrref_operator
    2752                 { $$ = DeclarationNode::newPointer( nullptr ); }
     2747                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    27532748        | ptrref_operator type_qualifier_list
    2754                 { $$ = DeclarationNode::newPointer( $2 ); }
     2749                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    27552750        | ptrref_operator abstract_parameter_declarator
    2756                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr ) ); }
     2751                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    27572752        | ptrref_operator type_qualifier_list abstract_parameter_declarator
    2758                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2753                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    27592754        | '(' abstract_parameter_ptr ')' attribute_list_opt
    27602755                { $$ = $2->addQualifiers( $4 ); }
     
    28292824variable_abstract_ptr:
    28302825        ptrref_operator
    2831                 { $$ = DeclarationNode::newPointer( 0 ); }
     2826                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    28322827        | ptrref_operator type_qualifier_list
    2833                 { $$ = DeclarationNode::newPointer( $2 ); }
     2828                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    28342829        | ptrref_operator variable_abstract_declarator
    2835                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2830                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    28362831        | ptrref_operator type_qualifier_list variable_abstract_declarator
    2837                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2832                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    28382833        | '(' variable_abstract_ptr ')' attribute_list_opt
    28392834                { $$ = $2->addQualifiers( $4 ); }
     
    28752870                // No SUE declaration in parameter list.
    28762871        ptrref_operator type_specifier_nobody
    2877                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2872                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    28782873        | type_qualifier_list ptrref_operator type_specifier_nobody
    2879                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2874                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    28802875        | ptrref_operator cfa_abstract_function
    2881                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2876                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    28822877        | type_qualifier_list ptrref_operator cfa_abstract_function
    2883                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2878                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    28842879        | ptrref_operator cfa_identifier_parameter_declarator_tuple
    2885                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2880                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    28862881        | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple
    2887                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2882                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    28882883        ;
    28892884
     
    29632958cfa_abstract_ptr:                                                                               // CFA
    29642959        ptrref_operator type_specifier
    2965                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2960                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29662961        | type_qualifier_list ptrref_operator type_specifier
    2967                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2962                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29682963        | ptrref_operator cfa_abstract_function
    2969                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2964                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29702965        | type_qualifier_list ptrref_operator cfa_abstract_function
    2971                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2966                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29722967        | ptrref_operator cfa_abstract_declarator_tuple
    2973                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2968                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29742969        | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple
    2975                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2970                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29762971        ;
    29772972
Note: See TracChangeset for help on using the changeset viewer.