object Stmt.IVisitor <object> .VisitBlockStmt(Stmt.Block stmt) { BeginScope(); Resolve(stmt.statements); EndScope(); return(null); }
public Unit VisitBlockStmt(Stmt.Block stmt) { BeginScope(); Resolve(stmt.Statements); EndScope(); return(Unit.Default); }
public object VisitBlockStmt(Stmt.Block stmt) { BeginScope(); Resolve(stmt.Statements); EndScope(); return(null); }
public Void Visit(Stmt.Block stmt) { BeginScope(); Resolve(stmt.Statements); EndScope(); return(Void.Instance); }
private Stmt ForStatement() { Consume(TokenType.LEFT_PAREN, "Expect '(' after 'for'."); Stmt initializer; if (Match(TokenType.SEMICOLON)) { initializer = null; } else if (Match(TokenType.VAR)) { initializer = VarDeclaration(); } else { initializer = ExpressionStatement(); } Expr condition = null; if (!Check(TokenType.SEMICOLON)) { condition = Expression(); } Consume(TokenType.SEMICOLON, "Expect ';' after loop condition."); Expr increment = null; if (!Check(TokenType.RIGHT_PAREN)) { increment = Expression(); } Consume(TokenType.RIGHT_PAREN, "Expect ')' after for clauses"); Stmt body = Statement(); if (increment != null) { body = new Stmt.Block(new List <Stmt>(new[] { 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>(new[] { initializer, body })); } return(body); }
private Stmt ForStatement() { Consume(LeftParen, "Expect '(' after 'for'."); Stmt initializer; if (Match(Semicolon)) { initializer = null; } else if (Match(Var)) { initializer = VarDeclaration(); } else { initializer = ExpressionStatement(); } var condition = Check(Semicolon) ? null : Expression(); Consume(Semicolon, "Expect ';' after loop condition."); var increment = Check(RightParen) ? null : Expression(); Consume(RightParen, "Expect ')' after for clauses."); var body = Statement(); if (increment != null) { body = new Stmt.Block(new[] { body, new Stmt.Expression(increment) }); } if (condition == null) { condition = new Literal(true); } body = new Stmt.While(condition, body); if (initializer != null) { body = new Stmt.Block(new[] { initializer, body }); } return(body); }
public string VisitBlockStmt(Stmt.Block stmt) { var builder = new StringBuilder(); builder.Append("(block "); foreach (var s in stmt.Statements) { builder.Append(s.Accept(this)); } builder.Append(")"); return(builder.ToString()); }
public object VisitBlockStmt(Stmt.Block stmt) { ExecuteBlock(stmt.Statements, new Environment(environment)); return(null); }
// forStmt :: "for" "(" ( varDecl | exprStmt | "; ") // expression? ";" // expression? ")" statement ; private Stmt ForStatement() { Consume(TokenType.LeftParen, "Expect '(' after 'for'"); // Get the initializer. Stmt init; if (MatchAny(TokenType.Semicolon)) { init = null; } else if (MatchAny(TokenType.Var)) { init = VarDeclaration(); } else { init = ExpressionStatement(); } // Get the condition. Expr condition = null; if (!Check(TokenType.Semicolon)) { condition = Expression(); } Consume(TokenType.Semicolon, "Expect ';' after loop condition"); // Get the increment. Expr increment = null; if (!Check(TokenType.RightParen)) { increment = Expression(); } Consume(TokenType.RightParen, "Expect ')' after for clauses"); var body = Statement(); // Desugar by creating a while loop instead. 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 (init != null) { body = new Stmt.Block( new List <Stmt> { init, body }); } return(body); }
object Stmt.IVisitor <object> .VisitBlockStmt(Stmt.Block stmt) { ExecuteBlock(stmt.statements, new Environment(environment)); return(null); }
public Unit VisitBlockStmt(Stmt.Block stmt) { ExecuteBlock(stmt.Statements, new Environment(_environment)); return(Unit.Default); }
public Void Visit(Stmt.Block stmt) { ExecuteBlock(stmt.Statements, new Environment(environment)); return(Void.Instance); }