Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r8a97248 r997185e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  2 21:36:16 2023
    13 // Update Count     : 5865
     12// Last Modified On : Mon Nov 21 22:34:30 2022
     13// Update Count     : 5848
    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 WAITUNTIL // CFA
     333%token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR    // 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, nullptr ) ); }
     1647                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    16481648        | TRY compound_statement finally_clause
    1649                 { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); }
     1649                { $$ = new StatementNode( build_try( $2, 0, $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, nullptr ) ); }
     1701                { $$ = new StatementNode( build_asm( $2, $4, 0 ) ); }
    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, nullptr, $8, $10, $12 ) ); }
     1709                { $$ = new StatementNode( build_asm( $2, $5, 0, $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, nullptr, true );
     1882//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    18831883//              }
    18841884//      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18851885//              {
    18861886//                      typedefTable.setNextIdentifier( *$5 );
    1887 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );
     1887//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
    18881888//              }
    18891889//      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18901890//              {
    18911891//                      typedefTable.setNextIdentifier( *$5 );
    1892 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );
     1892//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, 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, nullptr )->addQualifiers( $8 ); }
     1904                { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->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, nullptr )->addQualifiers( $8 ); }
     1906                { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); }
    19071907        ;
    19081908
     
    19391939        TYPEDEF type_specifier declarator
    19401940                {
    1941                         // if type_specifier is an anon aggregate => name
    19421941                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    19431942                        $$ = $3->addType( $2 )->addTypedef();
     
    19961995declaration_specifier:                                                                  // type specifier + storage class
    19971996        basic_declaration_specifier
     1997        | sue_declaration_specifier
    19981998        | type_declaration_specifier
    1999         | sue_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 
    2010 invalid_types:
    2011         aggregate_key
    2012         | basic_type_name
    2013         | indirect_type
    20141999        ;
    20152000
     
    20802065                { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
    20812066        | forall
    2082                 { $$ = DeclarationNode::newForall( $1 ); }
    20832067        ;
    20842068
    20852069forall:
    20862070        FORALL '(' type_parameter_list ')'                                      // CFA
    2087                 { $$ = $3; }
     2071                { $$ = DeclarationNode::newForall( $3 ); }
    20882072        ;
    20892073
     
    24892473        | EXTENSION type_specifier field_declaring_list_opt ';' // GCC
    24902474                { $$ = fieldDecl( $2, $3 ); distExt( $$ ); }
    2491         | STATIC type_specifier field_declaring_list_opt ';' // CFA
    2492                 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; }
    24932475        | INLINE type_specifier field_abstract_list_opt ';'     // CFA
    24942476                {
     
    25872569                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
    25882570                }
    2589         | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2590                 {
    2591                         $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );
    2592                 }
    25932571        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    25942572                {
     
    26002578                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    26012579                }
    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                 }
    26072580        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt
    26082581          hide_opt '{' enumerator_list comma_opt '}'
    26092582                {
    26102583                        $$ = 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 );
    26162584                }
    26172585        | enum_type_nobody
     
    26272595enum_type_nobody:                                                                               // enum - {...}
    26282596        ENUM attribute_list_opt identifier
    2629                 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); }
     2597                { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }
    26302598        | ENUM attribute_list_opt type_name
    2631                 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); }
     2599                { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }
    26322600        ;
    26332601
     
    27262694
    27272695cfa_abstract_parameter_declaration:                                             // CFA, new & old style parameter declaration
    2728         abstract_parameter_declaration
     2696        // empty
     2697                { $$ = nullptr; }
     2698        | abstract_parameter_declaration
    27292699        | cfa_identifier_parameter_declarator_no_tuple
    27302700        | cfa_abstract_tuple
     
    29682938                {
    29692939                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    2970                         $$ = DeclarationNode::newTypeDecl( $1, nullptr );
     2940                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    29712941                }
    29722942        | identifier_or_type_name '(' type_parameter_list ')'
     
    29792949trait_specifier:                                                                                // CFA
    29802950        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    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 ); }
     2951                { $$ = DeclarationNode::newTrait( $2, $4, 0 ); }
    29872952        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    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 ); }
     2953                { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
    29942954        ;
    29952955
     
    30713031                }
    30723032        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    3073                 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); }
     3033                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
    30743034        | EXTERN STRINGliteral
    30753035                {
     
    33153275variable_ptr:
    33163276        ptrref_operator variable_declarator
    3317                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3277                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    33183278        | ptrref_operator type_qualifier_list variable_declarator
    33193279                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    33793339function_ptr:
    33803340        ptrref_operator function_declarator
    3381                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3341                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    33823342        | ptrref_operator type_qualifier_list function_declarator
    33833343                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    34313391KR_function_ptr:
    34323392        ptrref_operator KR_function_declarator
    3433                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3393                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    34343394        | ptrref_operator type_qualifier_list KR_function_declarator
    34353395                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    34873447type_ptr:
    34883448        ptrref_operator variable_type_redeclarator
    3489                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3449                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    34903450        | ptrref_operator type_qualifier_list variable_type_redeclarator
    34913451                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    35453505identifier_parameter_ptr:
    35463506        ptrref_operator identifier_parameter_declarator
    3547                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3507                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    35483508        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    35493509                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36023562type_parameter_ptr:
    36033563        ptrref_operator type_parameter_redeclarator
    3604                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3564                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    36053565        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    36063566                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36453605abstract_ptr:
    36463606        ptrref_operator
    3647                 { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
     3607                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    36483608        | ptrref_operator type_qualifier_list
    36493609                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    36503610        | ptrref_operator abstract_declarator
    3651                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3611                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    36523612        | ptrref_operator type_qualifier_list abstract_declarator
    36533613                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36783638                // Only the first dimension can be empty.
    36793639        '[' ']'
    3680                 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
     3640                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    36813641        | '[' ']' multi_array_dimension
    3682                 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); }
     3642                { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
    36833643                // Cannot use constant_expression because of tuples => semantic check
    36843644        | '[' push assignment_expression pop ',' comma_expression ']' // CFA
    3685                 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); }
     3645                { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }
    36863646                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    36873647        | '[' push array_type_list pop ']'                                      // CFA
     
    37123672multi_array_dimension:
    37133673        '[' push assignment_expression pop ']'
    3714                 { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
     3674                { $$ = DeclarationNode::newArray( $3, 0, false ); }
    37153675        | '[' push '*' pop ']'                                                          // C99
    37163676                { $$ = DeclarationNode::newVarArray( 0 ); }
    37173677        | multi_array_dimension '[' push assignment_expression pop ']'
    3718                 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }
     3678                { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
    37193679        | multi_array_dimension '[' push '*' pop ']'            // C99
    37203680                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
     
    38133773array_parameter_1st_dimension:
    38143774        '[' ']'
    3815                 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
     3775                { $$ = DeclarationNode::newArray( 0, 0, false ); }
    38163776                // multi_array_dimension handles the '[' '*' ']' case
    38173777        | '[' push type_qualifier_list '*' pop ']'                      // remaining C99
    38183778                { $$ = DeclarationNode::newVarArray( $3 ); }
    38193779        | '[' push type_qualifier_list pop ']'
    3820                 { $$ = DeclarationNode::newArray( nullptr, $3, false ); }
     3780                { $$ = DeclarationNode::newArray( 0, $3, false ); }
    38213781                // multi_array_dimension handles the '[' assignment_expression ']' case
    38223782        | '[' push type_qualifier_list assignment_expression pop ']'
     
    38473807variable_abstract_ptr:
    38483808        ptrref_operator
    3849                 { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
     3809                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    38503810        | ptrref_operator type_qualifier_list
    38513811                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    38523812        | ptrref_operator variable_abstract_declarator
    3853                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3813                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    38543814        | ptrref_operator type_qualifier_list variable_abstract_declarator
    38553815                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    38933853                // No SUE declaration in parameter list.
    38943854        ptrref_operator type_specifier_nobody
    3895                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3855                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    38963856        | type_qualifier_list ptrref_operator type_specifier_nobody
    38973857                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    38983858        | ptrref_operator cfa_abstract_function
    3899                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3859                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    39003860        | type_qualifier_list ptrref_operator cfa_abstract_function
    39013861                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39023862        | ptrref_operator cfa_identifier_parameter_declarator_tuple
    3903                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3863                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    39043864        | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple
    39053865                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
     
    39103870                // shift/reduce conflict with new-style empty (void) function return type.
    39113871        '[' ']' type_specifier_nobody
    3912                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     3872                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    39133873        | cfa_array_parameter_1st_dimension type_specifier_nobody
    39143874                { $$ = $2->addNewArray( $1 ); }
    39153875        | '[' ']' multi_array_dimension type_specifier_nobody
    3916                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     3876                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    39173877        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    39183878                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    39213881
    39223882        | '[' ']' cfa_identifier_parameter_ptr
    3923                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     3883                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    39243884        | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr
    39253885                { $$ = $2->addNewArray( $1 ); }
    39263886        | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr
    3927                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     3887                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    39283888        | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr
    39293889                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    39813941cfa_abstract_ptr:                                                                               // CFA
    39823942        ptrref_operator type_specifier
    3983                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3943                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    39843944        | type_qualifier_list ptrref_operator type_specifier
    39853945                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39863946        | ptrref_operator cfa_abstract_function
    3987                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3947                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    39883948        | type_qualifier_list ptrref_operator cfa_abstract_function
    39893949                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39903950        | ptrref_operator cfa_abstract_declarator_tuple
    3991                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3951                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    39923952        | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple
    39933953                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note: See TracChangeset for help on using the changeset viewer.