Fix continuing with previous script scope
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Upsilon;
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.Binder;
|
||||
using Upsilon.Evaluator;
|
||||
using UpsilonCompiler;
|
||||
|
||||
namespace Ycicle
|
||||
{
|
||||
@@ -13,7 +9,6 @@ namespace Ycicle
|
||||
private static void Main()
|
||||
{
|
||||
Console.WriteLine("Upsilon REPL");
|
||||
var showTranspiledOutput = false;
|
||||
Script script = null;
|
||||
while (true)
|
||||
{
|
||||
@@ -23,9 +18,6 @@ namespace Ycicle
|
||||
{
|
||||
case "exit":
|
||||
return;
|
||||
case "compiled":
|
||||
showTranspiledOutput = !showTranspiledOutput;
|
||||
break;
|
||||
}
|
||||
|
||||
if (script == null)
|
||||
@@ -45,33 +37,24 @@ namespace Ycicle
|
||||
continue;
|
||||
}
|
||||
|
||||
if (showTranspiledOutput)
|
||||
var evaluate = script.Evaluate();
|
||||
if (script.Diagnostics.Messages.Count > 0)
|
||||
{
|
||||
var transpiler = new Transpiler();
|
||||
var transpiled = transpiler.TranspilerToCSharp(script.Bind());
|
||||
Console.WriteLine(transpiled);
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Errors were found during evaluating");
|
||||
foreach (var diagnosticsMessage in script.Diagnostics.Messages)
|
||||
{
|
||||
LogError(diagnosticsMessage);
|
||||
}
|
||||
Console.ResetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var evaluate = script.Evaluate();
|
||||
if (evaluate == null)
|
||||
continue;
|
||||
if (script.Diagnostics.Messages.Count > 0)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Errors were found during evaluating");
|
||||
foreach (var diagnosticsMessage in script.Diagnostics.Messages)
|
||||
{
|
||||
LogError(diagnosticsMessage);
|
||||
}
|
||||
Console.ResetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine(evaluate);
|
||||
Console.ResetColor();
|
||||
}
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine(evaluate);
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user