Changeset ce691d2
- Timestamp:
- Jan 30, 2023, 9:36:09 PM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 7a24d76, 9d0ff30, 9ef5516
- Parents:
- d2b94f2 (diff), 8728104 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
rd2b94f2 rce691d2 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Fri Jan 20 12:08:37202313 * Update Count : 76 612 * Last Modified On : Mon Jan 30 19:03:34 2023 13 * Update Count : 767 14 14 */ 15 15 … … 503 503 SemanticErrorThrow = true; 504 504 cerr << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1 505 << ": " << ErrorHelpers::error_str() << errmsg << " attoken \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;505 << ": " << ErrorHelpers::error_str() << errmsg << " before token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl; 506 506 } 507 507 -
src/Parser/parser.yy
rd2b94f2 rce691d2 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 20 12:11:56202313 // Update Count : 585 512 // Last Modified On : Mon Jan 30 20:47:27 2023 13 // Update Count : 5859 14 14 // 15 15 … … 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 … … 1996 1996 declaration_specifier: // type specifier + storage class 1997 1997 basic_declaration_specifier 1998 | type_declaration_specifier 1998 1999 | sue_declaration_specifier 1999 | 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 2000 2014 ; 2001 2015 … … 2612 2626 enum_type_nobody: // enum - {...} 2613 2627 ENUM attribute_list_opt identifier 2614 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }2628 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); } 2615 2629 | ENUM attribute_list_opt type_name 2616 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }2630 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); } 2617 2631 ; 2618 2632 … … 2953 2967 { 2954 2968 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2955 $$ = DeclarationNode::newTypeDecl( $1, 0);2969 $$ = DeclarationNode::newTypeDecl( $1, nullptr ); 2956 2970 } 2957 2971 | identifier_or_type_name '(' type_parameter_list ')' … … 2964 2978 trait_specifier: // CFA 2965 2979 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2966 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2980 { $$ = DeclarationNode::newTrait( $2, $4, nullptr ); } 2981 | FORALL '(' type_parameter_list ')' TRAIT identifier_or_type_name '{' '}' // alternate 2982 { $$ = DeclarationNode::newTrait( $6, $3, nullptr ); } 2967 2983 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2968 2984 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2985 | FORALL '(' type_parameter_list ')' TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate 2986 { $$ = DeclarationNode::newTrait( $6, $3, $9 ); } 2969 2987 ; 2970 2988 … … 3046 3064 } 3047 3065 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 3048 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0) ) ); }3066 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); } 3049 3067 | EXTERN STRINGliteral 3050 3068 { … … 3290 3308 variable_ptr: 3291 3309 ptrref_operator variable_declarator 3292 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3310 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3293 3311 | ptrref_operator type_qualifier_list variable_declarator 3294 3312 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3354 3372 function_ptr: 3355 3373 ptrref_operator function_declarator 3356 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3374 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3357 3375 | ptrref_operator type_qualifier_list function_declarator 3358 3376 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3406 3424 KR_function_ptr: 3407 3425 ptrref_operator KR_function_declarator 3408 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3426 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3409 3427 | ptrref_operator type_qualifier_list KR_function_declarator 3410 3428 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3462 3480 type_ptr: 3463 3481 ptrref_operator variable_type_redeclarator 3464 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3482 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3465 3483 | ptrref_operator type_qualifier_list variable_type_redeclarator 3466 3484 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3520 3538 identifier_parameter_ptr: 3521 3539 ptrref_operator identifier_parameter_declarator 3522 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3540 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3523 3541 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3524 3542 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3577 3595 type_parameter_ptr: 3578 3596 ptrref_operator type_parameter_redeclarator 3579 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3597 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3580 3598 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3581 3599 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3620 3638 abstract_ptr: 3621 3639 ptrref_operator 3622 { $$ = DeclarationNode::newPointer( 0, $1 ); }3640 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3623 3641 | ptrref_operator type_qualifier_list 3624 3642 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3625 3643 | ptrref_operator abstract_declarator 3626 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3644 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3627 3645 | ptrref_operator type_qualifier_list abstract_declarator 3628 3646 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3653 3671 // Only the first dimension can be empty. 3654 3672 '[' ']' 3655 { $$ = DeclarationNode::newArray( 0, 0, false ); }3673 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3656 3674 | '[' ']' multi_array_dimension 3657 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }3675 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 3658 3676 // Cannot use constant_expression because of tuples => semantic check 3659 3677 | '[' push assignment_expression pop ',' comma_expression ']' // CFA 3660 { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }3678 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); } 3661 3679 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3662 3680 | '[' push array_type_list pop ']' // CFA … … 3687 3705 multi_array_dimension: 3688 3706 '[' push assignment_expression pop ']' 3689 { $$ = DeclarationNode::newArray( $3, 0, false ); }3707 { $$ = DeclarationNode::newArray( $3, nullptr, false ); } 3690 3708 | '[' push '*' pop ']' // C99 3691 3709 { $$ = DeclarationNode::newVarArray( 0 ); } 3692 3710 | multi_array_dimension '[' push assignment_expression pop ']' 3693 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }3711 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 3694 3712 | multi_array_dimension '[' push '*' pop ']' // C99 3695 3713 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } … … 3788 3806 array_parameter_1st_dimension: 3789 3807 '[' ']' 3790 { $$ = DeclarationNode::newArray( 0, 0, false ); }3808 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3791 3809 // multi_array_dimension handles the '[' '*' ']' case 3792 3810 | '[' push type_qualifier_list '*' pop ']' // remaining C99 3793 3811 { $$ = DeclarationNode::newVarArray( $3 ); } 3794 3812 | '[' push type_qualifier_list pop ']' 3795 { $$ = DeclarationNode::newArray( 0, $3, false ); }3813 { $$ = DeclarationNode::newArray( nullptr, $3, false ); } 3796 3814 // multi_array_dimension handles the '[' assignment_expression ']' case 3797 3815 | '[' push type_qualifier_list assignment_expression pop ']' … … 3822 3840 variable_abstract_ptr: 3823 3841 ptrref_operator 3824 { $$ = DeclarationNode::newPointer( 0, $1 ); }3842 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3825 3843 | ptrref_operator type_qualifier_list 3826 3844 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3827 3845 | ptrref_operator variable_abstract_declarator 3828 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3846 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3829 3847 | ptrref_operator type_qualifier_list variable_abstract_declarator 3830 3848 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3868 3886 // No SUE declaration in parameter list. 3869 3887 ptrref_operator type_specifier_nobody 3870 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3888 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3871 3889 | type_qualifier_list ptrref_operator type_specifier_nobody 3872 3890 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3873 3891 | ptrref_operator cfa_abstract_function 3874 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3892 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3875 3893 | type_qualifier_list ptrref_operator cfa_abstract_function 3876 3894 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3877 3895 | ptrref_operator cfa_identifier_parameter_declarator_tuple 3878 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3896 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3879 3897 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 3880 3898 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 3885 3903 // shift/reduce conflict with new-style empty (void) function return type. 3886 3904 '[' ']' type_specifier_nobody 3887 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3905 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3888 3906 | cfa_array_parameter_1st_dimension type_specifier_nobody 3889 3907 { $$ = $2->addNewArray( $1 ); } 3890 3908 | '[' ']' multi_array_dimension type_specifier_nobody 3891 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3909 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3892 3910 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 3893 3911 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3896 3914 3897 3915 | '[' ']' cfa_identifier_parameter_ptr 3898 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3916 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3899 3917 | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr 3900 3918 { $$ = $2->addNewArray( $1 ); } 3901 3919 | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr 3902 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3920 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3903 3921 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr 3904 3922 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3956 3974 cfa_abstract_ptr: // CFA 3957 3975 ptrref_operator type_specifier 3958 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3976 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3959 3977 | type_qualifier_list ptrref_operator type_specifier 3960 3978 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3961 3979 | ptrref_operator cfa_abstract_function 3962 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3980 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3963 3981 | type_qualifier_list ptrref_operator cfa_abstract_function 3964 3982 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3965 3983 | ptrref_operator cfa_abstract_declarator_tuple 3966 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3984 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3967 3985 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 3968 3986 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note: See TracChangeset
for help on using the changeset viewer.