Esempio n. 1
0
        public object Get(Token name)
        {
            if (Values.ContainsKey(name.Lexeme))
            {
                return(Values[name.Lexeme]);
            }

            if (Enclosing != null)
            {
                return(Enclosing.Get(name));
            }

            throw new RuntimeError(name, $"Undefined variable '{name.Lexeme}'.");
        }
Esempio n. 2
0
        public object Get(Token name)
        {
            if (Values.TryGetValue(name.Lexeme, out var value))
            {
                return(value);
            }

            if (Enclosing != null)
            {
                return(Enclosing.Get(name));
            }

            throw new RuntimeError(name, $"Undefined variable '{name.Lexeme}'.");
        }
Esempio n. 3
0
 public object Get(Token name)
 => Values.TryGetValue(name.Lexeme, out var v)
         ? v
         : Enclosing != null
             ? Enclosing.Get(name)
             : throw new RuntimeException(name, $"Undefined variable {name.Lexeme}.");