Removed/expanded targeted-type 'new' expressions for legacy portability
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
This commit is contained in:
parent
442a967cd9
commit
1d34d1b6b7
@ -27,7 +27,7 @@ namespace Assignment_1
|
||||
/// <summary>
|
||||
/// Characters that cannot appear in a normal string
|
||||
/// </summary>
|
||||
static readonly List<char> ForbiddenChars = new()
|
||||
static readonly List<char> ForbiddenChars = new List<char>()
|
||||
{
|
||||
'$',
|
||||
'\\',
|
||||
@ -45,8 +45,8 @@ namespace Assignment_1
|
||||
bool exit = false;
|
||||
while (!exit)
|
||||
{
|
||||
MemoryStream sourceStream = new(1024);
|
||||
Parser parser = new();
|
||||
MemoryStream sourceStream = new MemoryStream(1024);
|
||||
Parser parser = new Parser();
|
||||
bool dynamicInput = false;
|
||||
// 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
|
||||
@ -78,7 +78,7 @@ namespace Assignment_1
|
||||
Thread.Sleep(2000);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
ConsoleKeyInfo ck = new();
|
||||
ConsoleKeyInfo ck = new ConsoleKeyInfo();
|
||||
while (ck.Key != ConsoleKey.Y && ck.Key != ConsoleKey.N)
|
||||
{
|
||||
Console.WriteLine("\nWould you like to parse another program? Y/n:");
|
||||
@ -91,7 +91,7 @@ namespace Assignment_1
|
||||
else
|
||||
{
|
||||
// Need the logic to prep the next source stream
|
||||
ck = new();
|
||||
ck = new ConsoleKeyInfo();
|
||||
while (ck.Key != ConsoleKey.Y && ck.Key != ConsoleKey.N)
|
||||
{
|
||||
Console.WriteLine("\nWould you like to pipe data from source file? Y/n:");
|
||||
@ -124,7 +124,7 @@ namespace Assignment_1
|
||||
|
||||
public class Parser
|
||||
{
|
||||
Dictionary<string, Tuple<string, VariableFlags>> Symbols = new()
|
||||
Dictionary<string, Tuple<string, VariableFlags>> Symbols = new Dictionary<string, Tuple<string, VariableFlags>>()
|
||||
{
|
||||
{ "SPACE", new Tuple<string, VariableFlags>(" ", VariableFlags.Reserved | VariableFlags.NoPrint) },
|
||||
{ "TAB", new Tuple<string, VariableFlags>("\t", VariableFlags.Reserved | VariableFlags.NoPrint) },
|
||||
@ -390,7 +390,7 @@ namespace Assignment_1
|
||||
int keyWidth = 21;
|
||||
int valueWidth = 50;
|
||||
int flagWidth = 9;
|
||||
StringBuilder consoleOutput = new();
|
||||
StringBuilder consoleOutput = new StringBuilder();
|
||||
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
|
||||
@ -462,7 +462,7 @@ namespace Assignment_1
|
||||
}
|
||||
Action Print(Stream source, int mode = 0)
|
||||
{
|
||||
StringBuilder outputString = new();
|
||||
StringBuilder outputString = new StringBuilder();
|
||||
string expression = ValidateValue(source);
|
||||
if (mode == 0)
|
||||
{
|
||||
@ -499,7 +499,7 @@ namespace Assignment_1
|
||||
string key = ValidateKey(source, true);
|
||||
string ToReverse = Symbols[key].Item1;
|
||||
string[] words = ToReverse.Split(' ');
|
||||
StringBuilder reversed = new();
|
||||
StringBuilder reversed = new StringBuilder();
|
||||
for (int i = words.Length - 1; i >= 0; i--)
|
||||
{
|
||||
reversed.Append(words[i]);
|
||||
@ -706,7 +706,7 @@ namespace Assignment_1
|
||||
/// <returns></returns>
|
||||
static long FindNextWord(Stream s, out string nextWord)
|
||||
{
|
||||
StringBuilder newWord = new();
|
||||
StringBuilder newWord = new StringBuilder();
|
||||
// Record our current position
|
||||
long start = s.Position;
|
||||
// Check if the character at the current pos is whitespace, if so, keep advancing until it isn't.
|
||||
@ -895,7 +895,7 @@ namespace Assignment_1
|
||||
|
||||
static List<string> GetStringLines(string source, int maxWidth)
|
||||
{
|
||||
List<string> lines = new();
|
||||
List<string> lines = new List<string>();
|
||||
int j = 0;
|
||||
while (j < source.Length)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user