From 7819ed387533267e141c92aa816d4464d48e13b0 Mon Sep 17 00:00:00 2001 From: "Chris J. Breisch" Date: Tue, 21 Jun 2022 21:01:05 -0400 Subject: [PATCH] code beautification --- Trs80.Level1Basic.Application/Bootstrapper.cs | 4 +- Trs80.Level1Basic.Application/ConsoleApp.cs | 1 + .../Commands/InputCommand.cs | 19 +- .../Commands/InterpretCommand.cs | 6 +- .../Commands/ParseCommand.cs | 5 +- .../Commands/SetupTrs80Command.cs | 5 +- .../Commands/ShutdownTrs80Command.cs | 5 +- .../WorkflowDataModel.cs | 2 + .../StringExtensionsTest.cs | 385 +++++++++--------- Trs80.Level1Basic.Common/AppSettings.cs | 3 +- .../Extensions/LoggerExtensions.cs | 18 - Trs80.Level1Basic.Common/SourceLine.cs | 25 +- Trs80.Level1Basic.Common/Void.cs | 10 +- .../EnvironmentTest.cs | 138 +++---- Trs80.Level1Basic.HostMachine/Host.cs | 5 +- .../CommandTest.cs | 2 + .../DataTest.cs | 3 +- .../ErrorTest.cs | 3 + .../ExpressionTest.cs | 2 + .../ExtensionsTest.cs | 4 +- .../FlowControlTest.cs | 6 +- .../InputTest.cs | 2 + .../InterpreterTest.cs | 4 +- .../LineListTest.cs | 8 +- .../LogicalTest.cs | 1 + .../LonghandSmokeTest.cs | 1 + .../NativeFunctionTest.cs | 1 + .../ParserTest.cs | 4 +- .../PrintTest.cs | 1 + .../RecursionTest.cs | 2 + Trs80.Level1Basic.Interpreter.Test/RunTest.cs | 1 + .../ScannerTest.cs | 2 + .../ShorthandTest.cs | 5 +- .../StatementListTest.cs | 2 + Trs80.Level1Basic.TestUtilities/FakeHost.cs | 235 ++++++----- .../TestController.cs | 2 +- Trs80.Level1Basic.Trs80.Test/Trs80Test.cs | 6 +- .../Exceptions/ExceptionHandler.cs | 2 +- .../Exceptions/LoopAfterNext.cs | 3 +- .../Exceptions/ReturnFromGosub.cs | 3 +- .../Exceptions/RuntimeExpressionException.cs | 1 + .../Exceptions/RuntimeStatementException.cs | 7 - .../Interpreter/FileDialog.cs | 6 - .../Interpreter/Interpreter.cs | 38 +- .../Interpreter/Program.cs | 3 +- .../Machine/ICallable.cs | 1 + .../Machine/IMachine.cs | 5 +- .../Machine/ITrs80.cs | 1 + .../Machine/Machine.cs | 15 +- .../Machine/NativeFunctions.cs | 2 +- .../Machine/Trs80.cs | 2 +- .../Parser/Expressions/Array.cs | 2 - .../Parser/Expressions/Assign.cs | 2 - .../Parser/Expressions/Binary.cs | 2 - .../Parser/Expressions/Expression.cs | 4 - .../Parser/Expressions/Grouping.cs | 4 - .../Parser/Expressions/Identifier.cs | 2 - .../Parser/Expressions/Literal.cs | 4 - .../Parser/Expressions/Unary.cs | 2 - .../Parser/IParser.cs | 1 + .../Parser/Parser.cs | 12 +- .../Parser/Statements/Cls.cs | 8 - .../Parser/Statements/Compound.cs | 3 - .../Statements/CompoundStatementList.cs | 4 +- .../Parser/Statements/Cont.cs | 8 - .../Parser/Statements/Delete.cs | 3 - .../Parser/Statements/End.cs | 8 - .../Parser/Statements/For.cs | 1 - .../Parser/Statements/Gosub.cs | 1 - .../Parser/Statements/Goto.cs | 1 - .../Parser/Statements/IStatement.cs | 3 - .../Parser/Statements/If.cs | 1 - .../Parser/Statements/Let.cs | 1 - .../Parser/Statements/List.cs | 1 - .../Parser/Statements/Load.cs | 1 - .../Parser/Statements/Merge.cs | 1 - .../Parser/Statements/New.cs | 8 - .../Parser/Statements/Next.cs | 1 - .../Parser/Statements/Rem.cs | 1 - .../Parser/Statements/Replace.cs | 3 - .../Parser/Statements/Restore.cs | 8 - .../Parser/Statements/Return.cs | 8 - .../Parser/Statements/Run.cs | 1 - .../Parser/Statements/Save.cs | 1 - .../Parser/Statements/Statement.cs | 3 - .../Parser/Statements/StatementExpression.cs | 1 - .../Parser/Statements/Stop.cs | 8 - .../Scanner/IScanner.cs | 1 + .../Scanner/Scanner.cs | 1 - Trs80.Level1Basic.Workflow/IInputStep.cs | 6 +- Trs80.Level1Basic.Workflow/IInterpretStep.cs | 1 + Trs80.Level1Basic.Workflow/IParseStep.cs | 6 +- Trs80.Level1Basic.Workflow/IScanStep.cs | 6 +- Trs80.Level1Basic.Workflow/InputStep.cs | 9 +- Trs80.Level1Basic.Workflow/InterpretStep.cs | 6 +- Trs80.Level1Basic.Workflow/ParseStep.cs | 6 +- Trs80.Level1Basic.Workflow/ScanStep.cs | 1 + .../SetupConsoleStep.cs | 6 +- .../ShutdownConsoleStep.cs | 6 +- Trs80.Level1Basic.sln.DotSettings | 2 + Trs80.Level1Basic/Program.cs | 1 + 101 files changed, 562 insertions(+), 636 deletions(-) delete mode 100644 Trs80.Level1Basic.Common/Extensions/LoggerExtensions.cs delete mode 100644 Trs80.Level1Basic.VirtualMachine/Interpreter/FileDialog.cs diff --git a/Trs80.Level1Basic.Application/Bootstrapper.cs b/Trs80.Level1Basic.Application/Bootstrapper.cs index 5124fde..03e027b 100644 --- a/Trs80.Level1Basic.Application/Bootstrapper.cs +++ b/Trs80.Level1Basic.Application/Bootstrapper.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; + using Trs80.Level1Basic.Command; using Trs80.Level1Basic.Command.Commands; using Trs80.Level1Basic.CommandModels; @@ -19,6 +20,7 @@ using Trs80.Level1Basic.VirtualMachine.Parser; using Trs80.Level1Basic.VirtualMachine.Scanner; using Trs80.Level1Basic.Workflow; + using WorkflowCore.Interface; using WorkflowCore.Models; using WorkflowCore.Services.DefinitionStorage; @@ -55,7 +57,7 @@ public Bootstrapper() CreateServiceProvider(); GetAppSettings(); - + GetApplicationName(); LogConfiguredServices(); diff --git a/Trs80.Level1Basic.Application/ConsoleApp.cs b/Trs80.Level1Basic.Application/ConsoleApp.cs index e333a2b..612ac10 100644 --- a/Trs80.Level1Basic.Application/ConsoleApp.cs +++ b/Trs80.Level1Basic.Application/ConsoleApp.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; + using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Machine; diff --git a/Trs80.Level1Basic.Command/Commands/InputCommand.cs b/Trs80.Level1Basic.Command/Commands/InputCommand.cs index 0a50e5c..23cd722 100644 --- a/Trs80.Level1Basic.Command/Commands/InputCommand.cs +++ b/Trs80.Level1Basic.Command/Commands/InputCommand.cs @@ -1,9 +1,12 @@ -using Trs80.Level1Basic.CommandModels; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.Command.Commands; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class InputCommand : ICommand { private readonly ITrs80 _trs80; @@ -28,6 +31,7 @@ private SourceLine GetInputLine() char[] line = new char[1024]; int charCount = 0; bool inQuote = false; + bool inCommand = true; while (true) { @@ -36,14 +40,12 @@ private SourceLine GetInputLine() if (key.Key == ConsoleKey.Enter) { _trs80.WriteLine(); - inQuote = false; break; } - if (key.KeyChar == '"') - { + if (key.KeyChar == '"' && inCommand) inQuote = !inQuote; - } + if (key.Key == ConsoleKey.Backspace) { if (charCount > 0) @@ -58,10 +60,13 @@ private SourceLine GetInputLine() } else { + if (inCommand && char.IsDigit(key.KeyChar) && (charCount <= 0 || original.All(char.IsWhiteSpace))) + inCommand = false; + original[charCount] = key.KeyChar; char upper = Upper(key.KeyChar); line[charCount++] = upper; - if (!inQuote) + if (!inQuote || !inCommand) _trs80.Write($"\b{upper}"); } } @@ -70,7 +75,7 @@ private SourceLine GetInputLine() ? new SourceLine() : new SourceLine { - Line = new string(line, 0, charCount), + Line = new string(line, 0, charCount), Original = new string(original, 0, charCount) }; } diff --git a/Trs80.Level1Basic.Command/Commands/InterpretCommand.cs b/Trs80.Level1Basic.Command/Commands/InterpretCommand.cs index 68d52c4..be898ba 100644 --- a/Trs80.Level1Basic.Command/Commands/InterpretCommand.cs +++ b/Trs80.Level1Basic.Command/Commands/InterpretCommand.cs @@ -1,19 +1,17 @@ using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Interpreter; -using Trs80.Level1Basic.VirtualMachine.Machine; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; namespace Trs80.Level1Basic.Command.Commands; +// ReSharper disable once UnusedMember.Global public class InterpretCommand : ICommand { private readonly IInterpreter _interpreter; - private readonly ITrs80 _trs80; - public InterpretCommand(IInterpreter interpreter, ITrs80 trs80) + public InterpretCommand(IInterpreter interpreter) { _interpreter = interpreter ?? throw new ArgumentNullException(nameof(interpreter)); - _trs80 = trs80 ?? throw new ArgumentNullException(nameof(trs80)); } public void Execute(InterpretModel parameterObject) diff --git a/Trs80.Level1Basic.Command/Commands/ParseCommand.cs b/Trs80.Level1Basic.Command/Commands/ParseCommand.cs index 724820f..c4bfcd8 100644 --- a/Trs80.Level1Basic.Command/Commands/ParseCommand.cs +++ b/Trs80.Level1Basic.Command/Commands/ParseCommand.cs @@ -1,10 +1,13 @@ -using Trs80.Level1Basic.CommandModels; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Parser; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; using Trs80.Level1Basic.VirtualMachine.Scanner; namespace Trs80.Level1Basic.Command.Commands; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class ParseCommand : ICommand { private readonly IParser _parser; diff --git a/Trs80.Level1Basic.Command/Commands/SetupTrs80Command.cs b/Trs80.Level1Basic.Command/Commands/SetupTrs80Command.cs index 943783e..890fba5 100644 --- a/Trs80.Level1Basic.Command/Commands/SetupTrs80Command.cs +++ b/Trs80.Level1Basic.Command/Commands/SetupTrs80Command.cs @@ -1,8 +1,11 @@ -using Trs80.Level1Basic.CommandModels; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.Command.Commands; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class SetupTrs80Command : ICommand { private readonly ITrs80 _trs80; diff --git a/Trs80.Level1Basic.Command/Commands/ShutdownTrs80Command.cs b/Trs80.Level1Basic.Command/Commands/ShutdownTrs80Command.cs index 17b191e..2f3f734 100644 --- a/Trs80.Level1Basic.Command/Commands/ShutdownTrs80Command.cs +++ b/Trs80.Level1Basic.Command/Commands/ShutdownTrs80Command.cs @@ -1,8 +1,11 @@ -using Trs80.Level1Basic.CommandModels; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.Command.Commands; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class ShutdownTrs80Command : ICommand { private readonly ITrs80 _trs80; diff --git a/Trs80.Level1Basic.CommandModels/WorkflowDataModel.cs b/Trs80.Level1Basic.CommandModels/WorkflowDataModel.cs index 76171f6..54ce853 100644 --- a/Trs80.Level1Basic.CommandModels/WorkflowDataModel.cs +++ b/Trs80.Level1Basic.CommandModels/WorkflowDataModel.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; + using Trs80.Level1Basic.Common; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; using Trs80.Level1Basic.VirtualMachine.Scanner; @@ -6,6 +7,7 @@ namespace Trs80.Level1Basic.CommandModels; [SuppressMessage("ReSharper", "EmptyConstructor")] +[SuppressMessage("ReSharper", "UnusedMember.Global")] public sealed class WorkflowDataModel { public bool WritePrompt { get; set; } = false; diff --git a/Trs80.Level1Basic.Common.Test/StringExtensionsTest.cs b/Trs80.Level1Basic.Common.Test/StringExtensionsTest.cs index e5d1cb6..258804f 100644 --- a/Trs80.Level1Basic.Common.Test/StringExtensionsTest.cs +++ b/Trs80.Level1Basic.Common.Test/StringExtensionsTest.cs @@ -1,199 +1,200 @@ using FluentAssertions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.Common.Extensions; -namespace Trs80.Level1Basic.Common.Test +namespace Trs80.Level1Basic.Common.Test; + +[TestClass] +public class StringExtensionsTest { - [TestClass] - public class StringExtensionsTest - { - private const string testString = "four Score-and_seven_YeArs AGO"; - private const string testOneWordString = "fOUr"; - private const string testUpperOneLetterString = "F"; - private const string testLowerOneLetterString = "f"; - private const string testCamelCaseString = "fourScoreAndSevenYearsAgo"; - - [TestMethod] - public void Can_Convert_Empty_String_To_Pascal_Case() - { - string? result = string.Empty.ToPascalCase(); - result.Should().BeEmpty(); - } - - [TestMethod] - public void Can_Convert_String_To_Pascal_Case() - { - string? result = testString.ToPascalCase(); - result.Should().Be("FourScoreAndSevenYearsAgo"); - } - - [TestMethod] - public void Can_Convert_String_To_Camel_Case() - { - string? result = testString.ToCamelCase(); - result.Should().Be("fourScoreAndSevenYearsAgo"); - } - - [TestMethod] - public void Can_Convert_String_To_Snake_Case() - { - string? result = testString.ToSnakeCase(); - result.Should().Be("four_score_and_seven_years_ago"); - } - - [TestMethod] - public void Can_Convert_String_To_Caps_Case() - { - string? result = testString.ToCapsCase(); - result.Should().Be("FOUR_SCORE_AND_SEVEN_YEARS_AGO"); - } - - [TestMethod] - public void Can_Convert_String_To_Kebab_Case() - { - string? result = testString.ToKebabCase(); - result.Should().Be("four-score-and-seven-years-ago"); - } - - [TestMethod] - public void Can_Convert_One_Word_String_To_Pascal_Case() - { - string? result = testOneWordString.ToPascalCase(); - result.Should().Be("Four"); - } - - [TestMethod] - public void Can_Convert_One_Word_String_To_Camel_Case() - { - string? result = testOneWordString.ToCamelCase(); - result.Should().Be("four"); - } - - [TestMethod] - public void Can_Convert_One_Word_String_To_Snake_Case() - { - string? result = testOneWordString.ToSnakeCase(); - result.Should().Be("four"); - } - - [TestMethod] - public void Can_Convert_One_Word_String_To_Caps_Case() - { - string? result = testOneWordString.ToCapsCase(); - result.Should().Be("FOUR"); - } - - [TestMethod] - public void Can_Convert_One_Word_String_To_Kebab_Case() - { - string? result = testOneWordString.ToKebabCase(); - result.Should().Be("four"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Upper_String_To_Pascal_Case() - { - string? result = testUpperOneLetterString.ToPascalCase(); - result.Should().Be("F"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Upper_String_To_Camel_Case() - { - string? result = testUpperOneLetterString.ToCamelCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Upper_String_To_Snake_Case() - { - string? result = testUpperOneLetterString.ToSnakeCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Upper_String_To_Caps_Case() - { - string? result = testUpperOneLetterString.ToCapsCase(); - result.Should().Be("F"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Upper_String_To_Kebab_Case() - { - string? result = testUpperOneLetterString.ToKebabCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Lower_String_To_Pascal_Case() - { - string? result = testLowerOneLetterString.ToPascalCase(); - result.Should().Be("F"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Lower_String_To_Camel_Case() - { - string? result = testLowerOneLetterString.ToCamelCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Lower_String_To_Snake_Case() - { - string? result = testLowerOneLetterString.ToSnakeCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Lower_String_To_Caps_Case() - { - string? result = testLowerOneLetterString.ToCapsCase(); - result.Should().Be("F"); - } - - [TestMethod] - public void Can_Convert_One_Letter_Lower_String_To_Kebab_Case() - { - string? result = testLowerOneLetterString.ToKebabCase(); - result.Should().Be("f"); - } - - [TestMethod] - public void Can_Separate_Camel_Case_String() - { - string? result = testCamelCaseString.SeparateWordsByCase('_'); - result.Should().Be("four_Score_And_Seven_Years_Ago"); - } - - [TestMethod] - public void Can_Convert_Separated_String_To_Pascal_Case() - { - string? result = testCamelCaseString.SeparateWordsByCase('_').ToPascalCase(); - result.Should().Be("FourScoreAndSevenYearsAgo"); - - } - - [TestMethod] - public void Can_Retrieve_Left_String() - { - string? result = testString.Left(4); - result.Should().Be("four"); - } - - [TestMethod] - public void Can_Retrieve_Left_String_Of_Zero_Chars() - { - string? result = testString.Left(0); - result.Should().BeEmpty(); - } - - [TestMethod] - public void Can_Retrieve_Left_String_Beyond_Length_Of_String() - { - string? result = testOneWordString.Left(20); - result.Should().Be(testOneWordString); - } + private const string testString = "four Score-and_seven_YeArs AGO"; + private const string testOneWordString = "fOUr"; + private const string testUpperOneLetterString = "F"; + private const string testLowerOneLetterString = "f"; + private const string testCamelCaseString = "fourScoreAndSevenYearsAgo"; + + [TestMethod] + public void Can_Convert_Empty_String_To_Pascal_Case() + { + string? result = string.Empty.ToPascalCase(); + result.Should().BeEmpty(); + } + + [TestMethod] + public void Can_Convert_String_To_Pascal_Case() + { + string? result = testString.ToPascalCase(); + result.Should().Be("FourScoreAndSevenYearsAgo"); + } + + [TestMethod] + public void Can_Convert_String_To_Camel_Case() + { + string? result = testString.ToCamelCase(); + result.Should().Be("fourScoreAndSevenYearsAgo"); + } + + [TestMethod] + public void Can_Convert_String_To_Snake_Case() + { + string? result = testString.ToSnakeCase(); + result.Should().Be("four_score_and_seven_years_ago"); + } + + [TestMethod] + public void Can_Convert_String_To_Caps_Case() + { + string? result = testString.ToCapsCase(); + result.Should().Be("FOUR_SCORE_AND_SEVEN_YEARS_AGO"); + } + + [TestMethod] + public void Can_Convert_String_To_Kebab_Case() + { + string? result = testString.ToKebabCase(); + result.Should().Be("four-score-and-seven-years-ago"); + } + + [TestMethod] + public void Can_Convert_One_Word_String_To_Pascal_Case() + { + string? result = testOneWordString.ToPascalCase(); + result.Should().Be("Four"); + } + + [TestMethod] + public void Can_Convert_One_Word_String_To_Camel_Case() + { + string? result = testOneWordString.ToCamelCase(); + result.Should().Be("four"); + } + + [TestMethod] + public void Can_Convert_One_Word_String_To_Snake_Case() + { + string? result = testOneWordString.ToSnakeCase(); + result.Should().Be("four"); + } + + [TestMethod] + public void Can_Convert_One_Word_String_To_Caps_Case() + { + string? result = testOneWordString.ToCapsCase(); + result.Should().Be("FOUR"); + } + + [TestMethod] + public void Can_Convert_One_Word_String_To_Kebab_Case() + { + string? result = testOneWordString.ToKebabCase(); + result.Should().Be("four"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Upper_String_To_Pascal_Case() + { + string? result = testUpperOneLetterString.ToPascalCase(); + result.Should().Be("F"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Upper_String_To_Camel_Case() + { + string? result = testUpperOneLetterString.ToCamelCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Upper_String_To_Snake_Case() + { + string? result = testUpperOneLetterString.ToSnakeCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Upper_String_To_Caps_Case() + { + string? result = testUpperOneLetterString.ToCapsCase(); + result.Should().Be("F"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Upper_String_To_Kebab_Case() + { + string? result = testUpperOneLetterString.ToKebabCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Lower_String_To_Pascal_Case() + { + string? result = testLowerOneLetterString.ToPascalCase(); + result.Should().Be("F"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Lower_String_To_Camel_Case() + { + string? result = testLowerOneLetterString.ToCamelCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Lower_String_To_Snake_Case() + { + string? result = testLowerOneLetterString.ToSnakeCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Lower_String_To_Caps_Case() + { + string? result = testLowerOneLetterString.ToCapsCase(); + result.Should().Be("F"); + } + + [TestMethod] + public void Can_Convert_One_Letter_Lower_String_To_Kebab_Case() + { + string? result = testLowerOneLetterString.ToKebabCase(); + result.Should().Be("f"); + } + + [TestMethod] + public void Can_Separate_Camel_Case_String() + { + string? result = testCamelCaseString.SeparateWordsByCase('_'); + result.Should().Be("four_Score_And_Seven_Years_Ago"); + } + + [TestMethod] + public void Can_Convert_Separated_String_To_Pascal_Case() + { + string? result = testCamelCaseString.SeparateWordsByCase('_').ToPascalCase(); + result.Should().Be("FourScoreAndSevenYearsAgo"); + + } + + [TestMethod] + public void Can_Retrieve_Left_String() + { + string? result = testString.Left(4); + result.Should().Be("four"); + } + + [TestMethod] + public void Can_Retrieve_Left_String_Of_Zero_Chars() + { + string? result = testString.Left(0); + result.Should().BeEmpty(); + } + + [TestMethod] + public void Can_Retrieve_Left_String_Beyond_Length_Of_String() + { + string? result = testOneWordString.Left(20); + result.Should().Be(testOneWordString); } } \ No newline at end of file diff --git a/Trs80.Level1Basic.Common/AppSettings.cs b/Trs80.Level1Basic.Common/AppSettings.cs index 56cd6d5..c1358a6 100644 --- a/Trs80.Level1Basic.Common/AppSettings.cs +++ b/Trs80.Level1Basic.Common/AppSettings.cs @@ -1,5 +1,4 @@ - -namespace Trs80.Level1Basic.Common; +namespace Trs80.Level1Basic.Common; public sealed class AppSettings : IAppSettings { diff --git a/Trs80.Level1Basic.Common/Extensions/LoggerExtensions.cs b/Trs80.Level1Basic.Common/Extensions/LoggerExtensions.cs deleted file mode 100644 index 420ea4b..0000000 --- a/Trs80.Level1Basic.Common/Extensions/LoggerExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; - -namespace Trs80.Level1Basic.Common.Extensions; - -public static class LoggerExtensions -{ - [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Extension Method")] - [SuppressMessage("ReSharper", "UnusedParameter.Global")] - public static string JsonSerializeObject(this ILogger logger, object item) - { - // this really should be a regex. I'm too lazy. - return JsonConvert.SerializeObject(item).Replace(",", ",\r\n").Replace("{\"", "{\r\n\"") - .Replace("\r\n\"", "\r\n\t\""); - } -} - diff --git a/Trs80.Level1Basic.Common/SourceLine.cs b/Trs80.Level1Basic.Common/SourceLine.cs index 7fc1652..ed4739c 100644 --- a/Trs80.Level1Basic.Common/SourceLine.cs +++ b/Trs80.Level1Basic.Common/SourceLine.cs @@ -1,18 +1,17 @@ -namespace Trs80.Level1Basic.Common +namespace Trs80.Level1Basic.Common; + +public class SourceLine { - public class SourceLine + public SourceLine() { - public SourceLine() - { - } + } - public SourceLine(string original) - { - Original = original; - Line = original.ToUpperInvariant(); - } - public string Original { get; set; } - public string Line { get; set; } + public SourceLine(string original) + { + Original = original; + Line = original.ToUpperInvariant(); } -} + public string Original { get; set; } + public string Line { get; set; } +} \ No newline at end of file diff --git a/Trs80.Level1Basic.Common/Void.cs b/Trs80.Level1Basic.Common/Void.cs index 930e6ed..3b60249 100644 --- a/Trs80.Level1Basic.Common/Void.cs +++ b/Trs80.Level1Basic.Common/Void.cs @@ -1,7 +1,5 @@ - -namespace Trs80.Level1Basic.Common +namespace Trs80.Level1Basic.Common; + +public sealed class Void { - public sealed class Void - { - } -} +} \ No newline at end of file diff --git a/Trs80.Level1Basic.Environment.Test/EnvironmentTest.cs b/Trs80.Level1Basic.Environment.Test/EnvironmentTest.cs index f692fc1..0145682 100644 --- a/Trs80.Level1Basic.Environment.Test/EnvironmentTest.cs +++ b/Trs80.Level1Basic.Environment.Test/EnvironmentTest.cs @@ -3,78 +3,78 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; -namespace Trs80.Level1Basic.Environment.Test +namespace Trs80.Level1Basic.Environment.Test; + +[TestClass] +public class EnvironmentTest { - [TestClass] - public class EnvironmentTest + private readonly List _program = new(){ + "10 i = 3", + "20 i = i * 2", + "30 print i" + }; + + [TestMethod] + public void Environment_Can_Execute_Baseline_Program() + { + using var controller = new TestController(); + + controller.RunProgram(_program); + + controller.ReadOutputLine().Should().Be(" 6 "); + controller.IsEndOfRun().Should().BeTrue(); + } + + [TestMethod] + public void Environment_Can_Insert_Line_In_The_Middle() + { + using var controller = new TestController(); + + controller.ExecuteLine("new"); + controller.ExecuteStatements(_program); + + controller.ExecuteLine("25 i = i + 7"); + controller.ExecuteLine("run"); + + controller.ReadOutputLine().Should().Be(" 13 "); + controller.IsEndOfRun().Should().BeTrue(); + } + + [TestMethod] + public void Environment_Can_Replace_Line() { - private readonly List _program = new (){ - "10 i = 3", - "20 i = i * 2", - "30 print i" - }; - - [TestMethod] - public void Environment_Can_Execute_Baseline_Program() - { - using var controller = new TestController(); - - controller.RunProgram(_program); - - controller.ReadOutputLine().Should().Be(" 6 "); - controller.IsEndOfRun().Should().BeTrue(); - } - - [TestMethod] - public void Environment_Can_Insert_Line_In_The_Middle() - { - using var controller = new TestController(); - - controller.ExecuteLine("new"); - controller.ExecuteStatements(_program); - - controller.ExecuteLine("25 i = i + 7"); - controller.ExecuteLine("run"); - - controller.ReadOutputLine().Should().Be(" 13 "); - controller.IsEndOfRun().Should().BeTrue(); - } - - [TestMethod] - public void Environment_Can_Replace_Line() - { - using var controller = new TestController(); - - controller.ExecuteLine("new"); - controller.ExecuteStatements(_program); - - controller.ExecuteLine("20 i = i + 7"); - controller.ExecuteLine("run"); - - controller.ReadOutputLine().Should().Be(" 10 "); - controller.IsEndOfRun().Should().BeTrue(); - } - - [TestMethod] - public void Environment_Can_Delete_Line() - { - using var controller = new TestController(); - - controller.ExecuteLine("new"); - controller.ExecuteStatements(_program); - - controller.ExecuteLine("20"); - controller.ExecuteLine("run"); - controller.ExecuteLine("list"); - - controller.ReadOutputLine().Should().Be(" 3 "); - controller.ReadOutputLine().Should().Be(""); - controller.ReadOutputLine().Should().Be("READY"); - controller.ReadOutputLine().Should().Be(" 10 I = 3"); - controller.ReadOutputLine().Should().Be(" 30 PRINT I"); - controller.ReadOutputLine().Should().BeNull(); - } + using var controller = new TestController(); + + controller.ExecuteLine("new"); + controller.ExecuteStatements(_program); + + controller.ExecuteLine("20 i = i + 7"); + controller.ExecuteLine("run"); + + controller.ReadOutputLine().Should().Be(" 10 "); + controller.IsEndOfRun().Should().BeTrue(); + } + + [TestMethod] + public void Environment_Can_Delete_Line() + { + using var controller = new TestController(); + + controller.ExecuteLine("new"); + controller.ExecuteStatements(_program); + + controller.ExecuteLine("20"); + controller.ExecuteLine("run"); + controller.ExecuteLine("list"); + + controller.ReadOutputLine().Should().Be(" 3 "); + controller.ReadOutputLine().Should().Be(""); + controller.ReadOutputLine().Should().Be("READY"); + controller.ReadOutputLine().Should().Be(" 10 I = 3"); + controller.ReadOutputLine().Should().Be(" 30 PRINT I"); + controller.ReadOutputLine().Should().BeNull(); } } \ No newline at end of file diff --git a/Trs80.Level1Basic.HostMachine/Host.cs b/Trs80.Level1Basic.HostMachine/Host.cs index 18d4661..58bc919 100644 --- a/Trs80.Level1Basic.HostMachine/Host.cs +++ b/Trs80.Level1Basic.HostMachine/Host.cs @@ -10,7 +10,7 @@ namespace Trs80.Level1Basic.HostMachine; -public class Host : IHost, IDisposable +public class Host : IHost, IDisposable { // https://www.pinvoke.net/default.aspx/user32/FindWindow.html [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true, CharSet = CharSet.Unicode)] @@ -118,7 +118,8 @@ public string ReadLine() ? string.Empty : new string(line, 0, charCount); } - + + [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Don't agree with this optimization.")] private char Upper(char key) { if (!char.IsLetter(key)) return key; diff --git a/Trs80.Level1Basic.Interpreter.Test/CommandTest.cs b/Trs80.Level1Basic.Interpreter.Test/CommandTest.cs index 18314f3..d00ad9d 100644 --- a/Trs80.Level1Basic.Interpreter.Test/CommandTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/CommandTest.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/DataTest.cs b/Trs80.Level1Basic.Interpreter.Test/DataTest.cs index 4841405..77f6c6d 100644 --- a/Trs80.Level1Basic.Interpreter.Test/DataTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/DataTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; @@ -98,7 +99,7 @@ public void Interpreter_Can_Read_Strings() } [TestMethod] - public void Interpreter_Doesnt_Fail_When_Reading_Strings_Into_Number_Variables() + public void Interpreter_Does_Not_Fail_When_Reading_Strings_Into_Number_Variables() { using var controller = new TestController(); var program = new List { diff --git a/Trs80.Level1Basic.Interpreter.Test/ErrorTest.cs b/Trs80.Level1Basic.Interpreter.Test/ErrorTest.cs index ef9643d..e8a2fe8 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ErrorTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ErrorTest.cs @@ -1,13 +1,16 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; [TestClass] +[SuppressMessage("ReSharper", "StringLiteralTypo")] public class ErrorTest { [TestMethod] diff --git a/Trs80.Level1Basic.Interpreter.Test/ExpressionTest.cs b/Trs80.Level1Basic.Interpreter.Test/ExpressionTest.cs index fc257b1..88a600c 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ExpressionTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ExpressionTest.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/ExtensionsTest.cs b/Trs80.Level1Basic.Interpreter.Test/ExtensionsTest.cs index 8ccac9a..e65d612 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ExtensionsTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ExtensionsTest.cs @@ -1,13 +1,15 @@ using System.Collections.Generic; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; [TestClass] -public class ExtensionsTest +public class ExtensionsTest { [TestMethod] public void Interpreter_Handles_Extra_String_Variables() diff --git a/Trs80.Level1Basic.Interpreter.Test/FlowControlTest.cs b/Trs80.Level1Basic.Interpreter.Test/FlowControlTest.cs index 97c51d2..18da804 100644 --- a/Trs80.Level1Basic.Interpreter.Test/FlowControlTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/FlowControlTest.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; @@ -76,7 +78,7 @@ public void Interpreter_Can_Execute_Correct_Statement_After_Gosub() controller.ReadOutputLine().Should().Be(" 6 "); controller.IsEndOfRun().Should().BeTrue(); } - + [TestMethod] public void Interpreter_Can_Execute_If_Statement() { @@ -341,7 +343,7 @@ public void Interpreter_Executes_Return_After_Then() } [TestMethod] - public void Interpreter_Executes_Goto_After_Multiple_Thens() + public void Interpreter_Executes_Goto_After_Multiple_Then_Statements() { using var controller = new TestController(); var program = new List { diff --git a/Trs80.Level1Basic.Interpreter.Test/InputTest.cs b/Trs80.Level1Basic.Interpreter.Test/InputTest.cs index 4aefda9..e3750e8 100644 --- a/Trs80.Level1Basic.Interpreter.Test/InputTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/InputTest.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using System.IO; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/InterpreterTest.cs b/Trs80.Level1Basic.Interpreter.Test/InterpreterTest.cs index d280b4b..0ded4e4 100644 --- a/Trs80.Level1Basic.Interpreter.Test/InterpreterTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/InterpreterTest.cs @@ -1,7 +1,9 @@ using System.Collections.Generic; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; @@ -36,7 +38,7 @@ public void Interpreter_Can_Execute_Multi_Statement_Lines() controller.ReadOutputLine().Should().Be(" 3 "); controller.IsEndOfRun().Should().BeTrue(); } - + [TestMethod] public void Interpreter_Handles_Line_Number_Zero() { diff --git a/Trs80.Level1Basic.Interpreter.Test/LineListTest.cs b/Trs80.Level1Basic.Interpreter.Test/LineListTest.cs index edadcde..1b1043e 100644 --- a/Trs80.Level1Basic.Interpreter.Test/LineListTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/LineListTest.cs @@ -2,8 +2,10 @@ using System.Diagnostics.CodeAnalysis; using FluentAssertions; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.Application; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; @@ -143,11 +145,11 @@ public void Can_Add_A_Statement_In_The_Middle_Of_LineList() secondStatement.Should().NotBeNull(); secondStatement.LineNumber.Should().Be(15); - + thirdStatement.Should().NotBeNull(); thirdStatement.LineNumber.Should().Be(20); } - + [TestMethod] public void Can_Replace_A_Statement_In_The_Middle_Of_LineList() { @@ -176,7 +178,7 @@ public void Can_Replace_A_Statement_In_The_Middle_Of_LineList() secondStatement.Should().NotBeNull(); secondStatement.LineNumber.Should().Be(20); secondStatement.SourceLine.Should().Be(newStatement); - + thirdStatement.Should().NotBeNull(); thirdStatement.LineNumber.Should().Be(30); } diff --git a/Trs80.Level1Basic.Interpreter.Test/LogicalTest.cs b/Trs80.Level1Basic.Interpreter.Test/LogicalTest.cs index 73c553a..a5695c8 100644 --- a/Trs80.Level1Basic.Interpreter.Test/LogicalTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/LogicalTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/LonghandSmokeTest.cs b/Trs80.Level1Basic.Interpreter.Test/LonghandSmokeTest.cs index 5d71626..aee58f8 100644 --- a/Trs80.Level1Basic.Interpreter.Test/LonghandSmokeTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/LonghandSmokeTest.cs @@ -4,6 +4,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/NativeFunctionTest.cs b/Trs80.Level1Basic.Interpreter.Test/NativeFunctionTest.cs index d42eb96..cd51f4c 100644 --- a/Trs80.Level1Basic.Interpreter.Test/NativeFunctionTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/NativeFunctionTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/ParserTest.cs b/Trs80.Level1Basic.Interpreter.Test/ParserTest.cs index a8faea0..5f767b3 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ParserTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ParserTest.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using FluentAssertions; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.Application; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; @@ -49,7 +51,7 @@ public void Parser_Can_Parse_A_Simple_Line_Correctly() literal.Should().NotBeNull(); string value = literal!.Value; value.Should().Be("Hello, World!"); - value = literal!.UpperValue; + value = literal.UpperValue; value.Should().Be("HELLO, WORLD!"); } } \ No newline at end of file diff --git a/Trs80.Level1Basic.Interpreter.Test/PrintTest.cs b/Trs80.Level1Basic.Interpreter.Test/PrintTest.cs index 4dfb9db..2194293 100644 --- a/Trs80.Level1Basic.Interpreter.Test/PrintTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/PrintTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/RecursionTest.cs b/Trs80.Level1Basic.Interpreter.Test/RecursionTest.cs index 21dbbd7..ecf1881 100644 --- a/Trs80.Level1Basic.Interpreter.Test/RecursionTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/RecursionTest.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using System.IO; + using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/RunTest.cs b/Trs80.Level1Basic.Interpreter.Test/RunTest.cs index 9b51fb7..a2a263a 100644 --- a/Trs80.Level1Basic.Interpreter.Test/RunTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/RunTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; diff --git a/Trs80.Level1Basic.Interpreter.Test/ScannerTest.cs b/Trs80.Level1Basic.Interpreter.Test/ScannerTest.cs index 06414b2..3ab9991 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ScannerTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ScannerTest.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using FluentAssertions; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.Application; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; diff --git a/Trs80.Level1Basic.Interpreter.Test/ShorthandTest.cs b/Trs80.Level1Basic.Interpreter.Test/ShorthandTest.cs index 348b63c..8bdaaa6 100644 --- a/Trs80.Level1Basic.Interpreter.Test/ShorthandTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/ShorthandTest.cs @@ -4,6 +4,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.TestUtilities; namespace Trs80.Level1Basic.Interpreter.Test; @@ -20,7 +21,7 @@ public void P_Is_Shorthand_For_Print() }; controller.RunProgram(program); - + controller.ReadOutputLine().Should().Be("HELLO"); controller.IsEndOfRun().Should().BeTrue(); } @@ -36,7 +37,7 @@ public void N_Is_Shorthand_For_New() controller.ExecuteStatements(program); controller.ExecuteLine("n."); controller.ExecuteLine("print mem"); - + controller.ReadOutputLine().Should().Be(" 15871 "); } diff --git a/Trs80.Level1Basic.Interpreter.Test/StatementListTest.cs b/Trs80.Level1Basic.Interpreter.Test/StatementListTest.cs index 91ae31b..d5259f8 100644 --- a/Trs80.Level1Basic.Interpreter.Test/StatementListTest.cs +++ b/Trs80.Level1Basic.Interpreter.Test/StatementListTest.cs @@ -2,8 +2,10 @@ using System.Diagnostics.CodeAnalysis; using FluentAssertions; + using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Trs80.Level1Basic.Application; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; diff --git a/Trs80.Level1Basic.TestUtilities/FakeHost.cs b/Trs80.Level1Basic.TestUtilities/FakeHost.cs index 02540f1..dacf84d 100644 --- a/Trs80.Level1Basic.TestUtilities/FakeHost.cs +++ b/Trs80.Level1Basic.TestUtilities/FakeHost.cs @@ -1,124 +1,117 @@ using Trs80.Level1Basic.HostMachine; -namespace Trs80.Level1Basic.TestUtilities +namespace Trs80.Level1Basic.TestUtilities; + +public class FakeHost : IHost { - public class FakeHost : IHost - { - private const int ScreenWidth = 64; - private const int ScreenHeight = 16; - private const int ScreenPixelWidth = 2 * ScreenWidth; - private const int ScreenPixelHeight = 3 * ScreenHeight; - private readonly bool[,] _screen = new bool[ScreenPixelWidth, ScreenPixelHeight]; - private int _cursorX; - private int _cursorY; - - public FakeHost() - { - ClearScreen(); - } - - private void ClearScreen() - { - Erase(0, 0, ScreenPixelWidth, ScreenPixelHeight); - _cursorX = 0; - _cursorY = 0; - } - - public void EnableVirtualTerminal() - { - // do nothing - } - - public HostFont GetCurrentConsoleFont() - { - return new HostFont { FontSize = 12, FontName = "Courier New" }; - } - - public void SetCurrentConsoleFont(HostFont font) - { - // do nothing - } - public (int Left, int Top) GetCursorPosition() - { - return (_cursorX, _cursorY); - } - - - public void SetCursorPosition(int column, int row) - { - _cursorX = column; - _cursorY = row; - } - - public void Clear() - { - ClearScreen(); - } - - public ConsoleKeyInfo ReadKey() - { - return new ConsoleKeyInfo(); - } - - public void SetWindowSize(int width, int height) - { - // do nothing - } - - public void SetBufferSize(int width, int height) - { - // do nothing - } - - public void Fill(int x, int y, int width, int height) - { - for (int xIndex = x; xIndex < x + width; xIndex++) - for (int yIndex = y; yIndex < y + height; yIndex++) - _screen[xIndex, yIndex] = true; - } - - public void Erase(int x, int y, int width, int height) - { - for (int xIndex = x; xIndex < x + width; xIndex++) - for (int yIndex = y; yIndex < y + height; yIndex++) - _screen[xIndex, yIndex] = false; - } - - public TextWriter Out { get; set; } = Console.Out; - public TextReader In { get; set; } = Console.In; - public TextWriter Error { get; set; } = Console.Error; - public void WriteLine(string text = "") - { - Out.WriteLine(text); - _cursorX = 0; - _cursorY++; - } - - public void Write(string text) - { - Out.Write(text); - _cursorX += text.Length; - } - - public void Write(char c) - { - Out.Write(c); - _cursorX++; - } - - public string ReadLine() - { - return In.ReadLine()!.ToUpperInvariant(); - } - - public string GetFileNameForSave() - { - return string.Empty; - } - - public string GetFileNameForLoad() - { - return string.Empty; - } - } -} + private const int ScreenWidth = 64; + private const int ScreenHeight = 16; + private const int ScreenPixelWidth = 2 * ScreenWidth; + private const int ScreenPixelHeight = 3 * ScreenHeight; + private readonly bool[,] _screen = new bool[ScreenPixelWidth, ScreenPixelHeight]; + private int _cursorX; + private int _cursorY; + + public FakeHost() + { + ClearScreen(); + } + + private void ClearScreen() + { + Erase(0, 0, ScreenPixelWidth, ScreenPixelHeight); + _cursorX = 0; + _cursorY = 0; + } + + public void EnableVirtualTerminal() + { + // do nothing + } + + public HostFont GetCurrentConsoleFont() + { + return new HostFont { FontSize = 12, FontName = "Courier New" }; + } + + public void SetCurrentConsoleFont(HostFont font) + { + // do nothing + } + public (int Left, int Top) GetCursorPosition() + { + return (_cursorX, _cursorY); + } + + + public void SetCursorPosition(int column, int row) + { + _cursorX = column; + _cursorY = row; + } + + public void Clear() + { + ClearScreen(); + } + + public ConsoleKeyInfo ReadKey() + { + return new ConsoleKeyInfo(); + } + + public void SetWindowSize(int width, int height) + { + // do nothing + } + + public void SetBufferSize(int width, int height) + { + // do nothing + } + + public void Fill(int x, int y, int width, int height) + { + for (int xIndex = x; xIndex < x + width; xIndex++) + for (int yIndex = y; yIndex < y + height; yIndex++) + _screen[xIndex, yIndex] = true; + } + + public void Erase(int x, int y, int width, int height) + { + for (int xIndex = x; xIndex < x + width; xIndex++) + for (int yIndex = y; yIndex < y + height; yIndex++) + _screen[xIndex, yIndex] = false; + } + + public TextWriter Out { get; set; } = Console.Out; + public TextReader In { get; set; } = Console.In; + public TextWriter Error { get; set; } = Console.Error; + public void WriteLine(string text = "") + { + Out.WriteLine(text); + _cursorX = 0; + _cursorY++; + } + + public void Write(string text) + { + Out.Write(text); + _cursorX += text.Length; + } + + public string ReadLine() + { + return In.ReadLine()!.ToUpperInvariant(); + } + + public string GetFileNameForSave() + { + return string.Empty; + } + + public string GetFileNameForLoad() + { + return string.Empty; + } +} \ No newline at end of file diff --git a/Trs80.Level1Basic.TestUtilities/TestController.cs b/Trs80.Level1Basic.TestUtilities/TestController.cs index 187b711..e9f3a9d 100644 --- a/Trs80.Level1Basic.TestUtilities/TestController.cs +++ b/Trs80.Level1Basic.TestUtilities/TestController.cs @@ -46,7 +46,7 @@ public TestController() _scanner = new Scanner(Trs80, natives); _parser = new Parser(Trs80, natives); IProgram program = new Program(_scanner, _parser); - IMachine environment = new Machine(Trs80, program, natives); + IMachine environment = new Machine(Trs80, program); ITrs80Api trs80Api = new Trs80Api(program, Trs80); _interpreter = new Interpreter(host, Trs80, trs80Api, environment, program); } diff --git a/Trs80.Level1Basic.Trs80.Test/Trs80Test.cs b/Trs80.Level1Basic.Trs80.Test/Trs80Test.cs index 3387ac5..b7102d5 100644 --- a/Trs80.Level1Basic.Trs80.Test/Trs80Test.cs +++ b/Trs80.Level1Basic.Trs80.Test/Trs80Test.cs @@ -9,10 +9,6 @@ using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; using Trs80.Level1Basic.TestUtilities; -using Trs80.Level1Basic.VirtualMachine.Interpreter; -using Trs80.Level1Basic.VirtualMachine.Machine; -using Trs80.Level1Basic.VirtualMachine.Parser; -using Trs80.Level1Basic.VirtualMachine.Scanner; namespace Trs80.Level1Basic.Trs80.Test; @@ -35,7 +31,7 @@ public void Can_Replace_In_And_Out() { IHost host = new FakeHost(); var trs80 = new VirtualMachine.Machine.Trs80(_appSettings, _loggerFactory, host); - + const string input = "Hello, World!\r\n"; var sw = new StringWriter(); var sr = new StringReader(input); diff --git a/Trs80.Level1Basic.VirtualMachine/Exceptions/ExceptionHandler.cs b/Trs80.Level1Basic.VirtualMachine/Exceptions/ExceptionHandler.cs index 01c7fab..afbfeac 100644 --- a/Trs80.Level1Basic.VirtualMachine/Exceptions/ExceptionHandler.cs +++ b/Trs80.Level1Basic.VirtualMachine/Exceptions/ExceptionHandler.cs @@ -1,6 +1,6 @@ using System; using System.Diagnostics; -using Trs80.Level1Basic.HostMachine; + using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Exceptions; diff --git a/Trs80.Level1Basic.VirtualMachine/Exceptions/LoopAfterNext.cs b/Trs80.Level1Basic.VirtualMachine/Exceptions/LoopAfterNext.cs index 38efef5..63c91b2 100644 --- a/Trs80.Level1Basic.VirtualMachine/Exceptions/LoopAfterNext.cs +++ b/Trs80.Level1Basic.VirtualMachine/Exceptions/LoopAfterNext.cs @@ -1,5 +1,4 @@ - -using System; +using System; namespace Trs80.Level1Basic.VirtualMachine.Exceptions; diff --git a/Trs80.Level1Basic.VirtualMachine/Exceptions/ReturnFromGosub.cs b/Trs80.Level1Basic.VirtualMachine/Exceptions/ReturnFromGosub.cs index 3138213..1977002 100644 --- a/Trs80.Level1Basic.VirtualMachine/Exceptions/ReturnFromGosub.cs +++ b/Trs80.Level1Basic.VirtualMachine/Exceptions/ReturnFromGosub.cs @@ -1,5 +1,4 @@ - -using System; +using System; namespace Trs80.Level1Basic.VirtualMachine.Exceptions; diff --git a/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeExpressionException.cs b/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeExpressionException.cs index 6a642bf..478ce38 100644 --- a/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeExpressionException.cs +++ b/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeExpressionException.cs @@ -1,4 +1,5 @@ using System; + using Trs80.Level1Basic.VirtualMachine.Scanner; namespace Trs80.Level1Basic.VirtualMachine.Exceptions; diff --git a/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeStatementException.cs b/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeStatementException.cs index 304ce61..4dacdd8 100644 --- a/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeStatementException.cs +++ b/Trs80.Level1Basic.VirtualMachine/Exceptions/RuntimeStatementException.cs @@ -12,11 +12,4 @@ public RuntimeStatementException(int lineNumber, string statement, string messag LineNumber = lineNumber; Statement = statement; } - - public RuntimeStatementException(int lineNumber, string statement, string message, Exception innerException) : base(message, innerException) - { - LineNumber = lineNumber; - Statement = statement; - } - } \ No newline at end of file diff --git a/Trs80.Level1Basic.VirtualMachine/Interpreter/FileDialog.cs b/Trs80.Level1Basic.VirtualMachine/Interpreter/FileDialog.cs deleted file mode 100644 index 412a924..0000000 --- a/Trs80.Level1Basic.VirtualMachine/Interpreter/FileDialog.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Trs80.Level1Basic.VirtualMachine.Interpreter -{ - internal class FileDialog - { - } -} diff --git a/Trs80.Level1Basic.VirtualMachine/Interpreter/Interpreter.cs b/Trs80.Level1Basic.VirtualMachine/Interpreter/Interpreter.cs index 1fd2c52..81b6c9b 100644 --- a/Trs80.Level1Basic.VirtualMachine/Interpreter/Interpreter.cs +++ b/Trs80.Level1Basic.VirtualMachine/Interpreter/Interpreter.cs @@ -1,11 +1,11 @@ using System; -using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; -using Trs80.Level1Basic.VirtualMachine.Exceptions; + using Trs80.Level1Basic.Common.Extensions; using Trs80.Level1Basic.HostMachine; +using Trs80.Level1Basic.VirtualMachine.Exceptions; using Trs80.Level1Basic.VirtualMachine.Machine; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; @@ -43,7 +43,7 @@ public void Interpret(IStatement statement) } - private dynamic Evaluate(Parser.Expressions.Expression expression) + private dynamic Evaluate(Expression expression) { return expression.Accept(this); } @@ -60,7 +60,7 @@ public dynamic VisitAssignExpression(Assign expression) return Assign(expression, value); } - private dynamic Assign(Parser.Expressions.Expression expression, dynamic value) + private dynamic Assign(Expression expression, dynamic value) { switch (expression) { @@ -232,7 +232,7 @@ private string StringifyFloat(float value) return "0"; if (value < .1 && value > -.1) return value.ToString("0.#####E+00"); - if (value < 1 && value > -1) + if (value is < 1 and > -1) return value.ToString(".######"); if (value > 999999 || value < -999999) return value.ToString("0.#####E+00"); @@ -283,7 +283,7 @@ public void RunProgram(IStatement statement, bool initialize) public Common.Void VisitDataStatement(Data statement) { - foreach (Parser.Expressions.Expression element in statement.DataElements) + foreach (Expression element in statement.DataElements) _machine.Data.Add(Evaluate(element)); return null!; @@ -343,7 +343,7 @@ public Common.Void VisitGosubStatement(Gosub statement) return null!; } - private IStatement GetJumpToStatement(Statement statement, Parser.Expressions.Expression location, string jumpType) + private IStatement GetJumpToStatement(Statement statement, Expression location, string jumpType) { dynamic jumpToLineNumber = Evaluate(location); @@ -379,13 +379,13 @@ public Common.Void VisitIfStatement(If statement) public Common.Void VisitInputStatement(Input statement) { - foreach (Parser.Expressions.Expression expression in statement.Expressions) + foreach (Expression expression in statement.Expressions) ProcessInputExpression(expression, statement.WriteNewline); return null!; } - private void ProcessInputExpression(Parser.Expressions.Expression expression, bool writeNewline) + private void ProcessInputExpression(Expression expression, bool writeNewline) { switch (expression) { @@ -401,7 +401,7 @@ private void ProcessInputExpression(Parser.Expressions.Expression expression, bo } } - private void GetInputValue(Parser.Expressions.Expression variable, bool writeNewline) + private void GetInputValue(Expression variable, bool writeNewline) { _trs80.Write("?"); @@ -421,7 +421,6 @@ private void GetInputValue(Parser.Expressions.Expression variable, bool writeNew Assign(variable, lookup); } else - { try { Assign(variable, value); @@ -431,7 +430,6 @@ private void GetInputValue(Parser.Expressions.Expression variable, bool writeNew _trs80.WriteLine(" 0 WHAT?"); GetInputValue(variable, writeNewline); } - } } public Common.Void VisitLetStatement(Let statement) @@ -453,7 +451,7 @@ public Common.Void VisitListStatement(List statement) return null!; } - private int GetStartingLineNumber(Parser.Expressions.Expression startAtLineNumber) + private int GetStartingLineNumber(Expression startAtLineNumber) { int lineNumber = -1; dynamic value = Evaluate(startAtLineNumber); @@ -478,7 +476,7 @@ public Common.Void VisitLoadStatement(Load statement) return null!; } - private string EvaluatePath(Parser.Expressions.Expression pathExpression) + private string EvaluatePath(Expression pathExpression) { string path; if (pathExpression is Literal literalPath) @@ -514,7 +512,7 @@ public Common.Void VisitNextStatement(Next statement) throw new LoopAfterNext(); } - private dynamic IncrementIndexer(Parser.Expressions.Expression identifier, int step) + private dynamic IncrementIndexer(Expression identifier, int step) { dynamic currentValue = Evaluate(identifier); dynamic newValue = currentValue + step; @@ -532,7 +530,7 @@ public Common.Void VisitOnStatement(On statement) if (statement.IsGosub) { IStatement resumeStatement = _machine.GetNextStatement(statement); - Parser.Expressions.Expression location = new Literal(locations[selector], null); + Expression location = new Literal(locations[selector], null); IStatement jumpToStatement = GetJumpToStatement(statement, location, "GOSUB"); ExecuteGosub(jumpToStatement, resumeStatement); @@ -564,11 +562,11 @@ private void ExecuteGosub(IStatement jumpToStatement, IStatement resumeStatement public Common.Void VisitPrintStatement(Print statement) { - if (statement.AtPosition != null) + if (statement.AtPosition != null) PrintAt(statement.AtPosition); if (statement.Expressions is { Count: > 0 }) - foreach (Parser.Expressions.Expression expression in statement.Expressions) + foreach (Expression expression in statement.Expressions) _trs80.Write(Stringify(Evaluate(expression))); if (!statement.WriteNewline) return null!; @@ -580,7 +578,7 @@ public Common.Void VisitPrintStatement(Print statement) return null!; } - private void PrintAt(Parser.Expressions.Expression position) + private void PrintAt(Expression position) { dynamic value = Evaluate(position); dynamic row = value / 64; @@ -594,7 +592,7 @@ private void PrintAt(Parser.Expressions.Expression position) public Common.Void VisitReadStatement(Read statement) { - foreach (Parser.Expressions.Expression variable in statement.Variables) + foreach (Expression variable in statement.Variables) Assign(variable, _machine.Data.GetNext()); return null!; diff --git a/Trs80.Level1Basic.VirtualMachine/Interpreter/Program.cs b/Trs80.Level1Basic.VirtualMachine/Interpreter/Program.cs index decd8a9..0d352f6 100644 --- a/Trs80.Level1Basic.VirtualMachine/Interpreter/Program.cs +++ b/Trs80.Level1Basic.VirtualMachine/Interpreter/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; + using Trs80.Level1Basic.Common; using Trs80.Level1Basic.VirtualMachine.Parser; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; @@ -59,7 +60,7 @@ public void Load(string path) { string original = reader.ReadLine(); string line = original?.ToUpper(); - List tokens = _scanner.ScanTokens(new SourceLine { Line = line, Original = original}); + List tokens = _scanner.ScanTokens(new SourceLine { Line = line, Original = original }); IStatement statement = _parser.Parse(tokens); AddStatement(statement); } diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/ICallable.cs b/Trs80.Level1Basic.VirtualMachine/Machine/ICallable.cs index 50f5b79..9530518 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/ICallable.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/ICallable.cs @@ -5,6 +5,7 @@ namespace Trs80.Level1Basic.VirtualMachine.Machine; public interface ICallable { + // ReSharper disable once UnusedMemberInSuper.Global int Arity { get; set; } Func, dynamic> Call { get; set; } } \ No newline at end of file diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/IMachine.cs b/Trs80.Level1Basic.VirtualMachine/Machine/IMachine.cs index fcff368..f03c243 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/IMachine.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/IMachine.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Interpreter; +using Trs80.Level1Basic.VirtualMachine.Interpreter; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; namespace Trs80.Level1Basic.VirtualMachine.Machine; @@ -10,14 +9,12 @@ public interface IMachine IProgram Program { get; } int CursorX { get; set; } int CursorY { get; set; } - public bool ExecutionHalted { get; set; } dynamic Set(string name, dynamic value); dynamic Set(string name, int index, dynamic value); dynamic Get(string name); dynamic Get(string name, int index); bool Exists(string name); - List Function(string name); void InitializeProgram(); void ListProgram(int lineNumber); void SaveProgram(string path); diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/ITrs80.cs b/Trs80.Level1Basic.VirtualMachine/Machine/ITrs80.cs index 9517d70..00d72ff 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/ITrs80.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/ITrs80.cs @@ -1,5 +1,6 @@ using System; using System.IO; + using Trs80.Level1Basic.HostMachine; namespace Trs80.Level1Basic.VirtualMachine.Machine; diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/Machine.cs b/Trs80.Level1Basic.VirtualMachine/Machine/Machine.cs index 81853b3..d138006 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/Machine.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/Machine.cs @@ -1,7 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; + using Trs80.Level1Basic.VirtualMachine.Interpreter; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; @@ -11,7 +11,6 @@ public class Machine : IMachine { private readonly Interpreter.Environment _globals = new(); private readonly ITrs80 _trs80; - private readonly INativeFunctions _natives; private IStatement _nextStatement; public int CursorX { get; set; } @@ -20,11 +19,10 @@ public class Machine : IMachine public IProgram Program { get; } public bool ExecutionHalted { get; set; } - public Machine(ITrs80 trs80, IProgram program, INativeFunctions natives) + public Machine(ITrs80 trs80, IProgram program) { _trs80 = trs80 ?? throw new ArgumentNullException(nameof(trs80)); Program = program ?? throw new ArgumentNullException(nameof(program)); - _natives = natives ?? throw new ArgumentNullException(nameof(natives)); Console.CancelKeyPress += delegate (object _, ConsoleCancelEventArgs e) { @@ -38,14 +36,14 @@ public void InitializeProgram() Program.Initialize(); GetCursorPosition(); } - + private void GetCursorPosition() { (int left, int top) = _trs80.GetCursorPosition(); CursorX = left; CursorY = top; } - + public dynamic Set(string name, dynamic value) { return _globals.Set(name, value); @@ -56,11 +54,6 @@ public dynamic Set(string name, int index, dynamic value) return _globals.AssignArray(name, index, value); } - public List Function(string name) - { - return _natives.Get(name); - } - public bool Exists(string name) { return _globals.Exists(name); diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/NativeFunctions.cs b/Trs80.Level1Basic.VirtualMachine/Machine/NativeFunctions.cs index 354a101..ab0eaa7 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/NativeFunctions.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/NativeFunctions.cs @@ -12,7 +12,7 @@ public NativeFunctions() { _functions = new Dictionary> { - {"_padquadrant", new List { new() {Arity = 0, Call = (api, arg) => api.PadQuadrant()}}}, + {"_pad_quadrant", new List { new() {Arity = 0, Call = (api, arg) => api.PadQuadrant()}}}, {"abs", new List { new() {Arity = 1, Call = (api, arg) => api.Abs(arg[0])}}}, {"a.", new List { new() {Arity = 1, Call = (api, arg) => api.Abs(arg[0])}}}, {"chr$", new List { new() {Arity = 1, Call = (api, arg) => api.Chr(arg[0])}}}, diff --git a/Trs80.Level1Basic.VirtualMachine/Machine/Trs80.cs b/Trs80.Level1Basic.VirtualMachine/Machine/Trs80.cs index 7533c2d..2d13a4a 100644 --- a/Trs80.Level1Basic.VirtualMachine/Machine/Trs80.cs +++ b/Trs80.Level1Basic.VirtualMachine/Machine/Trs80.cs @@ -2,9 +2,9 @@ using System.IO; using Microsoft.Extensions.Logging; + using Trs80.Level1Basic.Common; using Trs80.Level1Basic.HostMachine; -using Trs80.Level1Basic.VirtualMachine.Interpreter; namespace Trs80.Level1Basic.VirtualMachine.Machine; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Array.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Array.cs index 118f101..29edc08 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Array.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Array.cs @@ -5,9 +5,7 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Assign.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Assign.cs index 151fe36..dd0d0e8 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Assign.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Assign.cs @@ -5,9 +5,7 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Binary.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Binary.cs index 8070dde..98681ee 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Binary.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Binary.cs @@ -5,9 +5,7 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Expression.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Expression.cs index c035349..7451378 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Expression.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Expression.cs @@ -5,10 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; public abstract class Expression diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Grouping.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Grouping.cs index 558ddcb..4697f34 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Grouping.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Grouping.cs @@ -5,10 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; public class Grouping : Expression diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Identifier.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Identifier.cs index d7a4cdf..b5bc952 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Identifier.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Identifier.cs @@ -5,9 +5,7 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Literal.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Literal.cs index 96de903..a232dd0 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Literal.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Literal.cs @@ -5,10 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; public class Literal : Expression diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Unary.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Unary.cs index 3ff9355..4ed11ac 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Unary.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Expressions/Unary.cs @@ -5,9 +5,7 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Scanner; -using Trs80.Level1Basic.VirtualMachine.Machine; namespace Trs80.Level1Basic.VirtualMachine.Parser.Expressions; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/IParser.cs b/Trs80.Level1Basic.VirtualMachine/Parser/IParser.cs index c9956cc..bb0be0b 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/IParser.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/IParser.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using Trs80.Level1Basic.VirtualMachine.Parser.Statements; using Trs80.Level1Basic.VirtualMachine.Scanner; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Parser.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Parser.cs index 2e90fd1..82fcde5 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Parser.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Parser.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Trs80.Level1Basic.HostMachine; + using Trs80.Level1Basic.VirtualMachine.Exceptions; using Trs80.Level1Basic.VirtualMachine.Machine; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; @@ -24,7 +24,7 @@ public Parser(ITrs80 trs80, INativeFunctions natives) { _trs80 = trs80 ?? throw new ArgumentNullException(nameof(trs80)); _natives = natives ?? throw new ArgumentNullException(nameof(natives)); - _padQuadrant = _natives.Get("_padquadrant").First(); + _padQuadrant = _natives.Get("_pad_quadrant").First(); } public IStatement Parse(List tokens) @@ -298,8 +298,8 @@ private IStatement InputStatement() new Call( new Token( TokenType.Identifier, - "_padquadrant", - "_padquadrant", + "_pad_quadrant", + "_pad_quadrant", null, 0 ), @@ -475,8 +475,8 @@ private IStatement PrintStatement() new Call( new Token( TokenType.Identifier, - "_padquadrant", - "_padquadrant", + "_pad_quadrant", + "_pad_quadrant", null, 0 ), diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cls.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cls.cs index f193b0f..81c928e 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cls.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cls.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Cls : Statement { - - public Cls() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitClsStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Compound.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Compound.cs index 6fafa6d..76ba451 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Compound.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Compound.cs @@ -5,9 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Compound : Statement diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/CompoundStatementList.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/CompoundStatementList.cs index 32445be..414b627 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/CompoundStatementList.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/CompoundStatementList.cs @@ -8,11 +8,9 @@ public class CompoundStatementList : Statement, ICollection { private readonly List _statements = new(); - //public IStatement Enclosing { get; set; } - private IListStatementDecorator Decorate(IStatement statement) { - return statement is IListStatementDecorator decorated ? decorated : new ListStatementDecorator(statement); + return statement as IListStatementDecorator ?? new ListStatementDecorator(statement); } public void Add(IStatement item) diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cont.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cont.cs index 334239e..5bddc14 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cont.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Cont.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Cont : Statement { - - public Cont() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitContStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Delete.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Delete.cs index c1160e9..b9fc2d6 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Delete.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Delete.cs @@ -5,9 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Delete : Statement diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/End.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/End.cs index a53d118..83a627f 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/End.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/End.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class End : Statement { - - public End() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitEndStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/For.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/For.cs index 780fbd3..b3828f6 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/For.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/For.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Gosub.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Gosub.cs index b1fe034..1276b85 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Gosub.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Gosub.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Goto.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Goto.cs index fd0c8bb..4cf9548 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Goto.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Goto.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/IStatement.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/IStatement.cs index fb3743e..e82e3ef 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/IStatement.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/IStatement.cs @@ -5,9 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public interface IStatement diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/If.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/If.cs index 3f4c89c..caf26e9 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/If.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/If.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Let.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Let.cs index a254695..77f2f74 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Let.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Let.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/List.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/List.cs index 42221a3..10dbf0d 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/List.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/List.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Load.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Load.cs index c59b1e9..d43e32e 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Load.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Load.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Merge.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Merge.cs index 05731c6..2c90f9c 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Merge.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Merge.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/New.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/New.cs index 96457b6..905f83b 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/New.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/New.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class New : Statement { - - public New() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitNewStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Next.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Next.cs index 819762d..c165189 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Next.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Next.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Rem.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Rem.cs index 39a4ac9..d87aba8 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Rem.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Rem.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Replace.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Replace.cs index 6eba461..4c0c63e 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Replace.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Replace.cs @@ -5,9 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Replace : Statement diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Restore.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Restore.cs index 9455123..8fa4f46 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Restore.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Restore.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Restore : Statement { - - public Restore() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitRestoreStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Return.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Return.cs index 82034a6..548810f 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Return.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Return.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Return : Statement { - - public Return() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitReturnStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Run.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Run.cs index 4296c2d..5a996c1 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Run.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Run.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Save.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Save.cs index 7d69a99..59d6e8e 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Save.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Save.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Statement.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Statement.cs index 217ded3..7a0ff7b 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Statement.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Statement.cs @@ -5,9 +5,6 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public abstract class Statement: IStatement diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/StatementExpression.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/StatementExpression.cs index 3fe1adf..104d9cc 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/StatementExpression.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/StatementExpression.cs @@ -5,7 +5,6 @@ // // -using System.Collections.Generic; using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; diff --git a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Stop.cs b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Stop.cs index 2773ab0..03677e7 100644 --- a/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Stop.cs +++ b/Trs80.Level1Basic.VirtualMachine/Parser/Statements/Stop.cs @@ -5,18 +5,10 @@ // // -using System.Collections.Generic; -using Trs80.Level1Basic.VirtualMachine.Parser.Expressions; - namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements; public class Stop : Statement { - - public Stop() - { - } - public override T Accept(IVisitor visitor) { return visitor.VisitStopStatement(this); diff --git a/Trs80.Level1Basic.VirtualMachine/Scanner/IScanner.cs b/Trs80.Level1Basic.VirtualMachine/Scanner/IScanner.cs index 23b9494..45b9a89 100644 --- a/Trs80.Level1Basic.VirtualMachine/Scanner/IScanner.cs +++ b/Trs80.Level1Basic.VirtualMachine/Scanner/IScanner.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using Trs80.Level1Basic.Common; namespace Trs80.Level1Basic.VirtualMachine.Scanner; diff --git a/Trs80.Level1Basic.VirtualMachine/Scanner/Scanner.cs b/Trs80.Level1Basic.VirtualMachine/Scanner/Scanner.cs index 2975d16..a7715b3 100644 --- a/Trs80.Level1Basic.VirtualMachine/Scanner/Scanner.cs +++ b/Trs80.Level1Basic.VirtualMachine/Scanner/Scanner.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Trs80.Level1Basic.Common; -using Trs80.Level1Basic.HostMachine; using Trs80.Level1Basic.VirtualMachine.Exceptions; using Trs80.Level1Basic.VirtualMachine.Machine; diff --git a/Trs80.Level1Basic.Workflow/IInputStep.cs b/Trs80.Level1Basic.Workflow/IInputStep.cs index ba7e9ae..f826ebb 100644 --- a/Trs80.Level1Basic.Workflow/IInputStep.cs +++ b/Trs80.Level1Basic.Workflow/IInputStep.cs @@ -1,8 +1,12 @@ -using Trs80.Level1Basic.Common; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Common; + using WorkflowCore.Interface; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] public interface IInputStep : IStepBody { bool WritePrompt { get; set; } diff --git a/Trs80.Level1Basic.Workflow/IInterpretStep.cs b/Trs80.Level1Basic.Workflow/IInterpretStep.cs index 5f91a9c..3fbfc5b 100644 --- a/Trs80.Level1Basic.Workflow/IInterpretStep.cs +++ b/Trs80.Level1Basic.Workflow/IInterpretStep.cs @@ -1,4 +1,5 @@ using Trs80.Level1Basic.VirtualMachine.Parser.Statements; + using WorkflowCore.Interface; namespace Trs80.Level1Basic.Workflow; diff --git a/Trs80.Level1Basic.Workflow/IParseStep.cs b/Trs80.Level1Basic.Workflow/IParseStep.cs index e806c06..19f07df 100644 --- a/Trs80.Level1Basic.Workflow/IParseStep.cs +++ b/Trs80.Level1Basic.Workflow/IParseStep.cs @@ -1,11 +1,15 @@ -using Trs80.Level1Basic.VirtualMachine.Parser.Statements; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.VirtualMachine.Parser.Statements; using Trs80.Level1Basic.VirtualMachine.Scanner; + using WorkflowCore.Interface; namespace Trs80.Level1Basic.Workflow; public interface IParseStep : IStepBody { + [SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] List Tokens { get; set; } IStatement Statement { get; set; } } \ No newline at end of file diff --git a/Trs80.Level1Basic.Workflow/IScanStep.cs b/Trs80.Level1Basic.Workflow/IScanStep.cs index 1e4085c..dd9bbbc 100644 --- a/Trs80.Level1Basic.Workflow/IScanStep.cs +++ b/Trs80.Level1Basic.Workflow/IScanStep.cs @@ -1,9 +1,13 @@ -using Trs80.Level1Basic.Common; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Common; using Trs80.Level1Basic.VirtualMachine.Scanner; + using WorkflowCore.Interface; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")] public interface IScanStep : IStepBody { SourceLine SourceLine { get; set; } diff --git a/Trs80.Level1Basic.Workflow/InputStep.cs b/Trs80.Level1Basic.Workflow/InputStep.cs index 7c64c70..fb67aec 100644 --- a/Trs80.Level1Basic.Workflow/InputStep.cs +++ b/Trs80.Level1Basic.Workflow/InputStep.cs @@ -1,11 +1,15 @@ -using Trs80.Level1Basic.Command; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Command; using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.Common; + using WorkflowCore.Interface; using WorkflowCore.Models; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class InputStep : StepBody, IInputStep { private readonly ICommand _command; @@ -20,7 +24,8 @@ public InputStep(ICommand inboundCommand) public override ExecutionResult Run(IStepExecutionContext context) { - var model = new InputModel { + var model = new InputModel + { WritePrompt = WritePrompt }; diff --git a/Trs80.Level1Basic.Workflow/InterpretStep.cs b/Trs80.Level1Basic.Workflow/InterpretStep.cs index eff9da4..b11aa55 100644 --- a/Trs80.Level1Basic.Workflow/InterpretStep.cs +++ b/Trs80.Level1Basic.Workflow/InterpretStep.cs @@ -1,11 +1,15 @@ -using Trs80.Level1Basic.Command; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Command; using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; + using WorkflowCore.Interface; using WorkflowCore.Models; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class InterpretStep : StepBody, IInterpretStep { private readonly ICommand _command; diff --git a/Trs80.Level1Basic.Workflow/ParseStep.cs b/Trs80.Level1Basic.Workflow/ParseStep.cs index ae44c00..4b71b4c 100644 --- a/Trs80.Level1Basic.Workflow/ParseStep.cs +++ b/Trs80.Level1Basic.Workflow/ParseStep.cs @@ -1,12 +1,16 @@ -using Trs80.Level1Basic.Command; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Command; using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.VirtualMachine.Parser.Statements; using Trs80.Level1Basic.VirtualMachine.Scanner; + using WorkflowCore.Interface; using WorkflowCore.Models; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class ParseStep : StepBody, IParseStep { private readonly ICommand _command; diff --git a/Trs80.Level1Basic.Workflow/ScanStep.cs b/Trs80.Level1Basic.Workflow/ScanStep.cs index 6e5bbcb..3a427c1 100644 --- a/Trs80.Level1Basic.Workflow/ScanStep.cs +++ b/Trs80.Level1Basic.Workflow/ScanStep.cs @@ -2,6 +2,7 @@ using Trs80.Level1Basic.CommandModels; using Trs80.Level1Basic.Common; using Trs80.Level1Basic.VirtualMachine.Scanner; + using WorkflowCore.Interface; using WorkflowCore.Models; diff --git a/Trs80.Level1Basic.Workflow/SetupConsoleStep.cs b/Trs80.Level1Basic.Workflow/SetupConsoleStep.cs index 19ce743..6cd8573 100644 --- a/Trs80.Level1Basic.Workflow/SetupConsoleStep.cs +++ b/Trs80.Level1Basic.Workflow/SetupConsoleStep.cs @@ -1,10 +1,14 @@ -using Trs80.Level1Basic.Command; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Command; using Trs80.Level1Basic.CommandModels; + using WorkflowCore.Interface; using WorkflowCore.Models; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class SetupConsoleStep : StepBody, ISetupConsoleStep { private readonly ICommand _command; diff --git a/Trs80.Level1Basic.Workflow/ShutdownConsoleStep.cs b/Trs80.Level1Basic.Workflow/ShutdownConsoleStep.cs index c3587d5..dcb377c 100644 --- a/Trs80.Level1Basic.Workflow/ShutdownConsoleStep.cs +++ b/Trs80.Level1Basic.Workflow/ShutdownConsoleStep.cs @@ -1,10 +1,14 @@ -using Trs80.Level1Basic.Command; +using System.Diagnostics.CodeAnalysis; + +using Trs80.Level1Basic.Command; using Trs80.Level1Basic.CommandModels; + using WorkflowCore.Interface; using WorkflowCore.Models; namespace Trs80.Level1Basic.Workflow; +[SuppressMessage("ReSharper", "UnusedMember.Global")] public class ShutdownConsoleStep : StepBody, IShutdownConsoleStep { private readonly ICommand _command; diff --git a/Trs80.Level1Basic.sln.DotSettings b/Trs80.Level1Basic.sln.DotSettings index b78c7ce..3bda546 100644 --- a/Trs80.Level1Basic.sln.DotSettings +++ b/Trs80.Level1Basic.sln.DotSettings @@ -1,10 +1,12 @@  True True + True True True True True + True True True True diff --git a/Trs80.Level1Basic/Program.cs b/Trs80.Level1Basic/Program.cs index b519c7e..a337c78 100644 --- a/Trs80.Level1Basic/Program.cs +++ b/Trs80.Level1Basic/Program.cs @@ -1,4 +1,5 @@ using System; + using Trs80.Level1Basic.Application; namespace Trs80.Level1Basic;