mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 16:06:08 +02:00
Fix bugs and add new statement
- Add clear call stack (`ccs`) statement - Use `\v` instead of `\r` to support escape sequences in the future
This commit is contained in:
@@ -87,7 +87,7 @@ namespace YesNt.Interpreter.Runtime
|
|||||||
staticStatements = staticStatements.OrderBy(s => s.Key.Priority).ToList();
|
staticStatements = staticStatements.OrderBy(s => s.Key.Priority).ToList();
|
||||||
|
|
||||||
runtimeInfo.OnDebugOutput += (s) => OnDebugOutput?.Invoke(s);
|
runtimeInfo.OnDebugOutput += (s) => OnDebugOutput?.Invoke(s);
|
||||||
runtimeInfo.OnLineExecuted += (DebugEventArgs e) => OnLineExecuted.Invoke(e);
|
runtimeInfo.OnLineExecuted += (DebugEventArgs e) => OnLineExecuted?.Invoke(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(string path, bool isDebugMode = false)
|
public void Execute(string path, bool isDebugMode = false)
|
||||||
@@ -138,6 +138,11 @@ namespace YesNt.Interpreter.Runtime
|
|||||||
|
|
||||||
runtimeInfo.CurrentLine = runtimeInfo.Lines[runtimeInfo.LineNumber].Content.TrimEnd().Replace("\r", string.Empty);
|
runtimeInfo.CurrentLine = runtimeInfo.Lines[runtimeInfo.LineNumber].Content.TrimEnd().Replace("\r", string.Empty);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(runtimeInfo.CurrentLine) || runtimeInfo.CurrentLine.StartsWith('#'))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
DebugEventArgs debugEventArgs = new DebugEventArgs()
|
DebugEventArgs debugEventArgs = new DebugEventArgs()
|
||||||
{
|
{
|
||||||
LineNumber = runtimeInfo.LineNumber + 1,
|
LineNumber = runtimeInfo.LineNumber + 1,
|
||||||
@@ -146,11 +151,6 @@ namespace YesNt.Interpreter.Runtime
|
|||||||
TaskId = runtimeInfo.TaskId
|
TaskId = runtimeInfo.TaskId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(runtimeInfo.CurrentLine) || runtimeInfo.CurrentLine.StartsWith('#'))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KeyValuePair<StaticStatementAttribute, Action> staticStatement in staticStatements)
|
foreach (KeyValuePair<StaticStatementAttribute, Action> staticStatement in staticStatements)
|
||||||
{
|
{
|
||||||
StaticStatementAttribute staticStatementAttribute = staticStatement.Key;
|
StaticStatementAttribute staticStatementAttribute = staticStatement.Key;
|
||||||
|
|||||||
@@ -190,5 +190,11 @@ namespace YesNt.Interpreter.Statements
|
|||||||
RuntimeInfo.Exit("No function in stack", true);
|
RuntimeInfo.Exit("No function in stack", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Statement("ccs", SearchMode.Exact, SpaceAround.None, ConsoleColor.Red)]
|
||||||
|
public void ClearCallStack(string _)
|
||||||
|
{
|
||||||
|
RuntimeInfo.FunctionCallStack.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,14 +11,14 @@ namespace YesNt.Interpreter.Utilities
|
|||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
foreach (char c in input)
|
foreach (char c in input)
|
||||||
{
|
{
|
||||||
output.Append($"\r{c}\r");
|
output.Append($"\v{c}\v");
|
||||||
}
|
}
|
||||||
return output.ToString();
|
return output.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FromSaveString(this string input)
|
public static string FromSaveString(this string input)
|
||||||
{
|
{
|
||||||
return input.Replace("\r", "");
|
return input.Replace("\v", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ToStandardizedNumber(this string input, out double result)
|
public static bool ToStandardizedNumber(this string input, out double result)
|
||||||
|
|||||||
Reference in New Issue
Block a user