Exemple #1
0
 public void Interpret(Expr expression)
 {
     try {
         var value = Evaluate(expression);
         Console.WriteLine(Stringify(value));
     } catch (RuntimeException e) {
         Lox.RuntimeError(e);
     }
 }
Exemple #2
0
 internal void AssignAt(int distance, Token name, object value)
 {
     Ancestor(distance).Match(
         some: env => env.values[name.Lexeme] = value,
         none: () => Lox.RuntimeError(
             new RuntimeError(name, $"Unable to assign to variable {name.Lexeme} value {value}")
             )
         );
 }
Exemple #3
0
 public void Interpret(List <Stmt> statements)
 {
     try
     {
         foreach (Stmt statement in statements)
         {
             Execute(statement);
         }
     }
     catch (RuntimeException error)
     {
         Lox.RuntimeError(error);
     }
 }
Exemple #4
0
 internal void Interpret(IEnumerable <Stmt> statments)
 {
     try
     {
         foreach (Stmt statement in statments)
         {
             Execute(statement);
         }
     }
     catch (RuntimeError error)
     {
         Lox.RuntimeError(error);
     }
 }
Exemple #5
0
 public void Interpret(IList <Stmt> statements)
 {
     try
     {
         foreach (var statement in statements)
         {
             Execute(statement);
         }
     }
     catch (RuntimeError error)
     {
         _lox.RuntimeError(error);
     }
 }