private static void Main(string[] args) { var exitFlag = false; var validator = new MipsValidator(); while (!exitFlag) { Console.Write("Please enter a MIPS statement: "); var input = Console.ReadLine(); var arguments = new Line(input); var operands = arguments.Instruction.ParseInstruction(); var status = validator.IsSyntaxValid(operands); //Check syntax if (status.Success.Equals(true)) { var stat = validator.HasValidParams(operands); //Check parameters if (stat.Success.Equals(true)) { Console.WriteLine(string.Format("'{0}' is a valid mips instruction ", arguments.Instruction)); } else { foreach (var reason in stat.Reasons) { Console.WriteLine(reason); } } } else { foreach (var reason in status.Reasons) { Console.WriteLine(reason); } } Console.WriteLine("Enter esc key to quit, any other key to continue "); if (Console.ReadKey().Key == ConsoleKey.Escape) { exitFlag = true; } } }
private void TestInput(object sender, EventArgs e) { opListBox.Items.Clear(); var i = 0; statusListBox.Items.Clear(); var validator = new MipsValidator(); var arguments = new Line(inputTextBox.Text); var operands = arguments.Instruction.ParseInstruction(); var status = validator.IsSyntaxValid(operands); foreach (var operand in operands) { i++; if (i > 1) { opListBox.Items.Add(string.Format("operand({0}) : {1}", i, operand.Replace(",",string.Empty))); } else { opListBox.Items.Add(string.Format("Operator: {0}", operand.Replace(",",string.Empty))); } } //Check syntax if (status.Success.Equals(true)) { var stat = validator.HasValidParams(operands); //Check parameters if (stat.Success.Equals(true)) statusListBox.Items.Add(string.Format("'{0}' is a valid mips instruction", arguments.Instruction)); else foreach (var reason in stat.Reasons) statusListBox.Items.Add(reason); } else { foreach (var reason in status.Reasons) statusListBox.Items.Add(reason); } }