Changeset 6611177


Ignore:
Timestamp:
Apr 11, 2023, 12:48:03 PM (13 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
5541a44e
Parents:
9921573
Message:

Clean-up in parser. ClauseNode? rework, plus internal adjustments to reduce extra code and unchecked casts.

Location:
src/Parser
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r9921573 r6611177  
    10031003}
    10041004
    1005 void buildList( const DeclarationNode * firstNode,
     1005void buildList( DeclarationNode * firstNode,
    10061006                std::vector<ast::ptr<ast::Decl>> & outputList ) {
    10071007        SemanticErrorException errors;
     
    11361136
    11371137// currently only builds assertions, function parameters, and return values
    1138 void buildList( const DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList ) {
     1138void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList ) {
    11391139        SemanticErrorException errors;
    11401140        std::back_insert_iterator<std::vector<ast::ptr<ast::DeclWithType>>> out( outputList );
  • src/Parser/DeclarationNode.h

    r9921573 r6611177  
    180180template<typename AstType, typename NodeType,
    181181    template<typename, typename...> class Container, typename... Args>
    182 void buildList( const NodeType * firstNode,
     182void buildList( NodeType * firstNode,
    183183        Container<ast::ptr<AstType>, Args...> & output ) {
    184184    SemanticErrorException errors;
    185185    std::back_insert_iterator<Container<ast::ptr<AstType>, Args...>> out( output );
    186     const NodeType * cur = firstNode;
     186    NodeType * cur = firstNode;
    187187
    188188    while ( cur ) {
     
    197197            errors.append( e );
    198198        } // try
    199         const ParseNode * temp = cur->get_next();
     199        ParseNode * temp = cur->get_next();
    200200        // Should not return nullptr, then it is non-homogeneous:
    201         cur = dynamic_cast<const NodeType *>( temp );
     201        cur = dynamic_cast<NodeType *>( temp );
    202202        if ( !cur && temp ) {
    203203            SemanticError( temp->location, "internal error, non-homogeneous nodes founds in buildList processing." );
     
    209209}
    210210
    211 void buildList( const DeclarationNode * firstNode, std::vector<ast::ptr<ast::Decl>> & outputList );
    212 void buildList( const DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList );
     211void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::Decl>> & outputList );
     212void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList );
    213213void buildTypeList( const DeclarationNode * firstNode, std::vector<ast::ptr<ast::Type>> & outputList );
    214214
    215215template<typename AstType, typename NodeType,
    216216template<typename, typename...> class Container, typename... Args>
    217 void buildMoveList( const NodeType * firstNode,
    218 Container<ast::ptr<AstType>, Args...> & output ) {
    219 buildList<AstType, NodeType, Container, Args...>( firstNode, output );
    220 delete firstNode;
     217void buildMoveList( NodeType * firstNode,
     218                Container<ast::ptr<AstType>, Args...> & output ) {
     219        buildList<AstType, NodeType, Container, Args...>( firstNode, output );
     220        delete firstNode;
    221221}
  • src/Parser/ExpressionNode.cc

    r9921573 r6611177  
    702702} // build_binary_val
    703703
    704 ast::Expr * build_binary_ptr( const CodeLocation & location,
    705                 OperKinds op,
    706                 ExpressionNode * expr_node1,
    707                 ExpressionNode * expr_node2 ) {
    708         return build_binary_val( location, op, expr_node1, expr_node2 );
    709 } // build_binary_ptr
    710 
    711704ast::Expr * build_cond( const CodeLocation & location,
    712705                ExpressionNode * expr_node1,
  • src/Parser/ExpressionNode.h

    r9921573 r6611177  
    4141        bool isExpressionType() const {  return nullptr != dynamic_cast<T>(expr.get()); }
    4242
    43         ast::Expr * build() const {
    44                 ast::Expr * node = const_cast<ExpressionNode *>(this)->expr.release();
     43        ast::Expr * build() {
     44                ast::Expr * node = expr.release();
    4545                node->set_extension( this->get_extension() );
    4646                node->location = this->location;
     
    5353        bool extension = false;
    5454}; // ExpressionNode
    55 
    56 /*
    57 // Must harmonize with OperName.
    58 enum class OperKinds {
    59     // diadic
    60     SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
    61     BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    62     Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    63     Index, Range,
    64     // monadic
    65     UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost,
    66     Ctor, Dtor,
    67 }; // OperKinds
    68 
    69 enum class EnumHiding { Visible, Hide };
    70 
    71 struct LabelNode {
    72     std::vector<ast::Label> labels;
    73 };
    74 */
    7555
    7656// These 4 routines modify the string:
     
    9979ast::Expr * build_unary_val( const CodeLocation &, OperKinds op, ExpressionNode * expr_node );
    10080ast::Expr * build_binary_val( const CodeLocation &, OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
    101 ast::Expr * build_binary_ptr( const CodeLocation &, OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
    10281ast::Expr * build_cond( const CodeLocation &, ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 );
    10382ast::Expr * build_tuple( const CodeLocation &, ExpressionNode * expr_node = nullptr );
  • src/Parser/StatementNode.cc

    r9921573 r6611177  
    1111// Created On       : Sat May 16 14:59:41 2015
    1212// Last Modified By : Andrew Beach
    13 // Last Modified On : Tue Apr  4 11:40:00 2023
    14 // Update Count     : 427
     13// Last Modified On : Tue Apr 11 10:16:00 2023
     14// Update Count     : 428
    1515//
    1616
     
    3232
    3333using namespace std;
     34
     35// Some helpers for cases that really want a single node but check for lists.
     36static const ast::Stmt * buildMoveSingle( StatementNode * node ) {
     37        std::vector<ast::ptr<ast::Stmt>> list;
     38        buildMoveList( node, list );
     39        assertf( list.size() == 1, "CFA Internal Error: Extra/Missing Nodes" );
     40        return list.front().release();
     41}
     42
     43static const ast::Stmt * buildMoveOptional( StatementNode * node ) {
     44        std::vector<ast::ptr<ast::Stmt>> list;
     45        buildMoveList( node, list );
     46        assertf( list.size() <= 1, "CFA Internal Error: Extra Nodes" );
     47        return list.empty() ? nullptr : list.front().release();
     48}
    3449
    3550StatementNode::StatementNode( DeclarationNode * decl ) {
     
    6984}
    7085
    71 StatementNode * StatementNode::append_last_case( StatementNode * stmt ) {
    72         StatementNode * prev = this;
     86ClauseNode * ClauseNode::append_last_case( StatementNode * stmt ) {
     87        ClauseNode * prev = this;
    7388        // find end of list and maintain previous pointer
    74         for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    75                 StatementNode * node = strict_dynamic_cast< StatementNode * >(curr);
    76                 assert( nullptr == node->stmt.get() );
     89        for ( ClauseNode * curr = prev; curr != nullptr; curr = (ClauseNode *)curr->get_next() ) {
     90                ClauseNode * node = strict_dynamic_cast< ClauseNode * >(curr);
    7791                assert( dynamic_cast<ast::CaseClause *>( node->clause.get() ) );
    7892                prev = curr;
    7993        } // for
     94        ClauseNode * node = dynamic_cast< ClauseNode * >(prev);
    8095        // convert from StatementNode list to Statement list
    81         StatementNode * node = dynamic_cast< StatementNode * >(prev);
    8296        std::vector<ast::ptr<ast::Stmt>> stmts;
    8397        buildMoveList( stmt, stmts );
     
    89103        stmts.clear();
    90104        return this;
    91 } // StatementNode::append_last_case
     105} // ClauseNode::append_last_case
    92106
    93107ast::Stmt * build_expr( CodeLocation const & location, ExpressionNode * ctl ) {
     
    113127                for ( ast::ptr<ast::Stmt> & stmt : inits ) {
    114128                        // build the && of all of the declared variables compared against 0
    115                         //auto declStmt = strict_dynamic_cast<ast::DeclStmt *>( stmt );
    116129                        auto declStmt = stmt.strict_as<ast::DeclStmt>();
    117                         //ast::DeclWithType * dwt = strict_dynamic_cast<ast::DeclWithType *>( declStmt->decl );
    118130                        auto dwt = declStmt->decl.strict_as<ast::DeclWithType>();
    119131                        ast::Expr * nze = notZeroExpr( new ast::VariableExpr( dwt->location, dwt ) );
     
    136148        ast::Stmt const * astelse = nullptr;
    137149        if ( else_ ) {
    138                 std::vector<ast::ptr<ast::Stmt>> aststmt;
    139                 buildMoveList( else_, aststmt );
    140                 assert( aststmt.size() == 1 );
    141                 astelse = aststmt.front().release();
     150                astelse = buildMoveSingle( else_ );
    142151        } // if
    143152
     
    147156} // build_if
    148157
    149 // Temporary work around. Split StmtClause off from StatementNode.
    150 template<typename clause_t>
    151 static void buildMoveClauseList( StatementNode * firstNode,
    152                 std::vector<ast::ptr<clause_t>> & output ) {
    153         SemanticErrorException errors;
    154         std::back_insert_iterator<std::vector<ast::ptr<clause_t>>>
    155                 out( output );
    156         StatementNode * cur = firstNode;
    157 
    158         while ( cur ) {
    159                 try {
    160                         auto clause = cur->clause.release();
    161                         if ( auto result = dynamic_cast<clause_t *>( clause ) ) {
    162                                 *out++ = result;
    163                         } else {
    164                                 assertf(false, __PRETTY_FUNCTION__ );
    165                                 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." );
    166                         } // if
    167                 } catch( SemanticErrorException & e ) {
    168                         errors.append( e );
    169                 } // try
    170                 ParseNode * temp = cur->get_next();
    171                 // Should not return nullptr, then it is non-homogeneous:
    172                 cur = dynamic_cast<StatementNode *>( temp );
    173                 if ( !cur && temp ) {
    174                         SemanticError( temp->location, "internal error, non-homogeneous nodes founds in buildList processing." );
    175                 } // if
    176         } // while
    177         if ( ! errors.isEmpty() ) {
    178                 throw errors;
    179         } // if
    180         // Usually in the wrapper.
    181         delete firstNode;
    182 }
    183 
    184 ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) {
     158ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt ) {
    185159        std::vector<ast::ptr<ast::CaseClause>> aststmt;
    186         buildMoveClauseList( stmt, aststmt );
     160        buildMoveList( stmt, aststmt );
    187161        // If it is not a switch it is a choose statement.
    188162        if ( ! isSwitch ) {
     
    206180} // build_switch
    207181
    208 ast::CaseClause * build_case( ExpressionNode * ctl ) {
     182ast::CaseClause * build_case( const CodeLocation & location, ExpressionNode * ctl ) {
    209183        // stmt starts empty and then added to
    210184        auto expr = maybeMoveBuild( ctl );
    211         return new ast::CaseClause( expr->location, expr, {} );
     185        return new ast::CaseClause( location, expr, {} );
    212186} // build_case
    213187
     
    221195        ast::Expr * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set
    222196
    223         std::vector<ast::ptr<ast::Stmt>> aststmt;                                               // loop body, compound created if empty
    224         buildMoveList( stmt, aststmt );
    225         assert( aststmt.size() == 1 );
    226 
    227         std::vector<ast::ptr<ast::Stmt>> astelse;                                               // else clause, maybe empty
    228         buildMoveList( else_, astelse );
    229         assert( astelse.size() <= 1 );
    230 
    231197        return new ast::WhileDoStmt( location,
    232198                astcond,
    233                 aststmt.front(),
    234                 astelse.empty() ? nullptr : astelse.front().release(),
     199                buildMoveSingle( stmt ),
     200                buildMoveOptional( else_ ),
    235201                std::move( astinit ),
    236202                ast::While
     
    239205
    240206ast::Stmt * build_do_while( const CodeLocation & location, ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) {
    241         std::vector<ast::ptr<ast::Stmt>> aststmt;                                               // loop body, compound created if empty
    242         buildMoveList( stmt, aststmt );
    243         assert( aststmt.size() == 1 );                                          // compound created if empty
    244 
    245         std::vector<ast::ptr<ast::Stmt>> astelse;                                               // else clause, maybe empty
    246         buildMoveList( else_, astelse );
    247         assert( astelse.size() <= 1 );
    248 
    249207        // do-while cannot have declarations in the contitional, so init is always empty
    250208        return new ast::WhileDoStmt( location,
    251209                notZeroExpr( maybeMoveBuild( ctl ) ),
    252                 aststmt.front(),
    253                 astelse.empty() ? nullptr : astelse.front().release(),
     210                buildMoveSingle( stmt ),
     211                buildMoveOptional( else_ ),
    254212                {},
    255213                ast::DoWhile
     
    267225        astincr = maybeMoveBuild( forctl->change );
    268226        delete forctl;
    269 
    270         std::vector<ast::ptr<ast::Stmt>> aststmt;                                               // loop body, compound created if empty
    271         buildMoveList( stmt, aststmt );
    272         assert( aststmt.size() == 1 );
    273 
    274         std::vector<ast::ptr<ast::Stmt>> astelse;                                               // else clause, maybe empty
    275         buildMoveList( else_, astelse );
    276         assert( astelse.size() <= 1 );
    277227
    278228        return new ast::ForStmt( location,
     
    280230                astcond,
    281231                astincr,
    282                 aststmt.front(),
    283                 astelse.empty() ? nullptr : astelse.front().release()
     232                buildMoveSingle( stmt ),
     233                buildMoveOptional( else_ )
    284234        );
    285235} // build_for
     
    342292} // build_resume_at
    343293
    344 ast::Stmt * build_try( const CodeLocation & location, StatementNode * try_, StatementNode * catch_, StatementNode * finally_ ) {
     294ast::Stmt * build_try( const CodeLocation & location, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ ) {
    345295        std::vector<ast::ptr<ast::CatchClause>> aststmt;
    346         buildMoveClauseList( catch_, aststmt );
     296        buildMoveList( catch_, aststmt );
    347297        ast::CompoundStmt * tryBlock = strict_dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( try_ ) );
    348298        ast::FinallyClause * finallyBlock = nullptr;
     
    358308
    359309ast::CatchClause * build_catch( const CodeLocation & location, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) {
    360         std::vector<ast::ptr<ast::Stmt>> aststmt;
    361         buildMoveList( body, aststmt );
    362         assert( aststmt.size() == 1 );
    363310        return new ast::CatchClause( location,
    364311                kind,
    365312                maybeMoveBuild( decl ),
    366313                maybeMoveBuild( cond ),
    367                 aststmt.front().release()
     314                buildMoveSingle( body )
    368315        );
    369316} // build_catch
    370317
    371318ast::FinallyClause * build_finally( const CodeLocation & location, StatementNode * stmt ) {
    372         std::vector<ast::ptr<ast::Stmt>> aststmt;
    373         buildMoveList( stmt, aststmt );
    374         assert( aststmt.size() == 1 );
    375319        return new ast::FinallyClause( location,
    376                 aststmt.front().strict_as<ast::CompoundStmt>()
     320                strict_dynamic_cast<const ast::CompoundStmt *>(
     321                        buildMoveSingle( stmt )
     322                )
    377323        );
    378324} // build_finally
    379325
    380326ast::SuspendStmt * build_suspend( const CodeLocation & location, StatementNode * then, ast::SuspendStmt::Kind kind ) {
    381         std::vector<ast::ptr<ast::Stmt>> stmts;
    382         buildMoveList( then, stmts );
    383         ast::CompoundStmt const * then2 = nullptr;
    384         if(!stmts.empty()) {
    385                 assert( stmts.size() == 1 );
    386                 then2 = stmts.front().strict_as<ast::CompoundStmt>();
    387         }
    388         return new ast::SuspendStmt( location, then2, kind );
     327        return new ast::SuspendStmt( location,
     328                strict_dynamic_cast<const ast::CompoundStmt *, nullptr>(
     329                        buildMoveOptional( then )
     330                ),
     331                kind
     332        );
    389333} // build_suspend
    390334
  • src/Parser/StatementNode.h

    r9921573 r6611177  
    1010// Created On       : Wed Apr  5 11:42:00 2023
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr  5 11:57:00 2023
    13 // Update Count     : 0
     12// Last Modified On : Tue Apr 11  9:43:00 2023
     13// Update Count     : 1
    1414//
    1515
     
    1919
    2020struct StatementNode final : public ParseNode {
    21         StatementNode() :
    22                 stmt( nullptr ), clause( nullptr ) {}
    23         StatementNode( ast::Stmt * stmt ) :
    24                 stmt( stmt ), clause( nullptr ) {}
    25         StatementNode( ast::StmtClause * clause ) :
    26                 stmt( nullptr ), clause( clause ) {}
     21        StatementNode() : stmt( nullptr ) {}
     22        StatementNode( ast::Stmt * stmt ) : stmt( stmt ) {}
    2723        StatementNode( DeclarationNode * decl );
    2824        virtual ~StatementNode() {}
    2925
    3026        virtual StatementNode * clone() const final { assert( false ); return nullptr; }
    31         ast::Stmt * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }
     27        ast::Stmt * build() { return stmt.release(); }
    3228
    3329        StatementNode * add_label(
    3430                        const CodeLocation & location,
    3531                        const std::string * name,
    36                         DeclarationNode * attr = nullptr );/* {
    37                 stmt->labels.emplace_back( location,
    38                         *name,
    39                         attr ? std::move( attr->attributes )
    40                                 : std::vector<ast::ptr<ast::Attribute>>{} );
    41                 delete attr;
    42                 delete name;
    43                 return this;
    44         }*/
    45 
    46         virtual StatementNode * append_last_case( StatementNode * );
     32                        DeclarationNode * attr = nullptr );
    4733
    4834        virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {
     
    5137
    5238        std::unique_ptr<ast::Stmt> stmt;
     39}; // StatementNode
     40
     41struct ClauseNode final : public ParseNode {
     42        ClauseNode( ast::StmtClause * clause ) : clause( clause ) {}
     43        virtual ~ClauseNode() {}
     44
     45        ClauseNode * set_last( ParseNode * newlast ) {
     46                ParseNode::set_last( newlast );
     47        return this;
     48    }
     49
     50        virtual ClauseNode * clone() const final { assert( false ); return nullptr; }
     51        ast::StmtClause * build() { return clause.release(); }
     52
     53        virtual ClauseNode * append_last_case( StatementNode * );
     54
    5355        std::unique_ptr<ast::StmtClause> clause;
    54 }; // StatementNode
     56};
    5557
    5658ast::Stmt * build_expr( CodeLocation const &, ExpressionNode * ctl );
     
    7476
    7577ast::Stmt * build_if( const CodeLocation &, CondCtl * ctl, StatementNode * then, StatementNode * else_ );
    76 ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    77 ast::CaseClause * build_case( ExpressionNode * ctl );
     78ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt );
     79ast::CaseClause * build_case( const CodeLocation &, ExpressionNode * ctl );
    7880ast::CaseClause * build_default( const CodeLocation & );
    7981ast::Stmt * build_while( const CodeLocation &, CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
     
    8789ast::Stmt * build_resume( const CodeLocation &, ExpressionNode * ctl );
    8890ast::Stmt * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
    89 ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, StatementNode * catch_, StatementNode * finally_ );
     91ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ );
    9092ast::CatchClause * build_catch( const CodeLocation &, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body );
    9193ast::FinallyClause * build_finally( const CodeLocation &, StatementNode * stmt );
  • src/Parser/parser.yy

    r9921573 r6611177  
    306306        ast::TypeDecl::Kind tclass;
    307307        StatementNode * sn;
     308        ClauseNode * clause;
    308309        ast::WaitForStmt * wfs;
    309310        ast::Expr * constant;
     
    416417%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    417418%type<sn> selection_statement                   if_statement
    418 %type<sn> switch_clause_list_opt                switch_clause_list
     419%type<clause> switch_clause_list_opt            switch_clause_list
    419420%type<en> case_value
    420 %type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
     421%type<clause> case_clause                               case_value_list                         case_label                                      case_label_list
    421422%type<sn> iteration_statement                   jump_statement
    422423%type<sn> expression_statement                  asm_statement
    423424%type<sn> with_statement
    424425%type<en> with_clause_opt
    425 %type<sn> exception_statement                   handler_clause                          finally_clause
     426%type<sn> exception_statement
     427%type<clause> handler_clause                    finally_clause
    426428%type<catch_kind> handler_key
    427429%type<sn> mutex_statement
     
    12611263
    12621264case_value_list:                                                                                // CFA
    1263         case_value                                                                      { $$ = new StatementNode( build_case( $1 ) ); }
     1265        case_value                                                                      { $$ = new ClauseNode( build_case( yylloc, $1 ) ); }
    12641266                // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5"
    1265         | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); }
     1267        | case_value_list ',' case_value                        { $$ = $1->set_last( new ClauseNode( build_case( yylloc, $3 ) ) ); }
    12661268        ;
    12671269
     
    12721274        | CASE case_value_list error                                            // syntax error
    12731275                { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; }
    1274         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default( yylloc ) ); }
     1276        | DEFAULT ':'                                                           { $$ = new ClauseNode( build_default( yylloc ) ); }
    12751277                // A semantic check is required to ensure only one default clause per switch/choose statement.
    12761278        | DEFAULT error                                                                         //  syntax error
     
    12801282case_label_list:                                                                                // CFA
    12811283        case_label
    1282         | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_last( $2 )); }
     1284        | case_label_list case_label                            { $$ = $1->set_last( $2 ); }
    12831285        ;
    12841286
     
    12971299                { $$ = $1->append_last_case( new StatementNode( build_compound( yylloc, $2 ) ) ); }
    12981300        | switch_clause_list case_label_list statement_list_nodecl
    1299                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ) ); }
     1301                { $$ = $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ); }
    13001302        ;
    13011303
     
    17311733handler_clause:
    17321734        handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1733                 { $$ = new StatementNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
     1735                { $$ = new ClauseNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
    17341736        | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1735                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
     1737                { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
    17361738        ;
    17371739
     
    17501752
    17511753finally_clause:
    1752         FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( yylloc, $2 ) ); }
     1754        FINALLY compound_statement                                      { $$ = new ClauseNode( build_finally( yylloc, $2 ) ); }
    17531755        ;
    17541756
  • src/Parser/parserutility.h

    r9921573 r6611177  
    2424
    2525template< typename T >
    26 static inline auto maybeBuild( const T *orig ) -> decltype(orig->build()) {
     26static inline auto maybeBuild( T * orig ) -> decltype(orig->build()) {
    2727        return (orig) ? orig->build() : nullptr;
    2828}
    2929
    3030template< typename T >
    31 static inline auto maybeMoveBuild( const T *orig ) -> decltype(orig->build()) {
     31static inline auto maybeMoveBuild( T * orig ) -> decltype(orig->build()) {
    3232        auto ret = maybeBuild<T>(orig);
    3333        delete orig;
Note: See TracChangeset for help on using the changeset viewer.