Changes in src/Parser/parser.yy [997185e:8a97248]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r997185e r8a97248 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 21 22:34:30 202213 // Update Count : 58 4812 // Last Modified On : Thu Feb 2 21:36:16 2023 13 // Update Count : 5865 14 14 // 15 15 … … 331 331 %token ATTRIBUTE EXTENSION // GCC 332 332 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR // CFA333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL // CFA 334 334 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 335 335 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) … … 1645 1645 exception_statement: 1646 1646 TRY compound_statement handler_clause %prec THEN 1647 { $$ = new StatementNode( build_try( $2, $3, 0) ); }1647 { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); } 1648 1648 | TRY compound_statement finally_clause 1649 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }1649 { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); } 1650 1650 | TRY compound_statement handler_clause finally_clause 1651 1651 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } … … 1699 1699 asm_statement: 1700 1700 ASM asm_volatile_opt '(' string_literal ')' ';' 1701 { $$ = new StatementNode( build_asm( $2, $4, 0) ); }1701 { $$ = new StatementNode( build_asm( $2, $4, nullptr ) ); } 1702 1702 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC 1703 1703 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); } … … 1707 1707 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); } 1708 1708 | 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 ) ); } 1710 1710 ; 1711 1711 … … 1880 1880 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict 1881 1881 // { 1882 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );1882 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, nullptr, true ); 1883 1883 // } 1884 1884 // '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')' 1885 1885 // { 1886 1886 // typedefTable.setNextIdentifier( *$5 ); 1887 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );1887 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true ); 1888 1888 // } 1889 1889 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')' 1890 1890 // { 1891 1891 // typedefTable.setNextIdentifier( *$5 ); 1892 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );1892 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true ); 1893 1893 // } 1894 1894 // | '[' ']' typegen_name … … 1902 1902 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt 1903 1903 // 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 ); } 1905 1905 | 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 ); } 1907 1907 ; 1908 1908 … … 1939 1939 TYPEDEF type_specifier declarator 1940 1940 { 1941 // if type_specifier is an anon aggregate => name 1941 1942 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 1942 1943 $$ = $3->addType( $2 )->addTypedef(); … … 1995 1996 declaration_specifier: // type specifier + storage class 1996 1997 basic_declaration_specifier 1998 | type_declaration_specifier 1997 1999 | 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 2010 invalid_types: 2011 aggregate_key 2012 | basic_type_name 2013 | indirect_type 1999 2014 ; 2000 2015 … … 2065 2080 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } 2066 2081 | forall 2082 { $$ = DeclarationNode::newForall( $1 ); } 2067 2083 ; 2068 2084 2069 2085 forall: 2070 2086 FORALL '(' type_parameter_list ')' // CFA 2071 { $$ = DeclarationNode::newForall( $3 ); }2087 { $$ = $3; } 2072 2088 ; 2073 2089 … … 2473 2489 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 2474 2490 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } 2491 | STATIC type_specifier field_declaring_list_opt ';' // CFA 2492 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; } 2475 2493 | INLINE type_specifier field_abstract_list_opt ';' // CFA 2476 2494 { … … 2569 2587 $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 ); 2570 2588 } 2589 | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2590 { 2591 $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 ); 2592 } 2571 2593 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2572 2594 { … … 2578 2600 $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 ); 2579 2601 } 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 } 2580 2607 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt 2581 2608 hide_opt '{' enumerator_list comma_opt '}' 2582 2609 { 2583 2610 $$ = 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 ); 2584 2616 } 2585 2617 | enum_type_nobody … … 2595 2627 enum_type_nobody: // enum - {...} 2596 2628 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 ); } 2598 2630 | 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 ); } 2600 2632 ; 2601 2633 … … 2694 2726 2695 2727 cfa_abstract_parameter_declaration: // CFA, new & old style parameter declaration 2696 // empty 2697 { $$ = nullptr; } 2698 | abstract_parameter_declaration 2728 abstract_parameter_declaration 2699 2729 | cfa_identifier_parameter_declarator_no_tuple 2700 2730 | cfa_abstract_tuple … … 2938 2968 { 2939 2969 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2940 $$ = DeclarationNode::newTypeDecl( $1, 0);2970 $$ = DeclarationNode::newTypeDecl( $1, nullptr ); 2941 2971 } 2942 2972 | identifier_or_type_name '(' type_parameter_list ')' … … 2949 2979 trait_specifier: // CFA 2950 2980 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 ); } 2952 2987 | 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 ); } 2954 2994 ; 2955 2995 … … 3031 3071 } 3032 3072 | 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 ) ) ); } 3034 3074 | EXTERN STRINGliteral 3035 3075 { … … 3275 3315 variable_ptr: 3276 3316 ptrref_operator variable_declarator 3277 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3317 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3278 3318 | ptrref_operator type_qualifier_list variable_declarator 3279 3319 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3339 3379 function_ptr: 3340 3380 ptrref_operator function_declarator 3341 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3381 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3342 3382 | ptrref_operator type_qualifier_list function_declarator 3343 3383 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3391 3431 KR_function_ptr: 3392 3432 ptrref_operator KR_function_declarator 3393 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3433 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3394 3434 | ptrref_operator type_qualifier_list KR_function_declarator 3395 3435 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3447 3487 type_ptr: 3448 3488 ptrref_operator variable_type_redeclarator 3449 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3489 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3450 3490 | ptrref_operator type_qualifier_list variable_type_redeclarator 3451 3491 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3505 3545 identifier_parameter_ptr: 3506 3546 ptrref_operator identifier_parameter_declarator 3507 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3547 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3508 3548 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3509 3549 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3562 3602 type_parameter_ptr: 3563 3603 ptrref_operator type_parameter_redeclarator 3564 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3604 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3565 3605 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3566 3606 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3605 3645 abstract_ptr: 3606 3646 ptrref_operator 3607 { $$ = DeclarationNode::newPointer( 0, $1 ); }3647 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3608 3648 | ptrref_operator type_qualifier_list 3609 3649 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3610 3650 | ptrref_operator abstract_declarator 3611 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3651 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3612 3652 | ptrref_operator type_qualifier_list abstract_declarator 3613 3653 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3638 3678 // Only the first dimension can be empty. 3639 3679 '[' ']' 3640 { $$ = DeclarationNode::newArray( 0, 0, false ); }3680 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3641 3681 | '[' ']' multi_array_dimension 3642 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }3682 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 3643 3683 // Cannot use constant_expression because of tuples => semantic check 3644 3684 | '[' 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 ) ); } 3646 3686 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3647 3687 | '[' push array_type_list pop ']' // CFA … … 3672 3712 multi_array_dimension: 3673 3713 '[' push assignment_expression pop ']' 3674 { $$ = DeclarationNode::newArray( $3, 0, false ); }3714 { $$ = DeclarationNode::newArray( $3, nullptr, false ); } 3675 3715 | '[' push '*' pop ']' // C99 3676 3716 { $$ = DeclarationNode::newVarArray( 0 ); } 3677 3717 | multi_array_dimension '[' push assignment_expression pop ']' 3678 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }3718 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 3679 3719 | multi_array_dimension '[' push '*' pop ']' // C99 3680 3720 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } … … 3773 3813 array_parameter_1st_dimension: 3774 3814 '[' ']' 3775 { $$ = DeclarationNode::newArray( 0, 0, false ); }3815 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3776 3816 // multi_array_dimension handles the '[' '*' ']' case 3777 3817 | '[' push type_qualifier_list '*' pop ']' // remaining C99 3778 3818 { $$ = DeclarationNode::newVarArray( $3 ); } 3779 3819 | '[' push type_qualifier_list pop ']' 3780 { $$ = DeclarationNode::newArray( 0, $3, false ); }3820 { $$ = DeclarationNode::newArray( nullptr, $3, false ); } 3781 3821 // multi_array_dimension handles the '[' assignment_expression ']' case 3782 3822 | '[' push type_qualifier_list assignment_expression pop ']' … … 3807 3847 variable_abstract_ptr: 3808 3848 ptrref_operator 3809 { $$ = DeclarationNode::newPointer( 0, $1 ); }3849 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3810 3850 | ptrref_operator type_qualifier_list 3811 3851 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3812 3852 | ptrref_operator variable_abstract_declarator 3813 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3853 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3814 3854 | ptrref_operator type_qualifier_list variable_abstract_declarator 3815 3855 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3853 3893 // No SUE declaration in parameter list. 3854 3894 ptrref_operator type_specifier_nobody 3855 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3895 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3856 3896 | type_qualifier_list ptrref_operator type_specifier_nobody 3857 3897 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3858 3898 | ptrref_operator cfa_abstract_function 3859 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3899 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3860 3900 | type_qualifier_list ptrref_operator cfa_abstract_function 3861 3901 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3862 3902 | ptrref_operator cfa_identifier_parameter_declarator_tuple 3863 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3903 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3864 3904 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 3865 3905 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 3870 3910 // shift/reduce conflict with new-style empty (void) function return type. 3871 3911 '[' ']' type_specifier_nobody 3872 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3912 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3873 3913 | cfa_array_parameter_1st_dimension type_specifier_nobody 3874 3914 { $$ = $2->addNewArray( $1 ); } 3875 3915 | '[' ']' 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 ) ); } 3877 3917 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 3878 3918 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3881 3921 3882 3922 | '[' ']' cfa_identifier_parameter_ptr 3883 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3923 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3884 3924 | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr 3885 3925 { $$ = $2->addNewArray( $1 ); } 3886 3926 | '[' ']' 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 ) ); } 3888 3928 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr 3889 3929 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3941 3981 cfa_abstract_ptr: // CFA 3942 3982 ptrref_operator type_specifier 3943 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3983 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3944 3984 | type_qualifier_list ptrref_operator type_specifier 3945 3985 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3946 3986 | ptrref_operator cfa_abstract_function 3947 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3987 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3948 3988 | type_qualifier_list ptrref_operator cfa_abstract_function 3949 3989 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3950 3990 | ptrref_operator cfa_abstract_declarator_tuple 3951 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3991 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3952 3992 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 3953 3993 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note:
See TracChangeset
for help on using the changeset viewer.