Removed curly braces from the start and end of the program (Closes #9)
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed

This commit is contained in:
Brychan Dempsey 2021-03-24 13:03:51 +13:00
parent 0fd02dd9ac
commit 65a7b0e497
2 changed files with 29 additions and 8 deletions

View File

@ -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<string> eligibleKeys = new List<string>(Symbols.Count);
List<string> 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))
{

View File

@ -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'\""
}
}
}