private static void CFGReducibility_DominatorTree_PrettyPrinter_Demonstration() { string fpath = @"..\..\..\CodeSamples\reducibilityBadSample.txt"; astRoot = AST(fpath); if (astRoot == null) { return; } var tacodeVisitor = new TACodeVisitor(); astRoot.Visit(tacodeVisitor); var prettyPrinter = new PrettyPrintVisitor(); astRoot.Visit(prettyPrinter); var cfg = new ControlFlowGraph(tacodeVisitor.Code); var domTree = new DominatorTree(cfg); Console.WriteLine("###### CFG Reducibility(#59 by APC TEAM) based on DominatorTree(#56 by ДВП)"); Console.WriteLine("###### and PrettyPrinter(#5 by APC TEAM) DEMONSTARTION:"); Console.WriteLine("###### Sample 1:"); Console.WriteLine(prettyPrinter.Text); Console.WriteLine("###### Dominator Tree Matrix:"); Console.WriteLine(domTree.ToString()); Console.WriteLine($"###### CFG is reducible: {cfg.IsReducible}"); Console.WriteLine($"###### CFG depth is: {cfg.Depth}"); fpath = @"..\..\..\CodeSamples\reducibilityGoodSample.txt"; astRoot = null; astRoot = AST(fpath); if (astRoot == null) { return; } tacodeVisitor = new TACodeVisitor(); astRoot.Visit(tacodeVisitor); prettyPrinter = new PrettyPrintVisitor(); astRoot.Visit(prettyPrinter); cfg = new ControlFlowGraph(tacodeVisitor.Code); domTree = new DominatorTree(cfg); Console.WriteLine("###########################################"); Console.WriteLine("###### Sample 2:"); Console.WriteLine("###### Program text from PrettyPrinter:\n"); Console.WriteLine(prettyPrinter.Text); Console.WriteLine("###### Dominator Tree Matrix:"); Console.WriteLine(domTree.ToString()); Console.WriteLine($"###### CFG is reducible: {cfg.IsReducible}"); }