static void Main(string[] args) { var f1 = args[0] + ".reachability"; File.WriteAllText(f1, ""); try { var fmc = new FiniteMachineChecker(args[0]); File.AppendAllText(f1, fmc.ReachabilityToString()); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); Console.ReadKey(); } }
public DeclarationLexem(ref int lineNumber, string Line, int currentIndent, string[] lines, FiniteMachineChecker fmc) : base(null, ref lineNumber, Line, currentIndent, lines) { var a = Line.Split(new string[] { ":" }, StringSplitOptions.None); if (a.Length != 2) { throw new Exception($"Incorrect declaration at line {lineNumber + 1}"); } Declaration = a[0].Trim(); NameOfDeclaration = a[1].Trim(); if (Declaration == "STATES") { // Добавляем служебную лексему "_" this.childs.Add("_", new EmptyLexem(this, 0)); Parse(lineNumber: ref lineNumber, Line: Line, currentIndent: currentIndent, lines, fromStatesDeclaration: true, null); } else if (Declaration == "TRANS") { Parse(lineNumber: ref lineNumber, Line: Line, currentIndent: currentIndent, lines, fromStatesDeclaration: false, fmc.StatesLexems[NameOfDeclaration].childs); foreach (var node in fmc.StatesLexems[NameOfDeclaration].childs) { if (node.Value is EmptyLexem) { continue; } if (!this.childs.ContainsKey(node.Key)) { throw new Exception($"Not enought declaration in transitions: {node.Value}"); } } } }