Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r997185e r8a97248  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 21 22:34:30 2022
    13 // Update Count     : 5848
     12// Last Modified On : Thu Feb  2 21:36:16 2023
     13// Update Count     : 5865
    1414//
    1515
     
    331331%token ATTRIBUTE EXTENSION                                                              // GCC
    332332%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR    // CFA
     333%token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL // CFA
    334334%token DISABLE ENABLE TRY THROW THROWRESUME AT                  // CFA
    335335%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
     
    16451645exception_statement:
    16461646        TRY compound_statement handler_clause                                   %prec THEN
    1647                 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
     1647                { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); }
    16481648        | TRY compound_statement finally_clause
    1649                 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
     1649                { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); }
    16501650        | TRY compound_statement handler_clause finally_clause
    16511651                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
     
    16991699asm_statement:
    17001700        ASM asm_volatile_opt '(' string_literal ')' ';'
    1701                 { $$ = new StatementNode( build_asm( $2, $4, 0 ) ); }
     1701                { $$ = new StatementNode( build_asm( $2, $4, nullptr ) ); }
    17021702        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC
    17031703                { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); }
     
    17071707                { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); }
    17081708        | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    1709                 { $$ = new StatementNode( build_asm( $2, $5, 0, $8, $10, $12 ) ); }
     1709                { $$ = new StatementNode( build_asm( $2, $5, nullptr, $8, $10, $12 ) ); }
    17101710        ;
    17111711
     
    18801880//      '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict
    18811881//              {
    1882 //                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
     1882//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, nullptr, true );
    18831883//              }
    18841884//      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18851885//              {
    18861886//                      typedefTable.setNextIdentifier( *$5 );
    1887 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1887//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );
    18881888//              }
    18891889//      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18901890//              {
    18911891//                      typedefTable.setNextIdentifier( *$5 );
    1892 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1892//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );
    18931893//              }
    18941894//      | '[' ']' typegen_name
     
    19021902        cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt
    19031903                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    1904                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); }
     1904                { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->addQualifiers( $8 ); }
    19051905        | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt
    1906                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); }
     1906                { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->addQualifiers( $8 ); }
    19071907        ;
    19081908
     
    19391939        TYPEDEF type_specifier declarator
    19401940                {
     1941                        // if type_specifier is an anon aggregate => name
    19411942                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    19421943                        $$ = $3->addType( $2 )->addTypedef();
     
    19951996declaration_specifier:                                                                  // type specifier + storage class
    19961997        basic_declaration_specifier
     1998        | type_declaration_specifier
    19971999        | sue_declaration_specifier
    1998         | type_declaration_specifier
     2000        | sue_declaration_specifier invalid_types
     2001                {
     2002                        SemanticError( yylloc,
     2003                                                  ::toString( "Missing ';' after end of ",
     2004                                                                          $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
     2005                                                                          " declaration" ) );
     2006                        $$ = nullptr;
     2007                }
     2008        ;
     2009
     2010invalid_types:
     2011        aggregate_key
     2012        | basic_type_name
     2013        | indirect_type
    19992014        ;
    20002015
     
    20652080                { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
    20662081        | forall
     2082                { $$ = DeclarationNode::newForall( $1 ); }
    20672083        ;
    20682084
    20692085forall:
    20702086        FORALL '(' type_parameter_list ')'                                      // CFA
    2071                 { $$ = DeclarationNode::newForall( $3 ); }
     2087                { $$ = $3; }
    20722088        ;
    20732089
     
    24732489        | EXTENSION type_specifier field_declaring_list_opt ';' // GCC
    24742490                { $$ = fieldDecl( $2, $3 ); distExt( $$ ); }
     2491        | STATIC type_specifier field_declaring_list_opt ';' // CFA
     2492                { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; }
    24752493        | INLINE type_specifier field_abstract_list_opt ';'     // CFA
    24762494                {
     
    25692587                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
    25702588                }
     2589        | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'
     2590                {
     2591                        $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );
     2592                }
    25712593        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    25722594                {
     
    25782600                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    25792601                }
     2602        | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt
     2603          hide_opt '{' enumerator_list comma_opt '}'
     2604                {
     2605                        $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
     2606                }
    25802607        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt
    25812608          hide_opt '{' enumerator_list comma_opt '}'
    25822609                {
    25832610                        $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 );
     2611                }
     2612        | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt
     2613          hide_opt '{' enumerator_list comma_opt '}'
     2614                {
     2615                        $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    25842616                }
    25852617        | enum_type_nobody
     
    25952627enum_type_nobody:                                                                               // enum - {...}
    25962628        ENUM attribute_list_opt identifier
    2597                 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }
     2629                { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); }
    25982630        | ENUM attribute_list_opt type_name
    2599                 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }
     2631                { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); }
    26002632        ;
    26012633
     
    26942726
    26952727cfa_abstract_parameter_declaration:                                             // CFA, new & old style parameter declaration
    2696         // empty
    2697                 { $$ = nullptr; }
    2698         | abstract_parameter_declaration
     2728        abstract_parameter_declaration
    26992729        | cfa_identifier_parameter_declarator_no_tuple
    27002730        | cfa_abstract_tuple
     
    29382968                {
    29392969                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    2940                         $$ = DeclarationNode::newTypeDecl( $1, 0 );
     2970                        $$ = DeclarationNode::newTypeDecl( $1, nullptr );
    29412971                }
    29422972        | identifier_or_type_name '(' type_parameter_list ')'
     
    29492979trait_specifier:                                                                                // CFA
    29502980        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    2951                 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); }
     2981                {
     2982                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
     2983                        $$ = DeclarationNode::newTrait( $2, $4, nullptr );
     2984                }
     2985        | forall TRAIT identifier_or_type_name '{' '}'          // alternate
     2986                { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); }
    29522987        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    2953                 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
     2988                {
     2989                        SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" );
     2990                        $$ = DeclarationNode::newTrait( $2, $4, $8 );
     2991                }
     2992        | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate
     2993                { $$ = DeclarationNode::newTrait( $3, $1, $6 ); }
    29542994        ;
    29552995
     
    30313071                }
    30323072        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    3033                 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
     3073                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); }
    30343074        | EXTERN STRINGliteral
    30353075                {
     
    32753315variable_ptr:
    32763316        ptrref_operator variable_declarator
    3277                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3317                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    32783318        | ptrref_operator type_qualifier_list variable_declarator
    32793319                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    33393379function_ptr:
    33403380        ptrref_operator function_declarator
    3341                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3381                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    33423382        | ptrref_operator type_qualifier_list function_declarator
    33433383                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    33913431KR_function_ptr:
    33923432        ptrref_operator KR_function_declarator
    3393                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3433                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    33943434        | ptrref_operator type_qualifier_list KR_function_declarator
    33953435                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    34473487type_ptr:
    34483488        ptrref_operator variable_type_redeclarator
    3449                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3489                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    34503490        | ptrref_operator type_qualifier_list variable_type_redeclarator
    34513491                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    35053545identifier_parameter_ptr:
    35063546        ptrref_operator identifier_parameter_declarator
    3507                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3547                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    35083548        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    35093549                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    35623602type_parameter_ptr:
    35633603        ptrref_operator type_parameter_redeclarator
    3564                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3604                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    35653605        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    35663606                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36053645abstract_ptr:
    36063646        ptrref_operator
    3607                 { $$ = DeclarationNode::newPointer( 0, $1 ); }
     3647                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    36083648        | ptrref_operator type_qualifier_list
    36093649                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    36103650        | ptrref_operator abstract_declarator
    3611                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3651                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    36123652        | ptrref_operator type_qualifier_list abstract_declarator
    36133653                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36383678                // Only the first dimension can be empty.
    36393679        '[' ']'
    3640                 { $$ = DeclarationNode::newArray( 0, 0, false ); }
     3680                { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
    36413681        | '[' ']' multi_array_dimension
    3642                 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
     3682                { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); }
    36433683                // Cannot use constant_expression because of tuples => semantic check
    36443684        | '[' push assignment_expression pop ',' comma_expression ']' // CFA
    3645                 { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }
     3685                { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); }
    36463686                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    36473687        | '[' push array_type_list pop ']'                                      // CFA
     
    36723712multi_array_dimension:
    36733713        '[' push assignment_expression pop ']'
    3674                 { $$ = DeclarationNode::newArray( $3, 0, false ); }
     3714                { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
    36753715        | '[' push '*' pop ']'                                                          // C99
    36763716                { $$ = DeclarationNode::newVarArray( 0 ); }
    36773717        | multi_array_dimension '[' push assignment_expression pop ']'
    3678                 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
     3718                { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }
    36793719        | multi_array_dimension '[' push '*' pop ']'            // C99
    36803720                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
     
    37733813array_parameter_1st_dimension:
    37743814        '[' ']'
    3775                 { $$ = DeclarationNode::newArray( 0, 0, false ); }
     3815                { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
    37763816                // multi_array_dimension handles the '[' '*' ']' case
    37773817        | '[' push type_qualifier_list '*' pop ']'                      // remaining C99
    37783818                { $$ = DeclarationNode::newVarArray( $3 ); }
    37793819        | '[' push type_qualifier_list pop ']'
    3780                 { $$ = DeclarationNode::newArray( 0, $3, false ); }
     3820                { $$ = DeclarationNode::newArray( nullptr, $3, false ); }
    37813821                // multi_array_dimension handles the '[' assignment_expression ']' case
    37823822        | '[' push type_qualifier_list assignment_expression pop ']'
     
    38073847variable_abstract_ptr:
    38083848        ptrref_operator
    3809                 { $$ = DeclarationNode::newPointer( 0, $1 ); }
     3849                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    38103850        | ptrref_operator type_qualifier_list
    38113851                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    38123852        | ptrref_operator variable_abstract_declarator
    3813                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3853                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38143854        | ptrref_operator type_qualifier_list variable_abstract_declarator
    38153855                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    38533893                // No SUE declaration in parameter list.
    38543894        ptrref_operator type_specifier_nobody
    3855                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3895                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38563896        | type_qualifier_list ptrref_operator type_specifier_nobody
    38573897                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    38583898        | ptrref_operator cfa_abstract_function
    3859                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3899                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38603900        | type_qualifier_list ptrref_operator cfa_abstract_function
    38613901                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    38623902        | ptrref_operator cfa_identifier_parameter_declarator_tuple
    3863                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3903                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38643904        | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple
    38653905                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
     
    38703910                // shift/reduce conflict with new-style empty (void) function return type.
    38713911        '[' ']' type_specifier_nobody
    3872                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3912                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38733913        | cfa_array_parameter_1st_dimension type_specifier_nobody
    38743914                { $$ = $2->addNewArray( $1 ); }
    38753915        | '[' ']' multi_array_dimension type_specifier_nobody
    3876                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3916                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38773917        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    38783918                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    38813921
    38823922        | '[' ']' cfa_identifier_parameter_ptr
    3883                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3923                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38843924        | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr
    38853925                { $$ = $2->addNewArray( $1 ); }
    38863926        | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr
    3887                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3927                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38883928        | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr
    38893929                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    39413981cfa_abstract_ptr:                                                                               // CFA
    39423982        ptrref_operator type_specifier
    3943                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3983                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39443984        | type_qualifier_list ptrref_operator type_specifier
    39453985                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39463986        | ptrref_operator cfa_abstract_function
    3947                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3987                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39483988        | type_qualifier_list ptrref_operator cfa_abstract_function
    39493989                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39503990        | ptrref_operator cfa_abstract_declarator_tuple
    3951                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3991                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39523992        | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple
    39533993                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note: See TracChangeset for help on using the changeset viewer.