Changeset 8688ce1 for src/Parser


Ignore:
Timestamp:
Aug 4, 2016, 12:29:54 PM (9 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:
76e8c55
Parents:
e80ebe5
Message:

move case-list management into parser

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    re80ebe5 r8688ce1  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  5 13:41:55 2016
    13 // Update Count     : 320
     12// Last Modified On : Tue Aug  2 15:10:23 2016
     13// Update Count     : 322
    1414//
    1515
     
    246246        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    247247        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    248         "?[?]", "FieldSel", "PFieldSel", "Range",
     248        "?[?]", "FieldSel", "PFieldSel", "...",
    249249        // monadic
    250250        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&"
  • src/Parser/parser.cc

    re80ebe5 r8688ce1  
    10311031     631,   632,   638,   639,   640,   641,   642,   643,   644,   645,
    10321032     646,   656,   663,   665,   675,   676,   681,   683,   689,   691,
    1033      695,   696,   701,   706,   709,   711,   713,   722,   724,   735,
    1034      736,   738,   742,   743,   748,   749,   754,   755,   759,   764,
     1033     695,   696,   701,   706,   709,   711,   713,   723,   725,   736,
     1034     737,   739,   743,   744,   748,   749,   754,   755,   759,   764,
    10351035     765,   769,   771,   777,   778,   782,   784,   786,   788,   794,
    10361036     795,   799,   801,   806,   808,   810,   815,   817,   822,   824,
     
    60096009                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    60106010                        // statement around the switch.  Statements after the initial declaration list can never be executed, and
    6011                         // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
     6011                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
     6012                        // statement.
    60126013                        (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw;
    60136014                }
     
    60176018
    60186019/* Line 1806 of yacc.c  */
    6019 #line 723 "parser.yy"
     6020#line 724 "parser.yy"
    60206021    { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); }
    60216022    break;
     
    60246025
    60256026/* Line 1806 of yacc.c  */
    6026 #line 725 "parser.yy"
     6027#line 726 "parser.yy"
    60276028    {
    60286029                        StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) );
     
    60346035
    60356036/* Line 1806 of yacc.c  */
    6036 #line 735 "parser.yy"
     6037#line 736 "parser.yy"
    60376038    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    60386039    break;
     
    60416042
    60426043/* Line 1806 of yacc.c  */
    6043 #line 737 "parser.yy"
     6044#line 738 "parser.yy"
    60446045    { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }
    60456046    break;
    60466047
     6048  case 162:
     6049
     6050/* Line 1806 of yacc.c  */
     6051#line 743 "parser.yy"
     6052    { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(1) - (1)].en), 0 ); }
     6053    break;
     6054
    60476055  case 163:
    60486056
    60496057/* Line 1806 of yacc.c  */
    60506058#line 744 "parser.yy"
    6051     { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( (yyvsp[(1) - (3)].en) ))->set_link( (yyvsp[(3) - (3)].en) ) ); }
     6059    { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_link( new StatementNode( StatementNode::Case, (yyvsp[(3) - (3)].en), 0 ) ) ); }
    60526060    break;
    60536061
     
    60566064/* Line 1806 of yacc.c  */
    60576065#line 748 "parser.yy"
    6058     { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0 ); }
     6066    { (yyval.sn) = (yyvsp[(2) - (3)].sn); }
    60596067    break;
    60606068
     
    94179425
    94189426/* Line 1806 of yacc.c  */
    9419 #line 9420 "Parser/parser.cc"
     9427#line 9428 "Parser/parser.cc"
    94209428      default: break;
    94219429    }
  • src/Parser/parser.yy

    re80ebe5 r8688ce1  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 23 17:01:30 2016
    13 // Update Count     : 1668
     12// Last Modified On : Thu Aug  4 11:28:18 2016
     13// Update Count     : 1672
    1414//
    1515
     
    150150%type<sn> block_item_list                               block_item
    151151%type<sn> case_clause
    152 %type<en> case_value                                    case_value_list
    153 %type<sn> case_label                                    case_label_list
     152%type<en> case_value
     153%type<sn> case_value_list                               case_label                                      case_label_list
    154154%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    155155%type<pn> handler_list                                  handler_clause                          finally_clause
     
    717717                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    718718                        // statement around the switch.  Statements after the initial declaration list can never be executed, and
    719                         // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
     719                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
     720                        // statement.
    720721                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    721722                }
     
    740741
    741742case_value_list:                                                                                // CFA
    742         case_value
    743         | case_value_list ',' case_value
    744                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); }
     743        case_value                                                                      { $$ = new StatementNode( StatementNode::Case, $1, 0 ); }
     744        | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); }
    745745        ;
    746746
    747747case_label:                                                                                             // CFA
    748         CASE case_value_list ':'                                        { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }
     748        CASE case_value_list ':'                                        { $$ = $2; }
    749749        | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
    750750                // A semantic check is required to ensure only one default clause per switch/choose statement.
Note: See TracChangeset for help on using the changeset viewer.