Changeset 2ed94a9 for src/Parser
- Timestamp:
- Feb 8, 2023, 2:27:55 PM (22 months ago)
- Branches:
- ADT, master
- Children:
- b110bcc
- Parents:
- 997185e (diff), ccb29b4 (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
r997185e r2ed94a9 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Oct 13 20:46:04 202213 * Update Count : 76 412 * Last Modified On : Mon Jan 30 19:03:34 2023 13 * Update Count : 767 14 14 */ 15 15 … … 340 340 vtable { KEYWORD_RETURN(VTABLE); } // CFA 341 341 waitfor { KEYWORD_RETURN(WAITFOR); } // CFA 342 waituntil { KEYWORD_RETURN(WAITUNTIL); } // CFA 342 343 when { KEYWORD_RETURN(WHEN); } // CFA 343 344 while { KEYWORD_RETURN(WHILE); } … … 502 503 SemanticErrorThrow = true; 503 504 cerr << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1 504 << ": " << ErrorHelpers::error_str() << errmsg << " attoken \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;505 << ": " << ErrorHelpers::error_str() << errmsg << " before token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl; 505 506 } 506 507 -
src/Parser/parser.yy
r997185e r2ed94a9 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 333 %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 { … … 2595 2613 enum_type_nobody: // enum - {...} 2596 2614 ENUM attribute_list_opt identifier 2597 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); }2615 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); } 2598 2616 | ENUM attribute_list_opt type_name 2599 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); }2617 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); } 2600 2618 ; 2601 2619 … … 2938 2956 { 2939 2957 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2940 $$ = DeclarationNode::newTypeDecl( $1, 0);2958 $$ = DeclarationNode::newTypeDecl( $1, nullptr ); 2941 2959 } 2942 2960 | identifier_or_type_name '(' type_parameter_list ')' … … 2949 2967 trait_specifier: // CFA 2950 2968 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2951 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2969 { 2970 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2971 $$ = DeclarationNode::newTrait( $2, $4, nullptr ); 2972 } 2973 | forall TRAIT identifier_or_type_name '{' '}' // alternate 2974 { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); } 2952 2975 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2953 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2976 { 2977 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2978 $$ = DeclarationNode::newTrait( $2, $4, $8 ); 2979 } 2980 | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate 2981 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); } 2954 2982 ; 2955 2983 … … 3031 3059 } 3032 3060 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 3033 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0) ) ); }3061 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); } 3034 3062 | EXTERN STRINGliteral 3035 3063 { … … 3275 3303 variable_ptr: 3276 3304 ptrref_operator variable_declarator 3277 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3305 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3278 3306 | ptrref_operator type_qualifier_list variable_declarator 3279 3307 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3339 3367 function_ptr: 3340 3368 ptrref_operator function_declarator 3341 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3369 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3342 3370 | ptrref_operator type_qualifier_list function_declarator 3343 3371 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3391 3419 KR_function_ptr: 3392 3420 ptrref_operator KR_function_declarator 3393 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3421 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3394 3422 | ptrref_operator type_qualifier_list KR_function_declarator 3395 3423 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3447 3475 type_ptr: 3448 3476 ptrref_operator variable_type_redeclarator 3449 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3477 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3450 3478 | ptrref_operator type_qualifier_list variable_type_redeclarator 3451 3479 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3505 3533 identifier_parameter_ptr: 3506 3534 ptrref_operator identifier_parameter_declarator 3507 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3535 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3508 3536 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3509 3537 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3562 3590 type_parameter_ptr: 3563 3591 ptrref_operator type_parameter_redeclarator 3564 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3592 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3565 3593 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3566 3594 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3605 3633 abstract_ptr: 3606 3634 ptrref_operator 3607 { $$ = DeclarationNode::newPointer( 0, $1 ); }3635 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3608 3636 | ptrref_operator type_qualifier_list 3609 3637 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3610 3638 | ptrref_operator abstract_declarator 3611 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3639 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3612 3640 | ptrref_operator type_qualifier_list abstract_declarator 3613 3641 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3638 3666 // Only the first dimension can be empty. 3639 3667 '[' ']' 3640 { $$ = DeclarationNode::newArray( 0, 0, false ); }3668 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3641 3669 | '[' ']' multi_array_dimension 3642 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }3670 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 3643 3671 // Cannot use constant_expression because of tuples => semantic check 3644 3672 | '[' push assignment_expression pop ',' comma_expression ']' // CFA 3645 { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }3673 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); } 3646 3674 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3647 3675 | '[' push array_type_list pop ']' // CFA … … 3672 3700 multi_array_dimension: 3673 3701 '[' push assignment_expression pop ']' 3674 { $$ = DeclarationNode::newArray( $3, 0, false ); }3702 { $$ = DeclarationNode::newArray( $3, nullptr, false ); } 3675 3703 | '[' push '*' pop ']' // C99 3676 3704 { $$ = DeclarationNode::newVarArray( 0 ); } 3677 3705 | multi_array_dimension '[' push assignment_expression pop ']' 3678 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }3706 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 3679 3707 | multi_array_dimension '[' push '*' pop ']' // C99 3680 3708 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } … … 3773 3801 array_parameter_1st_dimension: 3774 3802 '[' ']' 3775 { $$ = DeclarationNode::newArray( 0, 0, false ); }3803 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); } 3776 3804 // multi_array_dimension handles the '[' '*' ']' case 3777 3805 | '[' push type_qualifier_list '*' pop ']' // remaining C99 3778 3806 { $$ = DeclarationNode::newVarArray( $3 ); } 3779 3807 | '[' push type_qualifier_list pop ']' 3780 { $$ = DeclarationNode::newArray( 0, $3, false ); }3808 { $$ = DeclarationNode::newArray( nullptr, $3, false ); } 3781 3809 // multi_array_dimension handles the '[' assignment_expression ']' case 3782 3810 | '[' push type_qualifier_list assignment_expression pop ']' … … 3807 3835 variable_abstract_ptr: 3808 3836 ptrref_operator 3809 { $$ = DeclarationNode::newPointer( 0, $1 ); }3837 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 3810 3838 | ptrref_operator type_qualifier_list 3811 3839 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3812 3840 | ptrref_operator variable_abstract_declarator 3813 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }3841 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3814 3842 | ptrref_operator type_qualifier_list variable_abstract_declarator 3815 3843 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3853 3881 // No SUE declaration in parameter list. 3854 3882 ptrref_operator type_specifier_nobody 3855 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3883 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3856 3884 | type_qualifier_list ptrref_operator type_specifier_nobody 3857 3885 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3858 3886 | ptrref_operator cfa_abstract_function 3859 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3887 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3860 3888 | type_qualifier_list ptrref_operator cfa_abstract_function 3861 3889 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3862 3890 | ptrref_operator cfa_identifier_parameter_declarator_tuple 3863 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3891 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3864 3892 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 3865 3893 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 3870 3898 // shift/reduce conflict with new-style empty (void) function return type. 3871 3899 '[' ']' type_specifier_nobody 3872 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3900 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3873 3901 | cfa_array_parameter_1st_dimension type_specifier_nobody 3874 3902 { $$ = $2->addNewArray( $1 ); } 3875 3903 | '[' ']' multi_array_dimension type_specifier_nobody 3876 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3904 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3877 3905 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 3878 3906 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3881 3909 3882 3910 | '[' ']' cfa_identifier_parameter_ptr 3883 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3911 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3884 3912 | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr 3885 3913 { $$ = $2->addNewArray( $1 ); } 3886 3914 | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr 3887 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }3915 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 3888 3916 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr 3889 3917 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3941 3969 cfa_abstract_ptr: // CFA 3942 3970 ptrref_operator type_specifier 3943 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3971 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3944 3972 | type_qualifier_list ptrref_operator type_specifier 3945 3973 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3946 3974 | ptrref_operator cfa_abstract_function 3947 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3975 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3948 3976 | type_qualifier_list ptrref_operator cfa_abstract_function 3949 3977 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3950 3978 | ptrref_operator cfa_abstract_declarator_tuple 3951 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }3979 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 3952 3980 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 3953 3981 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note: See TracChangeset
for help on using the changeset viewer.