Changeset 1a3eab8 for src/Parser


Ignore:
Timestamp:
Apr 30, 2018, 11:59:07 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
7b45636
Parents:
c0453ca3 (diff), b9c432f (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' into fix-reference-overloading

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rc0453ca3 r1a3eab8  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 20 22:37:20 2018
    13 // Update Count     : 1063
     12// Last Modified On : Thu Apr 26 13:45:10 2018
     13// Update Count     : 1064
    1414//
    1515
     
    783783DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) {
    784784        if ( p ) {
    785                 assert( p->type->kind == TypeData::Pointer || TypeData::Reference );
     785                assert( p->type->kind == TypeData::Pointer || p->type->kind == TypeData::Reference );
    786786                setBase( p->type );
    787787                p->type = nullptr;
  • src/Parser/ParseNode.h

    rc0453ca3 r1a3eab8  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 17:49:31 2018
    13 // Update Count     : 827
     12// Last Modified On : Sun Apr 29 14:04:05 2018
     13// Update Count     : 830
    1414//
    1515
     
    332332        bool hasEllipsis;
    333333        LinkageSpec::Spec linkage;
    334         Expression *asmName;
     334        Expression * asmName;
    335335        std::list< Attribute * > attributes;
    336336        InitializerNode * initializer;
     
    417417Statement * build_compound( StatementNode * first );
    418418Statement * build_asmstmt( bool voltile, Expression * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
     419Statement * build_dirstmt( std::string * directive );
    419420WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );
    420421WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );
  • src/Parser/StatementNode.cc

    rc0453ca3 r1a3eab8  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 14:31:32 2018
    13 // Update Count     : 348
     12// Last Modified On : Sun Apr 29 14:21:45 2018
     13// Update Count     : 353
    1414//
    1515
     
    3333
    3434
    35 StatementNode::StatementNode( DeclarationNode *decl ) {
     35StatementNode::StatementNode( DeclarationNode * decl ) {
    3636        assert( decl );
    37         DeclarationNode *agg = decl->extractAggregate();
     37        DeclarationNode * agg = decl->extractAggregate();
    3838        if ( agg ) {
    39                 StatementNode *nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
     39                StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild< Declaration >( decl ) ) );
    4040                set_next( nextStmt );
    4141                if ( decl->get_next() ) {
     
    5353} // StatementNode::StatementNode
    5454
    55 StatementNode *StatementNode::append_last_case( StatementNode *stmt ) {
    56         StatementNode *prev = this;
     55StatementNode * StatementNode::append_last_case( StatementNode * stmt ) {
     56        StatementNode * prev = this;
    5757        // find end of list and maintain previous pointer
    5858        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    59                 StatementNode *node = strict_dynamic_cast< StatementNode * >(curr);
     59                StatementNode * node = strict_dynamic_cast< StatementNode * >(curr);
    6060                assert( dynamic_cast< CaseStmt * >(node->stmt.get()) );
    6161                prev = curr;
    6262        } // for
    6363        // convert from StatementNode list to Statement list
    64         StatementNode *node = dynamic_cast< StatementNode * >(prev);
     64        StatementNode * node = dynamic_cast< StatementNode * >(prev);
    6565        std::list< Statement * > stmts;
    6666        buildMoveList( stmt, stmts );
     
    7171}
    7272
    73 Statement *build_expr( ExpressionNode *ctl ) {
    74         Expression *e = maybeMoveBuild< Expression >( ctl );
     73Statement * build_expr( ExpressionNode * ctl ) {
     74        Expression * e = maybeMoveBuild< Expression >( ctl );
    7575
    7676        if ( e )
     
    8080}
    8181
    82 Statement *build_if( IfCtl * ctl, StatementNode *then_stmt, StatementNode *else_stmt ) {
    83         Statement *thenb, *elseb = 0;
     82Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     83        Statement * thenb, * elseb = 0;
    8484        std::list< Statement * > branches;
    8585        buildMoveList< Statement, StatementNode >( then_stmt, branches );
     
    116116}
    117117
    118 Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
     118Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
    119119        std::list< Statement * > branches;
    120120        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    131131        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
    132132}
    133 Statement *build_case( ExpressionNode *ctl ) {
     133Statement * build_case( ExpressionNode * ctl ) {
    134134        std::list< Statement * > branches;
    135135        return new CaseStmt( maybeMoveBuild< Expression >(ctl), branches );
    136136}
    137 Statement *build_default() {
     137Statement * build_default() {
    138138        std::list< Statement * > branches;
    139139        return new CaseStmt( nullptr, branches, true );
    140140}
    141141
    142 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
     142Statement * build_while( ExpressionNode * ctl, StatementNode * stmt, bool kind ) {
    143143        std::list< Statement * > branches;
    144144        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    147147}
    148148
    149 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
     149Statement * build_for( ForCtl * forctl, StatementNode * stmt ) {
    150150        std::list< Statement * > branches;
    151151        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    157157        } // if
    158158
    159         Expression *cond = 0;
     159        Expression * cond = 0;
    160160        if ( forctl->condition != 0 )
    161161                cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
    162162
    163         Expression *incr = 0;
     163        Expression * incr = 0;
    164164        if ( forctl->change != 0 )
    165165                incr = maybeMoveBuild< Expression >(forctl->change);
     
    169169}
    170170
    171 Statement *build_branch( BranchStmt::Type kind ) {
     171Statement * build_branch( BranchStmt::Type kind ) {
    172172        Statement * ret = new BranchStmt( "", kind );
    173173        return ret;
    174174}
    175 Statement *build_branch( std::string *identifier, BranchStmt::Type kind ) {
    176         Statement * ret = new BranchStmt( *identifier, kind );
     175Statement * build_branch( std::string * identifier, BranchStmt::Type kind ) {
     176        Statement * ret = new BranchStmt( * identifier, kind );
    177177        delete identifier;                                                                      // allocated by lexer
    178178        return ret;
    179179}
    180 Statement *build_computedgoto( ExpressionNode *ctl ) {
     180Statement * build_computedgoto( ExpressionNode * ctl ) {
    181181        return new BranchStmt( maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
    182182}
    183183
    184 Statement *build_return( ExpressionNode *ctl ) {
     184Statement * build_return( ExpressionNode * ctl ) {
    185185        std::list< Expression * > exps;
    186186        buildMoveList( ctl, exps );
     
    188188}
    189189
    190 Statement *build_throw( ExpressionNode *ctl ) {
     190Statement * build_throw( ExpressionNode * ctl ) {
    191191        std::list< Expression * > exps;
    192192        buildMoveList( ctl, exps );
     
    195195}
    196196
    197 Statement *build_resume( ExpressionNode *ctl ) {
     197Statement * build_resume( ExpressionNode * ctl ) {
    198198        std::list< Expression * > exps;
    199199        buildMoveList( ctl, exps );
     
    202202}
    203203
    204 Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) {
     204Statement * build_resume_at( ExpressionNode * ctl, ExpressionNode * target ) {
    205205        (void)ctl;
    206206        (void)target;
     
    208208}
    209209
    210 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
     210Statement * build_try( StatementNode * try_stmt, StatementNode * catch_stmt, StatementNode * finally_stmt ) {
    211211        std::list< CatchStmt * > branches;
    212212        buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
    213         CompoundStmt *tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    214         FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
     213        CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
     214        FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
    215215        return new TryStmt( tryBlock, branches, finallyBlock );
    216216}
    217 Statement *build_catch( CatchStmt::Kind kind, DeclarationNode *decl, ExpressionNode *cond, StatementNode *body ) {
     217Statement * build_catch( CatchStmt::Kind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
    218218        std::list< Statement * > branches;
    219219        buildMoveList< Statement, StatementNode >( body, branches );
     
    221221        return new CatchStmt( kind, maybeMoveBuild< Declaration >(decl), maybeMoveBuild< Expression >(cond), branches.front() );
    222222}
    223 Statement *build_finally( StatementNode *stmt ) {
     223Statement * build_finally( StatementNode * stmt ) {
    224224        std::list< Statement * > branches;
    225225        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    304304}
    305305
    306 Statement *build_compound( StatementNode *first ) {
    307         CompoundStmt *cs = new CompoundStmt();
     306Statement * build_compound( StatementNode * first ) {
     307        CompoundStmt * cs = new CompoundStmt();
    308308        buildMoveList( first, cs->get_kids() );
    309309        return cs;
    310310}
    311311
    312 Statement *build_asmstmt( bool voltile, Expression *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) {
     312Statement * build_asmstmt( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {
    313313        std::list< Expression * > out, in;
    314314        std::list< ConstantExpr * > clob;
     
    318318        buildMoveList( clobber, clob );
    319319        return new AsmStmt( voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
     320}
     321
     322Statement * build_dirstmt( string * directive ) {
     323        cout << *directive << endl;
     324        return nullptr;
    320325}
    321326
  • src/Parser/TypeData.cc

    rc0453ca3 r1a3eab8  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 17 23:00:52 2018
    13 // Update Count     : 602
     12// Last Modified On : Thu Apr 26 13:46:07 2018
     13// Update Count     : 603
    1414//
    1515
     
    6262                enumeration.constants = nullptr;
    6363                enumeration.body = false;
     64                break;
    6465          case Aggregate:
    6566                // aggregate = new Aggregate_t;
  • src/Parser/lex.ll

    rc0453ca3 r1a3eab8  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Fri Apr  6 15:16:15 2018
    13  * Update Count     : 670
     12 * Last Modified On : Sun Apr 29 14:10:49 2018
     13 * Update Count     : 675
    1414 */
    1515
     
    174174}
    175175
    176                                 /* ignore preprocessor directives (for now) */
    177 ^{h_white}*"#"[^\n]*"\n" ;
     176                                /* ignore preprocessor-style directives (for now) */
     177^{h_white}*"#"[^\n]*"\n" { RETURN_VAL( DIRECTIVE ); }
    178178
    179179                                /* ignore C style comments (ALSO HANDLED BY CPP) */
  • src/Parser/parser.yy

    rc0453ca3 r1a3eab8  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 17 17:10:30 2018
    13 // Update Count     : 3144
     12// Last Modified On : Sun Apr 29 14:20:17 2018
     13// Update Count     : 3206
    1414//
    1515
     
    133133} // build_postfix_name
    134134
    135 bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     135bool forall = false, xxx = false;                                               // aggregate have one or more forall qualifiers ?
    136136
    137137// https://www.gnu.org/software/bison/manual/bison.html#Location-Type
     
    208208%token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    209209%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
     210%token<tok> DIRECTIVE
    210211// Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and
    211212// overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically
     
    282283%type<decl> aggregate_type aggregate_type_nobody
    283284
    284 %type<decl> assertion assertion_list_opt
     285%type<decl> assertion assertion_list assertion_list_opt
    285286
    286287%type<en>   bit_subrange_size_opt bit_subrange_size
     
    875876                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    876877        | asm_statement
     878        | DIRECTIVE
     879                { $$ = new StatementNode( build_dirstmt( $1 ) ); }
    877880        ;
    878881
     
    18661869                {
    18671870                        typedefTable.makeTypedef( *$3 );
     1871                        if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update
     1872                        forall = false;                                                         // reset
    18681873                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    18691874                }
     
    22352240                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    22362241        | type_specifier identifier_parameter_declarator
     2242        | assertion_list
     2243                { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    22372244        ;
    22382245
     
    22512258        // empty
    22522259                { $$ = nullptr; }
    2253         | assertion_list_opt assertion
     2260        | assertion_list
     2261        ;
     2262
     2263assertion_list:                                                                                 // CFA
     2264        assertion
     2265        | assertion_list assertion
    22542266                { $$ = $1 ? $1->appendList( $2 ) : $2; }
    22552267        ;
     
    23782390external_definition_list:
    23792391        external_definition
    2380         | external_definition_list push external_definition
    2381                 { $$ = $1 ? $1->appendList( $3 ) : $3; }
     2392        | external_definition_list { forall = xxx; } push external_definition
     2393                { $$ = $1 ? $1->appendList( $4 ) : $4; }
    23822394        ;
    23832395
     
    24112423                        $$ = $2;
    24122424                }
    2413         | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
     2425        | type_qualifier_list
     2426                {
     2427                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2428                }
     2429          push '{' external_definition_list '}'                         // CFA, namespace
     2430                {
     2431                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2432                                iter->addQualifiers( $1->clone() );
     2433                        } // for
     2434                        xxx = false;
     2435                        delete $1;
     2436                        $$ = $5;
     2437                }
     2438        | declaration_qualifier_list
     2439                {
     2440                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2441                }
     2442          push '{' external_definition_list '}'                         // CFA, namespace
     2443                {
     2444                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2445                                iter->addQualifiers( $1->clone() );
     2446                        } // for
     2447                        xxx = false;
     2448                        delete $1;
     2449                        $$ = $5;
     2450                }
     2451        | declaration_qualifier_list type_qualifier_list
     2452                {
     2453                        if ( $1->type->forall ) xxx = forall = true; // remember generic type
     2454                }
     2455          push '{' external_definition_list '}'                         // CFA, namespace
     2456                {
     2457                        for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     2458                                iter->addQualifiers( $1->clone() );
     2459                                iter->addQualifiers( $2->clone() );
     2460                        } // for
     2461                        xxx = false;
     2462                        delete $1;
     2463                        delete $2;
     2464                        $$ = $6;
     2465                }
    24142466        ;
    24152467
     
    24372489with_clause_opt:
    24382490        // empty
    2439                 { $$ = nullptr; }
     2491                { $$ = nullptr; forall = false; }
    24402492        | WITH '(' tuple_expression_list ')'
    2441                 { $$ = $3; }
     2493                { $$ = $3; forall = false; }
    24422494        ;
    24432495
Note: See TracChangeset for help on using the changeset viewer.