public Nothing VisitVariableExpr(Expr.Variable expr) { if (scopes.Count != 0 && scopes.Peek().ContainsKey(expr.Name.Lexeme) && scopes.Peek()[expr.Name.Lexeme] == false) { Lox.Error(expr.Name, "Cannot read local variable in its own initializer."); } ResolveLocal(expr, expr.Name); return(Nothing.AtAll); }
private Stmt ClassDeclaration() { Token name = Consume(IDENTIFIER, "Expect class name."); Expr superclass = null; if (Match(LESS)) { Consume(IDENTIFIER, "Expect superclass name."); superclass = new Expr.Variable(Previous()); } Consume(LEFT_BRACE, "Expect '{' before class body."); List <Stmt.Function> methods = new List <Stmt.Function>(); while (!Check(RIGHT_BRACE) && !IsAtEnd()) { methods.Add(Function("method")); } Consume(RIGHT_BRACE, "Expect '}' after class body."); return(new Stmt.Class(name, superclass, methods)); }
public object VisitVariableExpr(Expr.Variable expr) { return(LookUpVariable(expr.Name, expr)); }
public string VisitVariableExpr(Expr.Variable expr) { throw new System.NotImplementedException(); }