Changeset ce691d2


Ignore:
Timestamp:
Jan 30, 2023, 9:36:09 PM (22 months ago)
Author:
caparsons <caparson@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    rd2b94f2 rce691d2  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Fri Jan 20 12:08:37 2023
    13  * Update Count     : 766
     12 * Last Modified On : Mon Jan 30 19:03:34 2023
     13 * Update Count     : 767
    1414 */
    1515
     
    503503        SemanticErrorThrow = true;
    504504        cerr << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1
    505                  << ": " << ErrorHelpers::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
     505                 << ": " << ErrorHelpers::error_str() << errmsg << " before token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
    506506}
    507507
  • src/Parser/parser.yy

    rd2b94f2 rce691d2  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 20 12:11:56 2023
    13 // Update Count     : 5855
     12// Last Modified On : Mon Jan 30 20:47:27 2023
     13// Update Count     : 5859
    1414//
    1515
     
    16451645exception_statement:
    16461646        TRY compound_statement handler_clause                                   %prec THEN
    1647                 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
     1647                { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); }
    16481648        | TRY compound_statement finally_clause
    1649                 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
     1649                { $$ = new StatementNode( build_try( $2, nullptr, $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, 0 ) ); }
     1701                { $$ = new StatementNode( build_asm( $2, $4, nullptr ) ); }
    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, 0, $8, $10, $12 ) ); }
     1709                { $$ = new StatementNode( build_asm( $2, $5, nullptr, $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, 0, true );
     1882//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, nullptr, true );
    18831883//              }
    18841884//      '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18851885//              {
    18861886//                      typedefTable.setNextIdentifier( *$5 );
    1887 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1887//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );
    18881888//              }
    18891889//      | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')'
    18901890//              {
    18911891//                      typedefTable.setNextIdentifier( *$5 );
    1892 //                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true );
     1892//                      $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, 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, 0 )->addQualifiers( $8 ); }
     1904                { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->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, 0 )->addQualifiers( $8 ); }
     1906                { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr )->addQualifiers( $8 ); }
    19071907        ;
    19081908
     
    19961996declaration_specifier:                                                                  // type specifier + storage class
    19971997        basic_declaration_specifier
     1998        | type_declaration_specifier
    19981999        | 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
     2010invalid_types:
     2011        aggregate_key
     2012        | basic_type_name
     2013        | indirect_type
    20002014        ;
    20012015
     
    26122626enum_type_nobody:                                                                               // enum - {...}
    26132627        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 ); }
    26152629        | 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 ); }
    26172631        ;
    26182632
     
    29532967                {
    29542968                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    2955                         $$ = DeclarationNode::newTypeDecl( $1, 0 );
     2969                        $$ = DeclarationNode::newTypeDecl( $1, nullptr );
    29562970                }
    29572971        | identifier_or_type_name '(' type_parameter_list ')'
     
    29642978trait_specifier:                                                                                // CFA
    29652979        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 ); }
    29672983        | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'
    29682984                { $$ = 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 ); }
    29692987        ;
    29702988
     
    30463064                }
    30473065        | 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 ) ) ); }
    30493067        | EXTERN STRINGliteral
    30503068                {
     
    32903308variable_ptr:
    32913309        ptrref_operator variable_declarator
    3292                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3310                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    32933311        | ptrref_operator type_qualifier_list variable_declarator
    32943312                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    33543372function_ptr:
    33553373        ptrref_operator function_declarator
    3356                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3374                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    33573375        | ptrref_operator type_qualifier_list function_declarator
    33583376                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    34063424KR_function_ptr:
    34073425        ptrref_operator KR_function_declarator
    3408                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3426                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    34093427        | ptrref_operator type_qualifier_list KR_function_declarator
    34103428                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    34623480type_ptr:
    34633481        ptrref_operator variable_type_redeclarator
    3464                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3482                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    34653483        | ptrref_operator type_qualifier_list variable_type_redeclarator
    34663484                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    35203538identifier_parameter_ptr:
    35213539        ptrref_operator identifier_parameter_declarator
    3522                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3540                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    35233541        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    35243542                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    35773595type_parameter_ptr:
    35783596        ptrref_operator type_parameter_redeclarator
    3579                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3597                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    35803598        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    35813599                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36203638abstract_ptr:
    36213639        ptrref_operator
    3622                 { $$ = DeclarationNode::newPointer( 0, $1 ); }
     3640                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    36233641        | ptrref_operator type_qualifier_list
    36243642                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    36253643        | ptrref_operator abstract_declarator
    3626                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3644                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    36273645        | ptrref_operator type_qualifier_list abstract_declarator
    36283646                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    36533671                // Only the first dimension can be empty.
    36543672        '[' ']'
    3655                 { $$ = DeclarationNode::newArray( 0, 0, false ); }
     3673                { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
    36563674        | '[' ']' multi_array_dimension
    3657                 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
     3675                { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); }
    36583676                // Cannot use constant_expression because of tuples => semantic check
    36593677        | '[' 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 ) ); }
    36613679                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    36623680        | '[' push array_type_list pop ']'                                      // CFA
     
    36873705multi_array_dimension:
    36883706        '[' push assignment_expression pop ']'
    3689                 { $$ = DeclarationNode::newArray( $3, 0, false ); }
     3707                { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
    36903708        | '[' push '*' pop ']'                                                          // C99
    36913709                { $$ = DeclarationNode::newVarArray( 0 ); }
    36923710        | multi_array_dimension '[' push assignment_expression pop ']'
    3693                 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); }
     3711                { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }
    36943712        | multi_array_dimension '[' push '*' pop ']'            // C99
    36953713                { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); }
     
    37883806array_parameter_1st_dimension:
    37893807        '[' ']'
    3790                 { $$ = DeclarationNode::newArray( 0, 0, false ); }
     3808                { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }
    37913809                // multi_array_dimension handles the '[' '*' ']' case
    37923810        | '[' push type_qualifier_list '*' pop ']'                      // remaining C99
    37933811                { $$ = DeclarationNode::newVarArray( $3 ); }
    37943812        | '[' push type_qualifier_list pop ']'
    3795                 { $$ = DeclarationNode::newArray( 0, $3, false ); }
     3813                { $$ = DeclarationNode::newArray( nullptr, $3, false ); }
    37963814                // multi_array_dimension handles the '[' assignment_expression ']' case
    37973815        | '[' push type_qualifier_list assignment_expression pop ']'
     
    38223840variable_abstract_ptr:
    38233841        ptrref_operator
    3824                 { $$ = DeclarationNode::newPointer( 0, $1 ); }
     3842                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    38253843        | ptrref_operator type_qualifier_list
    38263844                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    38273845        | ptrref_operator variable_abstract_declarator
    3828                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3846                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38293847        | ptrref_operator type_qualifier_list variable_abstract_declarator
    38303848                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     
    38683886                // No SUE declaration in parameter list.
    38693887        ptrref_operator type_specifier_nobody
    3870                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3888                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38713889        | type_qualifier_list ptrref_operator type_specifier_nobody
    38723890                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    38733891        | ptrref_operator cfa_abstract_function
    3874                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3892                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38753893        | type_qualifier_list ptrref_operator cfa_abstract_function
    38763894                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    38773895        | ptrref_operator cfa_identifier_parameter_declarator_tuple
    3878                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3896                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    38793897        | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple
    38803898                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
     
    38853903                // shift/reduce conflict with new-style empty (void) function return type.
    38863904        '[' ']' type_specifier_nobody
    3887                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3905                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38883906        | cfa_array_parameter_1st_dimension type_specifier_nobody
    38893907                { $$ = $2->addNewArray( $1 ); }
    38903908        | '[' ']' 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 ) ); }
    38923910        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    38933911                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    38963914
    38973915        | '[' ']' cfa_identifier_parameter_ptr
    3898                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     3916                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    38993917        | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr
    39003918                { $$ = $2->addNewArray( $1 ); }
    39013919        | '[' ']' 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 ) ); }
    39033921        | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr
    39043922                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
     
    39563974cfa_abstract_ptr:                                                                               // CFA
    39573975        ptrref_operator type_specifier
    3958                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3976                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39593977        | type_qualifier_list ptrref_operator type_specifier
    39603978                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39613979        | ptrref_operator cfa_abstract_function
    3962                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3980                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39633981        | type_qualifier_list ptrref_operator cfa_abstract_function
    39643982                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    39653983        | ptrref_operator cfa_abstract_declarator_tuple
    3966                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
     3984                { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    39673985        | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple
    39683986                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
Note: See TracChangeset for help on using the changeset viewer.