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