Ignore:
Timestamp:
Aug 10, 2016, 2:02:10 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
321f55d, a563f01
Parents:
a6dd5b0
Message:

more refactoring of parser code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    ra6dd5b0 r2f22cc4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug  9 12:59:11 2016
    13 // Update Count     : 1821
     12// Last Modified On : Wed Aug 10 13:09:53 2016
     13// Update Count     : 1844
    1414//
    1515
     
    122122        StatementNode *sn;
    123123        ConstantExpr *constant;
     124        ForCtl *fctl;
    124125        LabelNode *label;
    125126        InitializerNode *in;
     
    142143%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    143144%type<en> comma_expression                              comma_expression_opt
    144 %type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
     145//%type<en> argument_expression_list            argument_expression                     for_control_expression          assignment_opt
     146%type<en> argument_expression_list              argument_expression                     assignment_opt
     147%type<fctl> for_control_expression
    145148%type<en> subrange
    146149%type<en> asm_operands_opt asm_operands_list asm_operand
     
    720723        IF '(' comma_expression ')' statement                           %prec THEN
    721724                // explicitly deal with the shift/reduce conflict on if/else
    722                 { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
     725                //{ $$ = new StatementNode( StatementNode::If, $3, $5 ); }
     726                { $$ = new StatementNode2( build_if( $3, $5, nullptr ) ); }
    723727        | IF '(' comma_expression ')' statement ELSE statement
    724                 { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
     728                //{ $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
     729                { $$ = new StatementNode2( build_if( $3, $5, $7 ) ); }
    725730        | SWITCH '(' comma_expression ')' case_clause           // CFA
    726                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     731                //{ $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     732                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    727733        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    728734                {
    729                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     735                        StatementNode *sw = new StatementNode2( build_switch( $3, $8 ) );
    730736                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    731737                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    736742                }
    737743        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    738                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     744                //{ $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     745                { $$ = new StatementNode2( build_switch( $3, $5 ) ); }
    739746        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    740747                {
    741                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     748                        //StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     749                        StatementNode *sw = new StatementNode2( build_switch( $3, $8 ) );
    742750                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    743751                }
     
    820828iteration_statement:
    821829        WHILE '(' comma_expression ')' statement
    822                 { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
     830                { $$ = new StatementNode2( build_while( $3, $5 ) ); }
    823831        | DO statement WHILE '(' comma_expression ')' ';'
    824                 { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
     832                { $$ = new StatementNode2( build_while( $5, $2 ) ); }
    825833        | FOR '(' push for_control_expression ')' statement
    826                 { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
     834                { $$ = new StatementNode2( build_for( $4, $6 ) ); }
    827835        ;
    828836
    829837for_control_expression:
    830838        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    831                 { $$ = new ForCtlExprNode( $1, $4, $6 ); }
     839                { $$ = new ForCtl( $1, $4, $6 ); }
    832840        | declaration comma_expression_opt ';' comma_expression_opt // C99
    833                 { $$ = new ForCtlExprNode( $1, $2, $4 ); }
     841                { $$ = new ForCtl( $1, $2, $4 ); }
    834842        ;
    835843
     
    946954                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
    947955        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    948         { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
     956                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
    949957        ;
    950958
Note: See TracChangeset for help on using the changeset viewer.