Esempio n. 1
0
        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");
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public object VisitGetExpr(Expr.Get expr)
 {
     Resolve(expr.Object);
     return(null);
 }
Esempio n. 4
0
 public string Visit(Expr.Get expr)
 {
     throw new NotImplementedException();
 }