Changeset 427854b for src/Parser


Ignore:
Timestamp:
Mar 2, 2020, 4:59:27 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
dfa4360
Parents:
37cdd97
Message:

First draft implementation of generators, still missing error checking, testing and clean-up

Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r37cdd97 r427854b  
    428428Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
    429429Statement * build_directive( std::string * directive );
     430SuspendStmt * build_suspend( StatementNode *, SuspendStmt::Type = SuspendStmt::None);
    430431WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );
    431432WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );
  • src/Parser/StatementNode.cc

    r37cdd97 r427854b  
    249249} // build_finally
    250250
     251SuspendStmt * build_suspend( StatementNode * then, SuspendStmt::Type type ) {
     252        auto node = new SuspendStmt();
     253
     254        node->type = type;
     255
     256        std::list< Statement * > stmts;
     257        buildMoveList< Statement, StatementNode >( then, stmts );
     258        if(!stmts.empty()) {
     259                assert( stmts.size() == 1 );
     260                node->then = dynamic_cast< CompoundStmt * >( stmts.front() );
     261        }
     262
     263        return node;
     264}
     265
    251266WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) {
    252267        auto node = new WaitForStmt();
  • src/Parser/TypeData.cc

    r37cdd97 r427854b  
    769769          case AggregateDecl::Struct:
    770770          case AggregateDecl::Coroutine:
     771          case AggregateDecl::Generator:
    771772          case AggregateDecl::Monitor:
    772773          case AggregateDecl::Thread:
  • src/Parser/parser.yy

    r37cdd97 r427854b  
    12611261                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    12621262        | SUSPEND ';'
    1263                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1263                { $$ = new StatementNode( build_suspend( nullptr ) ); }
    12641264        | SUSPEND compound_statement ';'
    1265                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1265                { $$ = new StatementNode( build_suspend( $2 ) ); }
    12661266        | SUSPEND COROUTINE ';'
    1267                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1267                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Coroutine ) ); }
    12681268        | SUSPEND COROUTINE compound_statement
    1269                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1269                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Coroutine ) ); }
    12701270        | SUSPEND GENERATOR ';'
    1271                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1271                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Generator ) ); }
    12721272        | SUSPEND GENERATOR compound_statement
    1273                 { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1273                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Generator ) ); }
    12741274        | THROW assignment_expression_opt ';'                           // handles rethrow
    12751275                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    20862086aggregate_control:                                                                              // CFA
    20872087        GENERATOR
    2088                 { SemanticError( yylloc, "generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2088                { yyy = true; $$ = AggregateDecl::Generator; }
    20892089        | MONITOR GENERATOR
    20902090                { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
Note: See TracChangeset for help on using the changeset viewer.