private Stmt ClassDeclaration() { var name = Consume(IDENTIFIER, "Expected class name."); Expr superclass = null; if (Match(LESS)) { Consume(IDENTIFIER, "Expected superclass."); superclass = new Expr.Variable(Previous()); } Consume(LEFT_BRACE, "Expected '{' before class body."); var methods = new List <Stmt.Function>(); while (!Check(RIGHT_BRACE) && !IsAtEnd()) { methods.Add(Function("method")); } Consume(RIGHT_BRACE, "Expected '}' after class body."); return(new Stmt.Class(name, superclass, methods)); }
public object VisitVariableExpr(Expr.Variable expr) { if (IsDeclaredExact(expr.Name.Lexeme, false) == true) { _logger.Error(expr.Name, "Cannot read local variable in its own initializer."); } ResolveLocal(expr, expr.Name); return(null); }
public object VisitVariableExpr(Expr.Variable expr) { return(LookUpVariable(expr.Name, expr)); }
public string VisitVariableExpr(Expr.Variable expr) { return(expr.Name.Lexeme); }