Changes in / [b1848a0:6603c1d]


Ignore:
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    rb1848a0 r6603c1d  
    3434# generated by bison and lex from cfa.yy and lex.ll, respectively
    3535src/Parser/parser.output
    36 
    37 # generated by xfig for user manual
    38 doc/user/Cdecl.tex
    39 doc/user/pointer1.tex
    40 doc/user/pointer2.tex
  • src/Parser/DeclarationNode.cc

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:30:25 2016
    13 // Update Count     : 172
     12// Last Modified On : Sat Aug 13 18:56:58 2016
     13// Update Count     : 171
    1414//
    1515
  • src/Parser/ExpressionNode.cc

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:30:42 2016
    13 // Update Count     : 490
     12// Last Modified On : Thu Aug 11 20:24:36 2016
     13// Update Count     : 487
    1414//
    1515
     
    292292//##############################################################################
    293293
    294 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
     294Expression *build_asm( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
    295295        return new AsmExpr( maybeBuild< Expression >( inout ), constraint, maybeBuild<Expression>(operand) );
    296296}
     
    298298//##############################################################################
    299299
    300 //void LabelNode::print( std::ostream &os, int indent ) const {}
    301 
    302 //void LabelNode::printOneLine( std::ostream &os, int indent ) const {}
     300void LabelNode::print( std::ostream &os, int indent ) const {}
     301
     302void LabelNode::printOneLine( std::ostream &os, int indent ) const {}
    303303
    304304//##############################################################################
  • src/Parser/ParseNode.cc

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 13:26:29 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:49:06 2016
    13 // Update Count     : 99
     12// Last Modified On : Sat Aug 13 18:55:35 2016
     13// Update Count     : 98
    1414//
    1515
     
    5252}
    5353
     54ParseNode &ParseNode::operator,( ParseNode &p ) {
     55        set_last( &p );
     56        return *this;
     57}
     58
     59ParseNode *mkList( ParseNode &pn ) {
     60        // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking
     61        // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))
     62        // (although "nice" is probably not the word)
     63        return &pn;
     64}
     65
    5466// Local Variables: //
    5567// tab-width: 4 //
  • src/Parser/ParseNode.h

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:52:12 2016
    13 // Update Count     : 512
     12// Last Modified On : Sun Aug 14 16:29:20 2016
     13// Update Count     : 483
    1414//
    1515
     
    6464        ParseNode *next;
    6565};
     66
     67ParseNode *mkList( ParseNode & );
    6668
    6769//##############################################################################
     
    131133};
    132134
     135//##############################################################################
     136
     137Expression *build_constantInteger( std::string &str );
     138Expression *build_constantFloat( std::string &str );
     139Expression *build_constantChar( std::string &str );
     140ConstantExpr *build_constantStr( std::string &str );
     141
     142//##############################################################################
     143
     144NameExpr *build_varref( const std::string *name, bool labelp = false );
     145
     146//##############################################################################
     147
     148Expression *build_typevalue( DeclarationNode *decl );
     149
     150//##############################################################################
     151
    133152enum class OperKinds {
    134153        // diadic
     
    141160        Ctor, Dtor,
    142161};
    143 
    144 struct LabelNode {
    145         std::list< Label > labels;
    146 };
    147 
    148 Expression *build_constantInteger( std::string &str );
    149 Expression *build_constantFloat( std::string &str );
    150 Expression *build_constantChar( std::string &str );
    151 ConstantExpr *build_constantStr( std::string &str );
    152 
    153 NameExpr *build_varref( const std::string *name, bool labelp = false );
    154 Expression *build_typevalue( DeclarationNode *decl );
    155162
    156163Expression *build_cast( DeclarationNode * decl_node, ExpressionNode *expr_node );
     
    176183Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node );
    177184Expression *build_range( ExpressionNode * low, ExpressionNode *high );
    178 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand );
     185
     186//##############################################################################
     187
     188Expression *build_asm( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand );
     189
     190//##############################################################################
     191
     192class LabelNode : public ExpressionNode {
     193  public:
     194        virtual Expression *build() const { return NULL; }
     195        virtual LabelNode *clone() const { assert( false ); return new LabelNode( *this ); }
     196
     197        virtual void print( std::ostream &os, int indent = 0) const;
     198        virtual void printOneLine( std::ostream &os, int indent = 0) const;
     199
     200        const std::list< Label > &get_labels() const { return labels; };
     201        void append_label( std::string * label ) { labels.push_back( *label ); delete label; }
     202  private:
     203        std::list< Label > labels;
     204};
     205
     206//##############################################################################
     207
    179208Expression *build_valexpr( StatementNode *s );
     209
     210//##############################################################################
     211
    180212Expression *build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids );
    181213
     
    243275        DeclarationNode *addNewArray( DeclarationNode *array );
    244276        DeclarationNode *addParamList( DeclarationNode *list );
    245         DeclarationNode *addIdList( DeclarationNode *list ); // old-style functions
     277        DeclarationNode *addIdList( DeclarationNode *list );       // old-style functions
    246278        DeclarationNode *addInitializer( InitializerNode *init );
    247279
     
    296328class StatementNode : public ParseNode {
    297329  public:
    298         StatementNode() { stmt = nullptr; }
    299         StatementNode( Statement *stmt ) : stmt( stmt ) {}
     330        enum Type { Exp,   If,        Switch,  Case,    Default,  Choose,   Fallthru,
     331                                While, Do,        For,
     332                                Goto,  Continue,  Break,   Return,  Throw,
     333                                Try,   Catch,     Finally, Asm,
     334                                Decl
     335        };
     336
     337        StatementNode();
    300338        StatementNode( DeclarationNode *decl );
    301         virtual ~StatementNode() {}
    302 
    303         virtual StatementNode *clone() const { assert( false ); return nullptr; }
     339        ~StatementNode();
     340
     341        StatementNode::Type get_type() const { return type; }
     342
     343        virtual StatementNode *add_label( const std::string * );
     344        virtual std::list<std::string> get_labels() const { return labels; }
     345
     346        void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
     347
     348        virtual StatementNode *append_last_case( StatementNode * );
     349
     350        virtual void print( std::ostream &os, int indent = 0) const {}
     351        virtual StatementNode *clone() const;
     352        virtual Statement *build() const;
     353  public:
     354        static const char *StType[];
     355        Type type;
     356        std::list<std::string> labels;
     357        DeclarationNode *decl;
     358}; // StatementNode
     359
     360class StatementNode2 : public StatementNode {
     361  public:
     362        StatementNode2() { stmt = nullptr; }
     363        StatementNode2( Statement *stmt ) : stmt( stmt ) {}
     364        StatementNode2( DeclarationNode *decl );
     365        virtual ~StatementNode2() {}
     366
     367        virtual StatementNode2 *clone() const { assert( false ); return nullptr; }
    304368        virtual Statement *build() const { return stmt; }
    305369
    306         virtual StatementNode *add_label( const std::string * name ) {
     370        virtual StatementNode2 *add_label( const std::string * name ) {
    307371                stmt->get_labels().emplace_back( *name );
    308372                return this;
    309373        }
     374        virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); }
    310375
    311376        virtual StatementNode *append_last_case( StatementNode * );
     
    321386struct ForCtl {
    322387        ForCtl( ExpressionNode *expr, ExpressionNode *condition, ExpressionNode *change ) :
    323                 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
     388                init( new StatementNode2( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    324389        ForCtl( DeclarationNode *decl, ExpressionNode *condition, ExpressionNode *change ) :
    325                 init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
     390                init( new StatementNode2( decl ) ), condition( condition ), change( change ) {}
    326391
    327392        StatementNode *init;
     
    343408Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny = false );
    344409Statement *build_finally( StatementNode *stmt );
    345 Statement *build_compound( StatementNode *first );
    346 Statement *build_asmstmt( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 );
     410
     411//##############################################################################
     412
     413class CompoundStmtNode : public StatementNode {
     414  public:
     415        CompoundStmtNode();
     416        CompoundStmtNode( StatementNode * );
     417        ~CompoundStmtNode();
     418
     419        void add_statement( StatementNode * );
     420
     421        void print( std::ostream &os, int indent = 0 ) const;
     422        virtual Statement *build() const;
     423  private:
     424        StatementNode *first, *last;
     425};
     426
     427//##############################################################################
     428
     429class AsmStmtNode : public StatementNode {
     430  public:
     431        AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 );
     432        ~AsmStmtNode();
     433
     434        void print( std::ostream &os, int indent = 0 ) const {}
     435        Statement *build() const;
     436  private:
     437        bool voltile;
     438        ConstantExpr *instruction;
     439        ExpressionNode *output, *input;
     440        ExpressionNode *clobber;
     441        std::list< Label > gotolabels;
     442};
    347443
    348444//##############################################################################
  • src/Parser/StatementNode.cc

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:40:05 2016
    13 // Update Count     : 317
     12// Last Modified On : Sun Aug 14 13:10:54 2016
     13// Update Count     : 288
    1414//
    1515
     
    2626using namespace std;
    2727
    28 
    29 StatementNode::StatementNode( DeclarationNode *decl ) {
     28const char *StatementNode::StType[] = {
     29        "Exp",   "If",       "Switch", "Case",    "Default",  "Choose",   "Fallthru",
     30        "While", "Do",       "For",
     31        "Goto",  "Continue", "Break",  "Return",  "Throw",
     32        "Try",   "Catch",    "Finally", "Asm",
     33        "Decl"
     34};
     35
     36StatementNode::StatementNode() : ParseNode(), labels( 0 ), decl( 0 ) {}
     37
     38StatementNode::StatementNode( DeclarationNode *decl ) : type( Decl ), labels( 0 ) {
     39        assert( false );
    3040        if ( decl ) {
    31                 DeclarationNode *agg = decl->extractAggregate();
    32                 if ( agg ) {
    33                         StatementNode *nextStmt = new StatementNode( new DeclStmt( noLabels, maybeBuild< Declaration >( decl ) ) );
     41                if ( DeclarationNode *agg = decl->extractAggregate() ) {
     42                        this->decl = agg;
     43                        StatementNode *nextStmt = new StatementNode;
     44                        nextStmt->type = Decl;
     45                        nextStmt->decl = decl;
    3446                        next = nextStmt;
    3547                        if ( decl->get_next() ) {
    36                                 next->set_next( new StatementNode( dynamic_cast<DeclarationNode *>(decl->get_next()) ) );
     48                                next->set_next( new StatementNode( dynamic_cast<DeclarationNode *>( decl->get_next() ) ) );
    3749                                decl->set_next( 0 );
    3850                        } // if
     
    4254                                decl->set_next( 0 );
    4355                        } // if
     56                        this->decl = decl;
     57                } // if
     58        } // if
     59}
     60
     61StatementNode2::StatementNode2( DeclarationNode *decl ) {
     62        if ( decl ) {
     63                DeclarationNode *agg = decl->extractAggregate();
     64                if ( agg ) {
     65                        StatementNode *nextStmt = new StatementNode;
     66                        nextStmt->type = Decl;
     67                        nextStmt->decl = decl;
     68                        next = nextStmt;
     69                        if ( decl->get_next() ) {
     70                                next->set_next( new StatementNode2( dynamic_cast<DeclarationNode *>(decl->get_next()) ) );
     71                                decl->set_next( 0 );
     72                        } // if
     73                } else {
     74                        if ( decl->get_next() ) {
     75                                next = new StatementNode2( dynamic_cast<DeclarationNode *>( decl->get_next() ) );
     76                                decl->set_next( 0 );
     77                        } // if
    4478                        agg = decl;
    4579                } // if
     
    5084}
    5185
     86StatementNode::~StatementNode() {
     87        delete decl;
     88}
     89
     90StatementNode * StatementNode::clone() const {
     91        assert( false );
     92        return 0;
     93}
     94
     95StatementNode *StatementNode::add_label( const std::string *l ) {
     96        if ( l != 0 ) {
     97                labels.push_front( *l );
     98                delete l;
     99        } // if
     100        return this;
     101}
     102
    52103StatementNode *StatementNode::append_last_case( StatementNode *stmt ) {
     104        assert( false );
     105        return this;
     106}
     107
     108StatementNode *StatementNode2::append_last_case( StatementNode *stmt ) {
    53109        StatementNode *prev = this;
    54110        // find end of list and maintain previous pointer
    55111        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    56                 StatementNode *node = dynamic_cast<StatementNode *>(curr);
     112                StatementNode2 *node = dynamic_cast<StatementNode2 *>(curr);
    57113                assert( node );
    58114                assert( dynamic_cast<CaseStmt *>(node->stmt) );
    59115                prev = curr;
    60116        } // for
    61         // convert from StatementNode list to Statement list
    62         StatementNode *node = dynamic_cast<StatementNode *>(prev);
     117        // conver from StatementNode list to Statement list
     118        StatementNode2 *node = dynamic_cast<StatementNode2 *>(prev);
    63119        std::list<Statement *> stmts;
    64120        buildList( stmt, stmts );
    65         // splice any new Statements to end of current Statements
     121        // splice any new Statements to end of currents Statements
    66122        CaseStmt * caseStmt = dynamic_cast<CaseStmt *>(node->stmt);
    67123        caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts );
    68124        return this;
     125}
     126
     127Statement *StatementNode::build() const {
     128        switch ( type ) {
     129          case Decl:
     130                return new DeclStmt( noLabels, maybeBuild< Declaration >( decl ) );
     131                assert( false );
     132          case Exp:
     133          case If:
     134          case Switch:
     135          case Case:
     136          case Default:
     137          case While:
     138          case Do:
     139          case For:
     140          case Goto:
     141          case Break:
     142          case Continue:
     143          case Return:
     144          case Throw :
     145          case Try:
     146          case Catch:
     147          case Finally:
     148          case Asm:
     149          default:
     150                assert( false );
     151                return 0;
     152        } // switch
    69153}
    70154
     
    177261}
    178262
    179 Statement *build_compound( StatementNode *first ) {
    180         CompoundStmt *cs = new CompoundStmt( noLabels );
     263
     264CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) {}
     265
     266CompoundStmtNode::CompoundStmtNode( StatementNode *stmt ) : first( stmt ) {
     267        if ( first ) {
     268                last = ( StatementNode *)( stmt->get_last());
     269        } else {
     270                last = 0;
     271        } // if
     272}
     273
     274CompoundStmtNode::~CompoundStmtNode() {
     275        delete first;
     276}
     277
     278void CompoundStmtNode::add_statement( StatementNode *stmt ) {
     279        if ( stmt != 0 ) {
     280                last->set_last( stmt );
     281                last = ( StatementNode *)( stmt->get_next());
     282        } // if
     283}
     284
     285void CompoundStmtNode::print( ostream &os, int indent ) const {
     286        if ( first ) {
     287                first->printList( os, indent+2 );
     288        } // if
     289}
     290
     291Statement *CompoundStmtNode::build() const {
     292        std::list<Label> labs;
     293        const std::list<std::string> &labels = get_labels();
     294
     295        if ( ! labels.empty() ) {
     296                std::back_insert_iterator< std::list<Label> > lab_it( labs );
     297                copy( labels.begin(), labels.end(), lab_it );
     298        } // if
     299
     300        CompoundStmt *cs = new CompoundStmt( labs );
    181301        buildList( first, cs->get_kids() );
    182302        return cs;
    183303}
    184304
    185 Statement *build_asmstmt( bool voltile, ConstantExpr *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) {
     305
     306AsmStmtNode::AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) :
     307        voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ) {
     308        type = Asm;
     309        if ( gotolabels ) {
     310                this->gotolabels = gotolabels->get_labels();
     311                delete gotolabels;
     312        } // if
     313}
     314
     315AsmStmtNode::~AsmStmtNode() {
     316        delete output; delete input; delete clobber;
     317}
     318
     319Statement *AsmStmtNode::build() const {
     320        std::list<Label> labs;
     321
     322        if ( ! get_labels().empty() ) {
     323                std::back_insert_iterator< std::list<Label> > lab_it( labs );
     324                copy( get_labels().begin(), get_labels().end(), lab_it );
     325        } // if
     326
    186327        std::list< Expression * > out, in;
    187328        std::list< ConstantExpr * > clob;
    188 
    189329        buildList( output, out );
    190330        buildList( input, in );
    191331        buildList( clobber, clob );
    192         return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
    193 }
     332        std::list< Label > gotolabs = gotolabels;
     333        return new AsmStmt( labs, voltile, instruction, out, in, clob, gotolabs );
     334}
     335
     336// Statement *build_asm( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ) {
     337//      std::list<Label> labs;
     338
     339//      if ( ! get_labels().empty() ) {
     340//              std::back_insert_iterator< std::list<Label> > lab_it( labs );
     341//              copy( get_labels().begin(), get_labels().end(), lab_it );
     342//      } // if
     343
     344//      std::list< Expression * > out, in;
     345//      std::list< ConstantExpr * > clob;
     346//      buildList( output, out );
     347//      buildList( input, in );
     348//      buildList( clobber, clob );
     349//      std::list< Label > gotolabs = gotolabels;
     350//      return new AsmStmt( labs, voltile, instruction, out, in, clob, gotolabs );
     351// }
    194352
    195353// Local Variables: //
  • src/Parser/TypeData.h

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 14:28:32 2016
    13 // Update Count     : 21
     12// Last Modified On : Tue Jul 12 20:52:02 2016
     13// Update Count     : 20
    1414//
    1515
  • src/Parser/parser.cc

    rb1848a0 r6603c1d  
    56385638                        Token fn;
    56395639                        fn.str = new std::string( "^?{}" ); // location undefined
    5640                         (yyval.sn) = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(2) - (6)].en) )->set_last( (yyvsp[(4) - (6)].en) ) ) ) ) );
     5640                        (yyval.sn) = new StatementNode2( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(2) - (6)].en) )->set_last( (yyvsp[(4) - (6)].en) ) ) ) ) );
    56415641                }
    56425642    break;
     
    56555655/* Line 1806 of yacc.c  */
    56565656#line 680 "parser.yy"
    5657     { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     5657    { (yyval.sn) = new CompoundStmtNode( (StatementNode *)0 ); }
    56585658    break;
    56595659
     
    56625662/* Line 1806 of yacc.c  */
    56635663#line 687 "parser.yy"
    5664     { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); }
     5664    { (yyval.sn) = new CompoundStmtNode( (yyvsp[(5) - (7)].sn) ); }
    56655665    break;
    56665666
     
    56765676/* Line 1806 of yacc.c  */
    56775677#line 698 "parser.yy"
    5678     { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
     5678    { (yyval.sn) = new StatementNode2( (yyvsp[(1) - (1)].decl) ); }
    56795679    break;
    56805680
     
    56865686                        for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != NULL; iter = (DeclarationNode *)iter->get_next() )
    56875687                                iter->set_extension( true );
    5688                         (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) );
     5688                        (yyval.sn) = new StatementNode2( (yyvsp[(2) - (2)].decl) );
    56895689                }
    56905690    break;
     
    56945694/* Line 1806 of yacc.c  */
    56955695#line 706 "parser.yy"
    5696     { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); }
     5696    { (yyval.sn) = new StatementNode2( (yyvsp[(1) - (1)].decl) ); }
    56975697    break;
    56985698
     
    57085708/* Line 1806 of yacc.c  */
    57095709#line 718 "parser.yy"
    5710     { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); }
     5710    { (yyval.sn) = new StatementNode2( build_expr( (yyvsp[(1) - (2)].en) ) ); }
    57115711    break;
    57125712
     
    57155715/* Line 1806 of yacc.c  */
    57165716#line 724 "parser.yy"
    5717     { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }
     5717    { (yyval.sn) = new StatementNode2( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }
    57185718    break;
    57195719
     
    57225722/* Line 1806 of yacc.c  */
    57235723#line 726 "parser.yy"
    5724     { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }
     5724    { (yyval.sn) = new StatementNode2( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }
    57255725    break;
    57265726
     
    57295729/* Line 1806 of yacc.c  */
    57305730#line 728 "parser.yy"
    5731     { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
     5731    { (yyval.sn) = new StatementNode2( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57325732    break;
    57335733
     
    57375737#line 730 "parser.yy"
    57385738    {
    5739                         StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     5739                        StatementNode *sw = new StatementNode2( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
    57405740                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    57415741                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    57435743                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    57445744                        // statement.
    5745                         (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) ) : sw;
     5745                        (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) : sw;
    57465746                }
    57475747    break;
     
    57515751/* Line 1806 of yacc.c  */
    57525752#line 740 "parser.yy"
    5753     { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
     5753    { (yyval.sn) = new StatementNode2( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    57545754    break;
    57555755
     
    57595759#line 742 "parser.yy"
    57605760    {
    5761                         StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
    5762                         (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) ) : sw;
     5761                        StatementNode *sw = new StatementNode2( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );
     5762                        (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) : sw;
    57635763                }
    57645764    break;
     
    57825782/* Line 1806 of yacc.c  */
    57835783#line 759 "parser.yy"
    5784     { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); }
     5784    { (yyval.sn) = new StatementNode2( build_case( (yyvsp[(1) - (1)].en) ) ); }
    57855785    break;
    57865786
     
    57895789/* Line 1806 of yacc.c  */
    57905790#line 761 "parser.yy"
    5791     { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }
     5791    { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode2( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }
    57925792    break;
    57935793
     
    58035803/* Line 1806 of yacc.c  */
    58045804#line 766 "parser.yy"
    5805     { (yyval.sn) = new StatementNode( build_default() ); }
     5805    { (yyval.sn) = new StatementNode2( build_default() ); }
    58065806    break;
    58075807
     
    58175817/* Line 1806 of yacc.c  */
    58185818#line 776 "parser.yy"
    5819     { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
     5819    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); }
    58205820    break;
    58215821
     
    58315831/* Line 1806 of yacc.c  */
    58325832#line 787 "parser.yy"
    5833     { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); }
     5833    { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); }
    58345834    break;
    58355835
     
    58385838/* Line 1806 of yacc.c  */
    58395839#line 789 "parser.yy"
    5840     { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); }
     5840    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(3) - (3)].sn) ) ) ) ); }
    58415841    break;
    58425842
     
    58595859/* Line 1806 of yacc.c  */
    58605860#line 802 "parser.yy"
    5861     { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); }
     5861    { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(2) - (3)].sn), *(yyvsp[(3) - (3)].sn) ) ) ) ); }
    58625862    break;
    58635863
     
    58735873/* Line 1806 of yacc.c  */
    58745874#line 806 "parser.yy"
    5875     { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(3) - (4)].sn)->set_last( (yyvsp[(4) - (4)].sn) ) ) ) ) ) ); }
     5875    { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(3) - (4)].sn), *(yyvsp[(4) - (4)].sn) ) ) ) ) ) ); }
    58765876    break;
    58775877
     
    58805880/* Line 1806 of yacc.c  */
    58815881#line 811 "parser.yy"
    5882     { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Break ) ); }
     5882    { (yyval.sn) = new StatementNode2( build_branch( "", BranchStmt::Break ) ); }
    58835883    break;
    58845884
     
    59015901/* Line 1806 of yacc.c  */
    59025902#line 824 "parser.yy"
    5903     { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
     5903    { (yyval.sn) = new StatementNode2( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }
    59045904    break;
    59055905
     
    59085908/* Line 1806 of yacc.c  */
    59095909#line 826 "parser.yy"
    5910     { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ) ); }
     5910    { (yyval.sn) = new StatementNode2( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ) ); }
    59115911    break;
    59125912
     
    59155915/* Line 1806 of yacc.c  */
    59165916#line 828 "parser.yy"
    5917     { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }
     5917    { (yyval.sn) = new StatementNode2( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }
    59185918    break;
    59195919
     
    59365936/* Line 1806 of yacc.c  */
    59375937#line 840 "parser.yy"
    5938     { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }
     5938    { (yyval.sn) = new StatementNode2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }
    59395939    break;
    59405940
     
    59435943/* Line 1806 of yacc.c  */
    59445944#line 844 "parser.yy"
    5945     { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
     5945    { (yyval.sn) = new StatementNode2( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }
    59465946    break;
    59475947
     
    59505950/* Line 1806 of yacc.c  */
    59515951#line 847 "parser.yy"
    5952     { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Continue ) ); }
     5952    { (yyval.sn) = new StatementNode2( build_branch( "", BranchStmt::Continue ) ); }
    59535953    break;
    59545954
     
    59575957/* Line 1806 of yacc.c  */
    59585958#line 851 "parser.yy"
    5959     { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); delete (yyvsp[(2) - (3)].tok); }
     5959    { (yyval.sn) = new StatementNode2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); delete (yyvsp[(2) - (3)].tok); }
    59605960    break;
    59615961
     
    59645964/* Line 1806 of yacc.c  */
    59655965#line 854 "parser.yy"
    5966     { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Break ) ); }
     5966    { (yyval.sn) = new StatementNode2( build_branch( "", BranchStmt::Break ) ); }
    59675967    break;
    59685968
     
    59715971/* Line 1806 of yacc.c  */
    59725972#line 858 "parser.yy"
    5973     { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); delete (yyvsp[(2) - (3)].tok); }
     5973    { (yyval.sn) = new StatementNode2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); delete (yyvsp[(2) - (3)].tok); }
    59745974    break;
    59755975
     
    59785978/* Line 1806 of yacc.c  */
    59795979#line 860 "parser.yy"
    5980     { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); }
     5980    { (yyval.sn) = new StatementNode2( build_return( (yyvsp[(2) - (3)].en) ) ); }
    59815981    break;
    59825982
     
    59855985/* Line 1806 of yacc.c  */
    59865986#line 862 "parser.yy"
    5987     { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
     5987    { (yyval.sn) = new StatementNode2( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    59885988    break;
    59895989
     
    59925992/* Line 1806 of yacc.c  */
    59935993#line 864 "parser.yy"
    5994     { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); }
     5994    { (yyval.sn) = new StatementNode2( build_throw( (yyvsp[(2) - (3)].en) ) ); }
    59955995    break;
    59965996
     
    59995999/* Line 1806 of yacc.c  */
    60006000#line 866 "parser.yy"
    6001     { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); }
     6001    { (yyval.sn) = new StatementNode2( build_throw( (yyvsp[(2) - (5)].en) ) ); }
    60026002    break;
    60036003
     
    60066006/* Line 1806 of yacc.c  */
    60076007#line 871 "parser.yy"
    6008     { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }
     6008    { (yyval.sn) = new StatementNode2( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }
    60096009    break;
    60106010
     
    60136013/* Line 1806 of yacc.c  */
    60146014#line 873 "parser.yy"
    6015     { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }
     6015    { (yyval.sn) = new StatementNode2( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }
    60166016    break;
    60176017
     
    60206020/* Line 1806 of yacc.c  */
    60216021#line 875 "parser.yy"
    6022     { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }
     6022    { (yyval.sn) = new StatementNode2( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }
    60236023    break;
    60246024
     
    60276027/* Line 1806 of yacc.c  */
    60286028#line 882 "parser.yy"
    6029     { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
     6029    { (yyval.sn) = new StatementNode2( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60306030    break;
    60316031
     
    60346034/* Line 1806 of yacc.c  */
    60356035#line 884 "parser.yy"
    6036     { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
     6036    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode2( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60376037    break;
    60386038
     
    60416041/* Line 1806 of yacc.c  */
    60426042#line 886 "parser.yy"
    6043     { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
     6043    { (yyval.sn) = new StatementNode2( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }
    60446044    break;
    60456045
     
    60486048/* Line 1806 of yacc.c  */
    60496049#line 888 "parser.yy"
    6050     { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
     6050    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode2( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }
    60516051    break;
    60526052
     
    60556055/* Line 1806 of yacc.c  */
    60566056#line 893 "parser.yy"
    6057     { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
     6057    { (yyval.sn) = new StatementNode2( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60586058    break;
    60596059
     
    60626062/* Line 1806 of yacc.c  */
    60636063#line 895 "parser.yy"
    6064     { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
     6064    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode2( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    60656065    break;
    60666066
     
    60696069/* Line 1806 of yacc.c  */
    60706070#line 897 "parser.yy"
    6071     { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
     6071    { (yyval.sn) = new StatementNode2( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }
    60726072    break;
    60736073
     
    60766076/* Line 1806 of yacc.c  */
    60776077#line 899 "parser.yy"
    6078     { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
     6078    { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode2( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }
    60796079    break;
    60806080
     
    60846084#line 904 "parser.yy"
    60856085    {
    6086                         (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) );
     6086                        (yyval.sn) = new StatementNode2( build_finally( (yyvsp[(2) - (2)].sn) ) );
    60876087                }
    60886088    break;
     
    61196119/* Line 1806 of yacc.c  */
    61206120#line 933 "parser.yy"
    6121     { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); }
     6121    { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ); }
    61226122    break;
    61236123
     
    61266126/* Line 1806 of yacc.c  */
    61276127#line 935 "parser.yy"
    6128     { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); }
     6128    { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ); }
    61296129    break;
    61306130
     
    61336133/* Line 1806 of yacc.c  */
    61346134#line 937 "parser.yy"
    6135     { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); }
     6135    { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ); }
    61366136    break;
    61376137
     
    61406140/* Line 1806 of yacc.c  */
    61416141#line 939 "parser.yy"
    6142     { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ) ); }
     6142    { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ); }
    61436143    break;
    61446144
     
    61476147/* Line 1806 of yacc.c  */
    61486148#line 941 "parser.yy"
    6149     { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ) ); }
     6149    { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ); }
    61506150    break;
    61516151
     
    61826182/* Line 1806 of yacc.c  */
    61836183#line 965 "parser.yy"
    6184     { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }
     6184    { (yyval.en) = new ExpressionNode( build_asm( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }
    61856185    break;
    61866186
     
    61896189/* Line 1806 of yacc.c  */
    61906190#line 967 "parser.yy"
    6191     { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }
     6191    { (yyval.en) = new ExpressionNode( build_asm( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }
    61926192    break;
    61936193
     
    62176217/* Line 1806 of yacc.c  */
    62186218#line 981 "parser.yy"
    6219     { (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) ); }
     6219    { (yyval.label) = new LabelNode(); (yyval.label)->append_label( (yyvsp[(1) - (1)].tok) ); }
    62206220    break;
    62216221
     
    62246224/* Line 1806 of yacc.c  */
    62256225#line 983 "parser.yy"
    6226     { (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) ); }
     6226    { (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->append_label( (yyvsp[(3) - (3)].tok) ); }
    62276227    break;
    62286228
  • src/Parser/parser.yy

    rb1848a0 r6603c1d  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 15:18:19 2016
    13 // Update Count     : 1891
     12// Last Modified On : Sun Aug 14 11:03:22 2016
     13// Update Count     : 1879
    1414//
    1515
     
    664664                        Token fn;
    665665                        fn.str = new std::string( "^?{}" ); // location undefined
    666                         $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
     666                        $$ = new StatementNode2( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    667667                }
    668668        ;
     
    678678compound_statement:
    679679        '{' '}'
    680                 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     680                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    681681        | '{'
    682682                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     
    685685          local_label_declaration_opt                                           // GCC, local labels
    686686          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    687                 { $$ = new StatementNode( build_compound( $5 ) ); }
     687                { $$ = new CompoundStmtNode( $5 ); }
    688688        ;
    689689
     
    696696block_item:
    697697        declaration                                                                                     // CFA, new & old style declarations
    698                 { $$ = new StatementNode( $1 ); }
     698                { $$ = new StatementNode2( $1 ); }
    699699        | EXTENSION declaration                                                         // GCC
    700700                {       // mark all fields in list
    701701                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )
    702702                                iter->set_extension( true );
    703                         $$ = new StatementNode( $2 );
     703                        $$ = new StatementNode2( $2 );
    704704                }
    705705        | function_definition
    706                 { $$ = new StatementNode( $1 ); }
     706                { $$ = new StatementNode2( $1 ); }
    707707        | statement pop
    708708        ;
     
    716716expression_statement:
    717717        comma_expression_opt ';'
    718                 { $$ = new StatementNode( build_expr( $1 ) ); }
     718                { $$ = new StatementNode2( build_expr( $1 ) ); }
    719719        ;
    720720
     
    722722        IF '(' comma_expression ')' statement                           %prec THEN
    723723                // explicitly deal with the shift/reduce conflict on if/else
    724                 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
     724                { $$ = new StatementNode2( build_if( $3, $5, nullptr ) ); }
    725725        | IF '(' comma_expression ')' statement ELSE statement
    726                 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
     726                { $$ = new StatementNode2( build_if( $3, $5, $7 ) ); }
    727727        | SWITCH '(' comma_expression ')' case_clause           // CFA
    728                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     728                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    729729        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    730730                {
    731                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     731                        StatementNode *sw = new StatementNode2( build_switch( $3, $8 ) );
    732732                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    733733                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    735735                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    736736                        // statement.
    737                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     737                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( $7 ))->set_last( sw )) ) : sw;
    738738                }
    739739        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    740                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     740                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    741741        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    742742                {
    743                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    744                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     743                        StatementNode *sw = new StatementNode2( build_switch( $3, $8 ) );
     744                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( $7 ))->set_last( sw )) ) : sw;
    745745                }
    746746        ;
     
    757757
    758758case_value_list:                                                                                // CFA
    759         case_value                                                                      { $$ = new StatementNode( build_case( $1 ) ); }
     759        case_value                                                                      { $$ = new StatementNode2( build_case( $1 ) ); }
    760760                // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5"
    761         | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); }
     761        | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_last( new StatementNode2( build_case( $3 ) ) ) ); }
    762762        ;
    763763
    764764case_label:                                                                                             // CFA
    765765        CASE case_value_list ':'                                        { $$ = $2; }
    766         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
     766        | DEFAULT ':'                                                           { $$ = new StatementNode2( build_default() ); }
    767767                // A semantic check is required to ensure only one default clause per switch/choose statement.
    768768        ;
     
    774774
    775775case_clause:                                                                                    // CFA
    776         case_label_list statement                                       { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     776        case_label_list statement                                       { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    777777        ;
    778778
     
    785785switch_clause_list:                                                                             // CFA
    786786        case_label_list statement_list
    787                 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     787                { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    788788        | switch_clause_list case_label_list statement_list
    789                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     789                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); }
    790790        ;
    791791
     
    800800                { $$ = $1->append_last_case( $2 ); }
    801801        | case_label_list statement_list fall_through_opt
    802                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
     802                { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }
    803803        | choose_clause_list case_label_list fall_through
    804804                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    805805        | choose_clause_list case_label_list statement_list fall_through_opt
    806                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
     806                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }
    807807        ;
    808808
    809809fall_through_opt:                                                                               // CFA
    810810        // empty
    811                 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break
     811                { $$ = new StatementNode2( build_branch( "", BranchStmt::Break ) ); } // insert implicit break
    812812        | fall_through
    813813        ;
     
    822822iteration_statement:
    823823        WHILE '(' comma_expression ')' statement
    824                 { $$ = new StatementNode( build_while( $3, $5 ) ); }
     824                { $$ = new StatementNode2( build_while( $3, $5 ) ); }
    825825        | DO statement WHILE '(' comma_expression ')' ';'
    826                 { $$ = new StatementNode( build_while( $5, $2 ) ); }
     826                { $$ = new StatementNode2( build_while( $5, $2 ) ); }
    827827        | FOR '(' push for_control_expression ')' statement
    828                 { $$ = new StatementNode( build_for( $4, $6 ) ); }
     828                { $$ = new StatementNode2( build_for( $4, $6 ) ); }
    829829        ;
    830830
     
    838838jump_statement:
    839839        GOTO IDENTIFIER ';'
    840                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Goto ) ); }
     840                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Goto ) ); }
    841841        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    842842                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
    843843                // whereas normal operator precedence yields goto (*i)+3;
    844                 { $$ = new StatementNode( build_computedgoto( $3 ) ); }
     844                { $$ = new StatementNode2( build_computedgoto( $3 ) ); }
    845845        | CONTINUE ';'
    846846                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    847                 { $$ = new StatementNode( build_branch( "", BranchStmt::Continue ) ); }
     847                { $$ = new StatementNode2( build_branch( "", BranchStmt::Continue ) ); }
    848848        | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
    849849                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    850850                // the target of the transfer appears only at the start of an iteration statement.
    851                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Continue ) ); delete $2; }
     851                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Continue ) ); delete $2; }
    852852        | BREAK ';'
    853853                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    854                 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); }
     854                { $$ = new StatementNode2( build_branch( "", BranchStmt::Break ) ); }
    855855        | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
    856856                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    857857                // the target of the transfer appears only at the start of an iteration statement.
    858                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Break ) ); delete $2; }
     858                { $$ = new StatementNode2( build_branch( *$2, BranchStmt::Break ) ); delete $2; }
    859859        | RETURN comma_expression_opt ';'
    860                 { $$ = new StatementNode( build_return( $2 ) ); }
     860                { $$ = new StatementNode2( build_return( $2 ) ); }
    861861        | THROW assignment_expression_opt ';'                           // handles rethrow
    862                 { $$ = new StatementNode( build_throw( $2 ) ); }
     862                { $$ = new StatementNode2( build_throw( $2 ) ); }
    863863        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
    864                 { $$ = new StatementNode( build_throw( $2 ) ); }
     864                { $$ = new StatementNode2( build_throw( $2 ) ); }
    865865        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    866                 { $$ = new StatementNode( build_throw( $2 ) ); }
     866                { $$ = new StatementNode2( build_throw( $2 ) ); }
    867867        ;
    868868
    869869exception_statement:
    870870        TRY compound_statement handler_list
    871                 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
     871                { $$ = new StatementNode2( build_try( $2, $3, 0 ) ); }
    872872        | TRY compound_statement finally_clause
    873                 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
     873                { $$ = new StatementNode2( build_try( $2, 0, $3 ) ); }
    874874        | TRY compound_statement handler_list finally_clause
    875                 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
     875                { $$ = new StatementNode2( build_try( $2, $3, $4 ) ); }
    876876        ;
    877877
     
    880880                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    881881        | CATCH '(' ELLIPSIS ')' compound_statement
    882                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     882                { $$ = new StatementNode2( build_catch( 0, $5, true ) ); }
    883883        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    884                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     884                { $$ = (StatementNode *)$1->set_last( new StatementNode2( build_catch( 0, $6, true ) ) ); }
    885885        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    886                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     886                { $$ = new StatementNode2( build_catch( 0, $5, true ) ); }
    887887        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    888                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     888                { $$ = (StatementNode *)$1->set_last( new StatementNode2( build_catch( 0, $6, true ) ) ); }
    889889        ;
    890890
    891891handler_clause:
    892892        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    893                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     893                { $$ = new StatementNode2( build_catch( $5, $8 ) ); }
    894894        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    895         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     895        { $$ = (StatementNode *)$1->set_last( new StatementNode2( build_catch( $6, $9 ) ) ); }
    896896        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    897                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     897                { $$ = new StatementNode2( build_catch( $5, $8 ) ); }
    898898        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    899                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     899                { $$ = (StatementNode *)$1->set_last( new StatementNode2( build_catch( $6, $9 ) ) ); }
    900900        ;
    901901
     
    903903        FINALLY compound_statement
    904904                {
    905                         $$ = new StatementNode( build_finally( $2 ) );
     905                        $$ = new StatementNode2( build_finally( $2 ) );
    906906                }
    907907        ;
     
    931931asm_statement:
    932932        ASM asm_volatile_opt '(' string_literal_list ')' ';'
    933                 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); }
     933                { $$ = new AsmStmtNode( $2, $4, 0 ); }
    934934        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
    935                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); }
     935                { $$ = new AsmStmtNode( $2, $4, $6 ); }
    936936        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    937                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); }
     937                { $$ = new AsmStmtNode( $2, $4, $6, $8 ); }
    938938        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    939                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); }
     939                { $$ = new AsmStmtNode( $2, $4, $6, $8, $10 ); }
    940940        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    941                 { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); }
     941                { $$ = new AsmStmtNode( $2, $5, 0, $8, $10, $12 ); }
    942942        ;
    943943
     
    963963asm_operand:                                                                                    // GCC
    964964        string_literal_list '(' constant_expression ')'
    965                 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
     965                { $$ = new ExpressionNode( build_asm( 0, $1, $3 ) ); }
    966966        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
    967         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     967        { $$ = new ExpressionNode( build_asm( $2, $4, $6 ) ); }
    968968        ;
    969969
     
    974974                { $$ = new ExpressionNode( $1 ); }
    975975        | asm_clobbers_list_opt ',' string_literal_list
    976                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     976        { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    977977        ;
    978978
    979979label_list:
    980980        no_attr_identifier
    981                 { $$ = new LabelNode(); $$->labels.push_back( *$1 ); }
     981                { $$ = new LabelNode(); $$->append_label( $1 ); }
    982982        | label_list ',' no_attr_identifier
    983                 { $$ = $1; $1->labels.push_back( *$3 ); }
     983                { $$ = $1; $1->append_label( $3 ); }
    984984        ;
    985985
  • src/Parser/parseutility.cc

    rb1848a0 r6603c1d  
    1010// Created On       : Sat May 16 15:30:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 14 23:45:03 2016
    13 // Update Count     : 3
     12// Last Modified On : Sat May 16 15:31:33 2015
     13// Update Count     : 2
    1414//
    1515
     
    1717#include "SynTree/Type.h"
    1818#include "SynTree/Expression.h"
    19 
    20 // rewrite
    21 //    if ( x ) ...
    22 // as
    23 //    if ( (int)(x != 0) ) ...
    2419
    2520Expression *notZeroExpr( Expression *orig ) {
  • src/tests/.expect/64/gccExtensions.txt

    rb1848a0 r6603c1d  
    1717    asm volatile ( "mov %1, %0\n\tadd $1, %0" : "=r" ( __dst__i_2 ) : "r" ( __src__i_2 ) :  );
    1818    asm ( "mov %1, %0\n\tadd $1, %0" : "=r" ( __dst__i_2 ), "=r" ( __src__i_2 ) : [ __src__i_2 ] "r" ( __dst__i_2 ) : "r0" );
    19     L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( __src__i_2 ), "r" ( (&__dst__i_2) ) : "r5", "memory" : L1, L2 );
    2019    double _Complex __c1__Xd_2;
    2120    double _Complex __c2__Xd_2;
  • src/tests/Makefile.am

    rb1848a0 r6603c1d  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Aug 15 12:24:54 2016
    14 ## Update Count     : 39
     13## Last Modified On : Tue Aug  9 15:34:57 2016
     14## Update Count     : 38
    1515###############################################################################
    1616
     
    2727
    2828all-local :
    29         @+python test.py vector_test avl_test operators numericConstants expression enum array typeof cast dtor-early-exit init_once
     29        @+python test.py vector_test avl_test operators numericConstants expression enum asmName array typeof cast dtor-early-exit init_once
    3030
    3131all-tests :
  • src/tests/Makefile.in

    rb1848a0 r6603c1d  
    635635
    636636all-local :
    637         @+python test.py vector_test avl_test operators numericConstants expression enum array typeof cast dtor-early-exit init_once
     637        @+python test.py vector_test avl_test operators numericConstants expression enum asmName array typeof cast dtor-early-exit init_once
    638638
    639639all-tests :
  • src/tests/gccExtensions.c

    rb1848a0 r6603c1d  
    1010// Created On       : Sun Aug 14 17:28:17 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 12:44:35 2016
    13 // Update Count     : 5
     12// Last Modified On : Sun Aug 14 17:36:28 2016
     13// Update Count     : 3
    1414//
    1515
     
    4444                  : [src] "r" (dst)
    4545                  : "r0");
    46 
     46#if 0
    4747  L1: L2:
    4848        asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
     
    5151                           : "r5", "memory"
    5252                           : L1, L2 );
    53 
     53#endif
    5454        __complex__ c1;
    5555        _Complex c2;
Note: See TracChangeset for help on using the changeset viewer.