Added the ~~print~~list function

This commit is contained in:
Brychan Dempsey 2021-03-11 16:39:15 +13:00
parent 3905b46e75
commit b2b8a036e9

View File

@ -10,7 +10,8 @@ namespace Assignment_1
enum VariableFlags
{
Empty = 0,
Reserved = 1
Reserved = 1,
NoPrint = 2
}
/// <summary>
@ -23,10 +24,10 @@ namespace Assignment_1
static Dictionary<string, Tuple<string, VariableFlags>> Symbols = new Dictionary<string, Tuple<string, VariableFlags>>
{
{ "SPACE", new Tuple<string, VariableFlags>(" ", VariableFlags.Reserved) },
{ "TAB", new Tuple<string, VariableFlags>("\t", VariableFlags.Reserved) },
{ "NEWLINE", new Tuple<string, VariableFlags>("\n", VariableFlags.Reserved) },
{ "CARRIAGE_RETURN", new Tuple<string, VariableFlags>("\r", VariableFlags.Reserved) }
{ "SPACE", new Tuple<string, VariableFlags>(" ", VariableFlags.Reserved | VariableFlags.NoPrint) },
{ "TAB", new Tuple<string, VariableFlags>("\t", VariableFlags.Reserved | VariableFlags.NoPrint) },
{ "NEWLINE", new Tuple<string, VariableFlags>("\n", VariableFlags.Reserved | VariableFlags.NoPrint) },
{ "CARRIAGE_RETURN", new Tuple<string, VariableFlags>("\r", VariableFlags.Reserved | VariableFlags.NoPrint) }
};
static void Main(string[] args)
{
@ -115,6 +116,31 @@ namespace Assignment_1
return true;
}
bool List()
{
Console.WriteLine("┌" + new string('─', 49) + "┐");
Console.WriteLine("│{0:-15}│{1:-25}│{2:9}│", "Symbol", "Value", "Flags");
Console.WriteLine("├" + new string('─', 15) + "┼" + new string('─', 25) + "┼" + new string('─', 9) + "┤");
int keyPos = Symbols.Count;
foreach (var item in Symbols)
{
Console.WriteLine("│{0:-15}│{1:-25}│{2:9}│", item.Key, item.Value.Item1, Convert.ToString((byte)item.Value.Item2,2).PadLeft(8,'0'));
if (keyPos == Symbols.Count-1)
{
Console.WriteLine("└" + new string('─', 15) + "┴" + new string('─', 25) + "┴" + new string('─', 9) + "┘");
}
else
{
Console.WriteLine("├" + new string('─', 15) + "┼" + new string('─', 25) + "┼" + new string('─', 9) + "┤");
}
}
return true;
}
bool
#endregion
#region Data Handling
// Data Handling