private static void Help() { TextProc.WriteBar("expression_types"); TextProc.WriteInfo("--bool = bool expression", ":", ConsoleColor.Magenta); TextProc.WriteInfo("--reg = regular expression", ":", ConsoleColor.Magenta); TextProc.WriteInfo("--mat = matrix expression", ":", ConsoleColor.Magenta); TextProc.WriteInfo("--pov = polynomial of one variable", ":", ConsoleColor.Magenta); TextProc.WriteBar("variables"); TextProc.WriteInfo("--vars", ":", ConsoleColor.Magenta); TextProc.WriteBar("debug_mode"); TextProc.WriteInfo("--debug", ":", ConsoleColor.Magenta); Console.WriteLine(); }
private static void Main(string[] args) { var debugMode = false; var useVars = false; var expressionType = ""; var solution = ""; var vars = new Dictionary <string, string>(); foreach (var arg in args) { if (arg == "--bool" || arg == "--reg" || arg == "--mat" || arg == "--pov") { expressionType = arg; } else if (arg == "--debug") { debugMode = true; } else if (arg == "--vars") { useVars = true; } } if (expressionType == "") { Help(); } else { if (useVars) { TextProc.WriteBar("vars"); Console.Write(" : "); vars = VarsProcessor.GetVarDictionary(TextProc.ReadColor(ConsoleColor.Blue)); } TextProc.WriteBar("expression"); Console.Write(" : "); var expression = TextProc.ReadColor(ConsoleColor.Blue); if (useVars && VarsProcessor.ValidateVars(vars)) { expression = VarsProcessor.ReplaceVars(expression, vars); } switch (expressionType) { case "--bool": solution = ProcessBoolExpression(expression, debugMode); break; case "--reg": solution = ProcessRegularExpression(expression, debugMode); break; case "--mat": solution = ProcessMatrixExpression(expression, debugMode); break; case "--pov": solution = ProcessPovExpression(expression, debugMode); break; default: Help(); break; } if (debugMode) { Console.WriteLine(); } TextProc.WriteBar("solution"); TextProc.WriteInfo(solution, "=", solution.IndexOf("error", StringComparison.Ordinal) == -1 ? ConsoleColor.Green : ConsoleColor.Red); Console.WriteLine(); } }