diff --git a/Kernel.cs b/Kernel.cs index 5bb9e80..89f33eb 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -4,7 +4,6 @@ using RemSox.Processes; using RemSox.Processing; using RemSox.UI.CLI; using RemSox.UI.CLI.Commands; - using System.Runtime; namespace RemSox; @@ -26,7 +25,8 @@ public class Kernel : Sys.Kernel new StopProcessCommand(), new StartGuiCommand(), new StopGuiCommand(), - new ViewProcessLogs() + new ViewProcessLogs(), + new YesNtCommand() ]); Sys.Graphics.Canvas canvas = Sys.Graphics.FullScreenCanvas.GetFullScreenCanvas(); diff --git a/Processes/YesNtInterpreterProcess.cs b/Processes/YesNtInterpreterProcess.cs new file mode 100644 index 0000000..9aa01a5 --- /dev/null +++ b/Processes/YesNtInterpreterProcess.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using RemSox.Processing; +using YesNt.Interpreter.Runtime; +using YesNt.Interpreter.Utilities; + +namespace RemSox.Processes +{ + public class YesNtInterpreterProcess() : Process("YesNtInterpreter") + { + YesNtInterpreter interpreter = null!; + + internal override void Start(string[] args) + { + interpreter = new(); + interpreter.AddStatement(new StatementInformation("%test", YesNt.Interpreter.Enums.SearchMode.Contains, YesNt.Interpreter.Enums.SpaceAround.None) { KeepStatementInArgs = true, Priority = YesNt.Interpreter.Enums.Priority.PreProcessing }, (args, context) => + { + context.CurrentLine = TemplateProcessor.ProcessSimplePlaceholders(args, "%test", "Test successful!"); + }); + interpreter.Prepare([.. args]); + } + + internal override void Tick() + { + if (interpreter.IsRunning) + { + interpreter.Step(); + } + else + { + RequestStop(); + } + } + + internal override void Stop() + { + interpreter.Stop(); + } + } +} \ No newline at end of file diff --git a/RemSox.csproj b/RemSox.csproj index f703b67..c76dffe 100644 --- a/RemSox.csproj +++ b/RemSox.csproj @@ -9,13 +9,10 @@ + - + @@ -72,11 +69,7 @@ - + diff --git a/UI/CLI/Commands/YesNtCommand.cs b/UI/CLI/Commands/YesNtCommand.cs new file mode 100644 index 0000000..bb2551e --- /dev/null +++ b/UI/CLI/Commands/YesNtCommand.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using RemSox.Processing; + +namespace RemSox.UI.CLI.Commands +{ + public class YesNtCommand : ICommand + { + public string Name => "yesnt"; + + public string Description => "Start the YesNt interpreter"; + + public async Task ExecuteAsync(string? arguments, Action printLine) + { + int processId = ProcessManager.SpawnProcess(arguments?.Split(',') ?? []); + await ProcessManager.WaitForProcessExitAsync(processId); + } + } +} \ No newline at end of file