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