public object VisitGetExpr(Expr.Get expr) { object @object = Evaluate(expr.Object); if (@object is LoxInstance instance) { return(instance.Get(expr.Name)); } throw new RuntimeError(expr.Name, "Only instances have properties"); }
private Expr Call() { Expr expr = Primary(); while (true) { if (Match(LEFT_PAREN)) { expr = FinishCall(expr); } else if (Match(DOT)) { Token name = Consume(IDENTIFIER, "Expect property name after '.'"); expr = new Expr.Get(expr, name); } else { break; } } return(expr); }
public object VisitGetExpr(Expr.Get expr) { Resolve(expr.Object); return(null); }
public string Visit(Expr.Get expr) { throw new NotImplementedException(); }