Changeset 3d9d017 for src/Parser


Ignore:
Timestamp:
Nov 6, 2023, 2:19:37 PM (7 months ago)
Author:
caparson <caparson@…>
Branches:
master
Children:
ba0e1bc
Parents:
49ae2bc
Message:

added cofor implementation

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    r49ae2bc r3d9d017  
    503503} // build_corun
    504504
     505ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt ) {
     506        std::vector<ast::ptr<ast::Stmt>> astinit;                                               // maybe empty
     507        buildMoveList( forctl->init, astinit );
     508
     509        ast::Expr * astcond = nullptr;                                          // maybe empty
     510        astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) );
     511
     512        ast::Expr * astincr = nullptr;                                          // maybe empty
     513        astincr = maybeMoveBuild( forctl->change );
     514        delete forctl;
     515
     516        return new ast::CoforStmt( location,
     517                std::move( astinit ),
     518                astcond,
     519                astincr,
     520                buildMoveSingle( stmt )
     521        );
     522} // build_cofor
     523
    505524// Local Variables: //
    506525// tab-width: 4 //
  • src/Parser/StatementNode.h

    r49ae2bc r3d9d017  
    106106ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
    107107ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt );
     108ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt );
  • src/Parser/parser.yy

    r49ae2bc r3d9d017  
    17251725cofor_statement:
    17261726        COFOR '(' for_control_expression_list ')' statement
    1727                 { SemanticError( yylloc, "cofor statement is currently unimplemented." ); $$ = nullptr; }
     1727                { $$ = new StatementNode( build_cofor( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
    17281728        ;
    17291729
Note: See TracChangeset for help on using the changeset viewer.