Changeset 738a9b4 for src


Ignore:
Timestamp:
Sep 23, 2024, 11:08:40 PM (7 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
569b118
Parents:
fca78f1
Message:

fformatting, make names consistent

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cpp

    rfca78f1 r738a9b4  
    1111// Created On       : Sat May 16 14:59:41 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Sep  9 21:49:15 2024
    14 // Update Count     : 431
     13// Last Modified On : Mon Sep 23 22:50:35 2024
     14// Update Count     : 432
    1515//
    1616
     
    105105} // ClauseNode::append_last_case
    106106
    107 ast::Stmt * build_expr( CodeLocation const & location, ExpressionNode * ctl ) {
    108         if ( ast::Expr * e = maybeMoveBuild( ctl ) ) {
     107ast::Stmt * build_expr( CodeLocation const & location, ExpressionNode * ctrl ) {
     108        if ( ast::Expr * e = maybeMoveBuild( ctrl ) ) {
    109109                return new ast::ExprStmt( location, e );
    110110        } else {
     
    113113} // build_expr
    114114
    115 static ast::Expr * build_if_control( CondCtl * ctl,
     115static ast::Expr * build_if_control( CondCtrl * ctrl,
    116116                std::vector<ast::ptr<ast::Stmt>> & inits ) {
    117117        assert( inits.empty() );
    118         if ( nullptr != ctl->init ) {
    119                 buildMoveList( ctl->init, inits );
     118        if ( nullptr != ctrl->init ) {
     119                buildMoveList( ctrl->init, inits );
    120120        } // if
    121121
    122122        ast::Expr * cond = nullptr;
    123         if ( ctl->condition ) {
    124                 cond = maybeMoveBuild( ctl->condition );
     123        if ( ctrl->condition ) {
     124                cond = maybeMoveBuild( ctrl->condition );
    125125        } else {
    126126                for ( ast::ptr<ast::Stmt> & stmt : inits ) {
     
    132132                }
    133133        }
    134         delete ctl;
     134        delete ctrl;
    135135        return cond;
    136136} // build_if_control
    137137
    138 ast::Stmt * build_if( const CodeLocation & location, CondCtl * ctl, StatementNode * then, StatementNode * else_ ) {
    139         std::vector<ast::ptr<ast::Stmt>> astinit;                                               // maybe empty
    140         ast::Expr * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
     138ast::Stmt * build_if( const CodeLocation & location, CondCtrl * ctrl, StatementNode * then, StatementNode * else_ ) {
     139        std::vector<ast::ptr<ast::Stmt>> astinit;                       // maybe empty
     140        ast::Expr * astcond = build_if_control( ctrl, astinit ); // ctrl deleted, cond/init set
    141141
    142142        ast::Stmt const * astthen = buildMoveSingle( then );
     
    148148} // build_if
    149149
    150 ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt ) {
     150ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctrl, ClauseNode * stmt ) {
    151151        std::vector<ast::ptr<ast::CaseClause>> aststmt;
    152152        buildMoveList( stmt, aststmt );
     
    169169        // aststmt.size() == 0 for switch (...) {}, i.e., no declaration or statements
    170170        return new ast::SwitchStmt( location,
    171                 maybeMoveBuild( ctl ), std::move( aststmt ) );
     171                maybeMoveBuild( ctrl ), std::move( aststmt ) );
    172172} // build_switch
    173173
    174 ast::CaseClause * build_case( const CodeLocation & location, ExpressionNode * ctl ) {
     174ast::CaseClause * build_case( const CodeLocation & location, ExpressionNode * ctrl ) {
    175175        // stmt starts empty and then added to
    176         auto expr = maybeMoveBuild( ctl );
     176        auto expr = maybeMoveBuild( ctrl );
    177177        return new ast::CaseClause( location, expr, {} );
    178178} // build_case
     
    183183} // build_default
    184184
    185 ast::Stmt * build_while( const CodeLocation & location, CondCtl * ctl, StatementNode * stmt, StatementNode * else_ ) {
     185ast::Stmt * build_while( const CodeLocation & location, CondCtrl * ctrl, StatementNode * stmt, StatementNode * else_ ) {
    186186        std::vector<ast::ptr<ast::Stmt>> astinit;                       // maybe empty
    187         ast::Expr * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
     187        ast::Expr * astcond = build_if_control( ctrl, astinit ); // ctrl deleted, cond/init set
    188188
    189189        return new ast::WhileDoStmt( location,
     
    196196} // build_while
    197197
    198 ast::Stmt * build_do_while( const CodeLocation & location, ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) {
     198ast::Stmt * build_do_while( const CodeLocation & location, ExpressionNode * ctrl, StatementNode * stmt, StatementNode * else_ ) {
    199199        // do-while cannot have declarations in the contitional, so init is always empty
    200200        return new ast::WhileDoStmt( location,
    201                 maybeMoveBuild( ctl ),
     201                maybeMoveBuild( ctrl ),
    202202                buildMoveSingle( stmt ),
    203203                buildMoveOptional( else_ ),
     
    207207} // build_do_while
    208208
    209 ast::Stmt * build_for( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ ) {
     209ast::Stmt * build_for( const CodeLocation & location, ForCtrl * forctrl, StatementNode * stmt, StatementNode * else_ ) {
    210210        std::vector<ast::ptr<ast::Stmt>> astinit;                       // maybe empty
    211         buildMoveList( forctl->init, astinit );
    212 
    213         if ( forctl->range_over ) {
    214                 ast::Expr * range_over = maybeMoveBuild( forctl->range_over );
    215                 bool isIncreasing = forctl->kind == OperKinds::LEThan;
     211        buildMoveList( forctrl->init, astinit );
     212
     213        if ( forctrl->range_over ) {
     214                ast::Expr * range_over = maybeMoveBuild( forctrl->range_over );
     215                bool isIncreasing = forctrl->kind == OperKinds::LEThan;
    216216                // Copy all the data needed before the delete.
    217                 delete forctl;
     217                delete forctrl;
    218218                return new ast::ForeachStmt( location,
    219219                        std::move( astinit ),
     
    226226
    227227        ast::Expr * astcond = nullptr;                                          // maybe empty
    228         astcond = maybeMoveBuild( forctl->condition );
     228        astcond = maybeMoveBuild( forctrl->condition );
    229229
    230230        ast::Expr * astincr = nullptr;                                          // maybe empty
    231         astincr = maybeMoveBuild( forctl->change );
    232         delete forctl;
     231        astincr = maybeMoveBuild( forctrl->change );
     232        delete forctrl;
    233233
    234234        return new ast::ForStmt( location,
     
    257257} // build_branch
    258258
    259 ast::Stmt * build_computedgoto( ExpressionNode * ctl ) {
    260         ast::Expr * expr = maybeMoveBuild( ctl );
     259ast::Stmt * build_computedgoto( ExpressionNode * ctrl ) {
     260        ast::Expr * expr = maybeMoveBuild( ctrl );
    261261        return new ast::BranchStmt( expr->location, expr );
    262262} // build_computedgoto
    263263
    264 ast::Stmt * build_return( const CodeLocation & location, ExpressionNode * ctl ) {
     264ast::Stmt * build_return( const CodeLocation & location, ExpressionNode * ctrl ) {
    265265        std::vector<ast::ptr<ast::Expr>> exps;
    266         buildMoveList( ctl, exps );
     266        buildMoveList( ctrl, exps );
    267267        return new ast::ReturnStmt( location,
    268268                exps.size() > 0 ? exps.back().release() : nullptr
     
    272272static ast::Stmt * build_throw_stmt(
    273273                const CodeLocation & location,
    274                 ExpressionNode * ctl,
     274                ExpressionNode * ctrl,
    275275                ast::ExceptionKind kind ) {
    276276        std::vector<ast::ptr<ast::Expr>> exps;
    277         buildMoveList( ctl, exps );
     277        buildMoveList( ctrl, exps );
    278278        assertf( exps.size() < 2, "CFA internal error: leaking memory" );
    279279        return new ast::ThrowStmt( location,
     
    284284}
    285285
    286 ast::Stmt * build_throw( const CodeLocation & loc, ExpressionNode * ctl ) {
    287         return build_throw_stmt( loc, ctl, ast::Terminate );
     286ast::Stmt * build_throw( const CodeLocation & loc, ExpressionNode * ctrl ) {
     287        return build_throw_stmt( loc, ctrl, ast::Terminate );
    288288} // build_throw
    289289
    290 ast::Stmt * build_resume( const CodeLocation & loc, ExpressionNode * ctl ) {
    291         return build_throw_stmt( loc, ctl, ast::Resume );
     290ast::Stmt * build_resume( const CodeLocation & loc, ExpressionNode * ctrl ) {
     291        return build_throw_stmt( loc, ctrl, ast::Resume );
    292292} // build_resume
    293293
    294 ast::Stmt * build_resume_at( ExpressionNode * ctl, ExpressionNode * target ) {
    295         (void)ctl;
     294ast::Stmt * build_resume_at( ExpressionNode * ctrl, ExpressionNode * target ) {
     295        (void)ctrl;
    296296        (void)target;
    297297        assertf( false, "resume at (non-local throw) is not yet supported," );
     
    516516} // build_corun
    517517
    518 ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt ) {
     518ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctrl, StatementNode * stmt ) {
    519519        std::vector<ast::ptr<ast::Stmt>> astinit;                                               // maybe empty
    520         buildMoveList( forctl->init, astinit );
     520        buildMoveList( forctrl->init, astinit );
    521521
    522522        ast::Expr * astcond = nullptr;                                          // maybe empty
    523         astcond = maybeMoveBuild( forctl->condition );
     523        astcond = maybeMoveBuild( forctrl->condition );
    524524
    525525        ast::Expr * astincr = nullptr;                                          // maybe empty
    526         astincr = maybeMoveBuild( forctl->change );
    527         delete forctl;
     526        astincr = maybeMoveBuild( forctrl->change );
     527        delete forctrl;
    528528
    529529        return new ast::CoforStmt( location,
  • src/Parser/StatementNode.hpp

    rfca78f1 r738a9b4  
    1010// Created On       : Wed Apr  5 11:42:00 2023
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 11 11:44:07 2023
    13 // Update Count     : 2
     12// Last Modified On : Mon Sep 23 22:43:05 2024
     13// Update Count     : 3
    1414//
    1515
     
    5151};
    5252
    53 ast::Stmt * build_expr( CodeLocation const &, ExpressionNode * ctl );
     53ast::Stmt * build_expr( CodeLocation const &, ExpressionNode * ctrl );
    5454
    55 struct CondCtl {
    56         CondCtl( DeclarationNode * decl, ExpressionNode * condition ) :
     55struct CondCtrl {
     56        CondCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
    5757                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    5858
     
    6565                init( stmt ), condition( condition ), change( change ), range_over( nullptr ) {}
    6666        ForCtrl( StatementNode * decl, ExpressionNode * range_over, OperKinds kind ) :
    67                 init( decl ), condition( nullptr ), change( nullptr ),  range_over( range_over ), kind( kind ) {}
     67                init( decl ), condition( nullptr ), change( nullptr ), range_over( range_over ), kind( kind ) {}
    6868
    6969        StatementNode * init;
     
    7474};
    7575
    76 ast::Stmt * build_if( const CodeLocation &, CondCtl * ctl, StatementNode * then, StatementNode * else_ );
    77 ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt );
    78 ast::CaseClause * build_case( const CodeLocation &, ExpressionNode * ctl );
     76ast::Stmt * build_if( const CodeLocation &, CondCtrl * ctrl, StatementNode * then, StatementNode * else_ );
     77ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctrl, ClauseNode * stmt );
     78ast::CaseClause * build_case( const CodeLocation &, ExpressionNode * ctrl );
    7979ast::CaseClause * build_default( const CodeLocation & );
    80 ast::Stmt * build_while( const CodeLocation &, CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
    81 ast::Stmt * build_do_while( const CodeLocation &, ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
    82 ast::Stmt * build_for( const CodeLocation &, ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ = nullptr );
     80ast::Stmt * build_while( const CodeLocation &, CondCtrl * ctrl, StatementNode * stmt, StatementNode * else_ = nullptr );
     81ast::Stmt * build_do_while( const CodeLocation &, ExpressionNode * ctrl, StatementNode * stmt, StatementNode * else_ = nullptr );
     82ast::Stmt * build_for( const CodeLocation &, ForCtrl * forctrl, StatementNode * stmt, StatementNode * else_ = nullptr );
    8383ast::Stmt * build_branch( const CodeLocation &, ast::BranchStmt::Kind kind );
    8484ast::Stmt * build_branch( const CodeLocation &, std::string * identifier, ast::BranchStmt::Kind kind );
    85 ast::Stmt * build_computedgoto( ExpressionNode * ctl );
    86 ast::Stmt * build_return( const CodeLocation &, ExpressionNode * ctl );
    87 ast::Stmt * build_throw( const CodeLocation &, ExpressionNode * ctl );
    88 ast::Stmt * build_resume( const CodeLocation &, ExpressionNode * ctl );
    89 ast::Stmt * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
     85ast::Stmt * build_computedgoto( ExpressionNode * ctrl );
     86ast::Stmt * build_return( const CodeLocation &, ExpressionNode * ctrl );
     87ast::Stmt * build_throw( const CodeLocation &, ExpressionNode * ctrl );
     88ast::Stmt * build_resume( const CodeLocation &, ExpressionNode * ctrl );
     89ast::Stmt * build_resume_at( ExpressionNode * ctrl , ExpressionNode * target );
    9090ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ );
    9191ast::CatchClause * build_catch( const CodeLocation &, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body );
     
    105105ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
    106106ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt );
    107 ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt );
     107ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctrl, StatementNode * stmt );
  • src/Parser/lex.ll

    rfca78f1 r738a9b4  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Sep 11 17:16:23 2024
    13  * Update Count     : 791
     12 * Last Modified On : Mon Sep 23 22:45:33 2024
     13 * Update Count     : 792
    1414 */
    1515
     
    4949#include "ParseNode.hpp"
    5050#include "ParserTypes.hpp"                              // for Token
    51 #include "StatementNode.hpp"                            // for CondCtl, ForCtrl
     51#include "StatementNode.hpp"                            // for CondCtrl, ForCtrl
    5252#include "TypedefTable.hpp"
    5353// This (generated) header must come late as it is missing includes.
Note: See TracChangeset for help on using the changeset viewer.