From 65a7b0e497d7f850720a7a1aeb8cf8b95e6371ce Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Wed, 24 Mar 2021 13:03:51 +1300 Subject: [PATCH] Removed curly braces from the start and end of the program (Closes #9) --- Assignment 1/Program.cs | 17 +++++++++-------- Assignment 1/Properties/launchSettings.json | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index f7e0cb1..21fb665 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -50,13 +50,13 @@ namespace Assignment_1 MemoryStream sourceStream = new(1024); Parser parser = new(); bool dynamicInput = false; - foreach (var arg in args) + /*foreach (var arg in args) { if (arg == "-ns") { nonStrict = true; } - } + }*/ // From https://stackoverflow.com/questions/3453220/how-to-detect-if-console-in-stdin-has-been-redirected // Reading from pipes is equivalent to reading user input, though the input is redirected if (Console.IsInputRedirected) @@ -71,7 +71,7 @@ namespace Assignment_1 } else { - sourceStream.Write(Encoding.UTF8.GetBytes("{ \r\n")); + //sourceStream.Write(Encoding.UTF8.GetBytes("{ \r\n")); sourceStream.Position = 0; dynamicInput = true; } @@ -157,12 +157,13 @@ namespace Assignment_1 public void StartParsing(Stream source, bool dynamicInput = false) { long initSourceLength = source.Length; - if (nonStrict || PeekChar(source) == '{') + //if (nonStrict || PeekChar(source) == '{') + if (true) { - if (PeekChar(source) == '{') + /*if (PeekChar(source) == '{') { source.ReadByte(); - } + }*/ long lastLinePos = 0; long initPos = 0; bool cont = false; @@ -416,7 +417,7 @@ namespace Assignment_1 consoleOutput.Append(string.Format("┌" + new string('─', keyWidth) + "┬" + new string('─', valueWidth) + "┬" + new string('─', flagWidth) + "┐\n")); consoleOutput.Append(string.Format("│{0}│{1}│{2}│\n", CenterString("Symbol", keyWidth), CenterString("Value", valueWidth), CenterString("Flags", flagWidth))); // Figure out how many symbols are eligible for printing - List eligibleKeys = new List(Symbols.Count); + List eligibleKeys = new(Symbols.Count); foreach (var item in Symbols.Keys) { if (!Symbols[item].Item2.HasFlag(VariableFlags.NoPrint) || (Symbols[item].Item2.HasFlag(VariableFlags.NoPrint) && printUnprint)) @@ -464,7 +465,7 @@ namespace Assignment_1 { path = Path.Combine(Environment.CurrentDirectory, path); // insert the final closing bracket - source.WriteByte((byte)'}'); + //source.WriteByte((byte)'}'); source.Position = 0; using (FileStream fs = File.OpenWrite(path)) { diff --git a/Assignment 1/Properties/launchSettings.json b/Assignment 1/Properties/launchSettings.json index 2c1322f..c9e0dc2 100644 --- a/Assignment 1/Properties/launchSettings.json +++ b/Assignment 1/Properties/launchSettings.json @@ -7,6 +7,26 @@ "commandName": "Executable", "executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "commandLineArgs": "-command \"& type .\\ExampleOutput.txt | & '.\\Assignment 1.exe'\"" + }, + "Example1": { + "commandName": "Executable", + "executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "commandLineArgs": "-command \"& type .\\Example1.txt | & '.\\Assignment 1.exe'\"" + }, + "Example2": { + "commandName": "Executable", + "executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "commandLineArgs": "-command \"& type .\\example2.txt | & '.\\Assignment 1.exe'\"" + }, + "Example3": { + "commandName": "Executable", + "executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "commandLineArgs": "-command \"& type .\\example3.txt | & '.\\Assignment 1.exe'\"" + }, + "Example4": { + "commandName": "Executable", + "executablePath": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "commandLineArgs": "-command \"& type .\\example4.txt | & '.\\Assignment 1.exe'\"" } } } \ No newline at end of file