public object VisitBlockStmt(Stmt.Block stmt) { BeginScope(); Resolve(stmt.Statements); EndScope(); return(null); }
public string VisitBlockStmt(Stmt.Block stmt) { var builder = new StringBuilder(); builder.Append("(block "); foreach (var statement in stmt.Statements) { builder.Append(statement.Accept(this)); } builder.Append(")"); return(builder.ToString()); }
public object VisitBlockStmt(Stmt.Block stmt) { ExecuteBlock(stmt.Statements, new EnvironmentScope(_environment)); return(null); }
private Stmt ForStatement() { Consume(LEFT_PAREN, "Expected '(' after 'for'."); Stmt initializer; if (Match(SEMICOLON)) { initializer = null; } else if (Match(VAR)) { initializer = VarDeclaration(); } else { initializer = ExpressionStatement(); } Expr condition = null; if (!Check(SEMICOLON)) { condition = Expression(); } Consume(SEMICOLON, "Expected ';' after loop condition."); Expr increment = null; if (!Check(RIGHT_PAREN)) { increment = Expression(); } Consume(RIGHT_PAREN, "Expected ')' after for clauses."); var body = Statement(); if (increment != null) { body = new Stmt.Block(new List <Stmt> { body, new Stmt.Expression(increment) }); } if (condition == null) { condition = new Expr.Literal(true); } body = new Stmt.While(condition, body); if (initializer != null) { body = new Stmt.Block(new List <Stmt> { initializer, body }); } return(body); }