//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { List <List <Elem> > allTables = new List <List <Elem> >(); Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); List <string> files = TestParser.ProcessCommandline(args); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); ITokenCollection semi = Factory.create(); //semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi, file); Parser parser = builder.build(); try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; allTables.Add(table); Console.Write("\n"); semi.close(); } Display.showMetricsNamespace(allTables); Display.showMetricsClass(allTables); Display.showMetricsFunction(allTables); Display.showMetricsAlias(allTables); Display.showMetricsEnum(allTables); Display.showMetricsStruct(allTables); Display.showMetricsDelegate(allTables); Display.showMetricsUsing(allTables); Display.showMetricsInterface(allTables); Console.Write("\n\n"); }
//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { TypeTable tb = new TypeTable(); Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); List <string> files = TestParser.ProcessCommandline(args); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); ITokenCollection semi = Factory.create(); //semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); string name = ""; for (int i = file.Length - 1; file[i] != '/' && file[i] != '\\'; --i) { name = file[i] + name; } Console.WriteLine("FILE: {0}", name); BuildTypeAnalyzer builder = new BuildTypeAnalyzer(semi, name); Parser parser = builder.build(); try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; Display.showMetricsTable(table); Console.Write("\n"); semi.close(); } Console.Write("\n\n"); tb.print(); Console.ReadLine(); }
//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); List <string> files = TestParser.ProcessCommandline(args); Repository repo = Repository.getInstance(); ITokenCollection semi = Factory.create(); BuildTypeAnalyzer builder = new BuildTypeAnalyzer(semi); Parser parser = builder.build(); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); repo.currentFile = file; //ITokenCollection semi = Factory.create(); //semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); //BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi); //Parser parser = builder.build(); //repo.currentFile = file; try { while (semi.get().Count > 0) { parser.parse(semi); } } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; Display.showMetricsTable(table); Console.Write("\n"); semi.close(); } Console.Write("\n\n"); }
//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); List <string> files = TestParser.ProcessCommandline(args); foreach (object file in files) { Console.Write("\n Processing file {0}\n", file as string); CSsemi.CSemiExp semi = new CSsemi.CSemiExp(); semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------\n"); BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi); Parser parser = builder.build(); try { while (semi.getSemi()) { parser.parse(semi); } Console.Write("\n\n locations table contains:"); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.analyzedata; foreach (Elem e in table) { Console.Write("\n {0,10}, {1,25}, {2,5}, {3,5}", e.type, e.name, e.begin, e.end); } Console.WriteLine(); Console.Write("\n\n That's all folks!\n\n"); semi.close(); Console.ReadLine(); } }
//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); Parser parser; List <string> files = TestParser.ProcessCommandline(args); BuildCodeAnalyzer builder = null; foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); CSsemi.CSemiExp semi = new CSsemi.CSemiExp(); semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); builder = new BuildCodeAnalyzer(semi); parser = builder.build(true); try { while (semi.getSemi()) { parser.parse(semi); } Console.Write("\n locations table contains:"); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", "category", "name", "bLine", "eLine", "bScop", "eScop", "size", "cmplx" ); Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", "--------", "----", "-----", "-----", "-----", "-----", "----", "-----" ); foreach (Elem e in table) { if (e.type == "class" || e.type == "struct") { Console.Write("\n"); } Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", e.type, e.name, e.beginLine, e.endLine, e.beginScopeCount, e.endScopeCount + 1, e.endLine - e.beginLine + 1, e.endScopeCount - e.beginScopeCount + 1 ); } Console.Write("\n"); semi.close(); } foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); CSsemi.CSemiExp semi = new CSsemi.CSemiExp(); semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); builder = new BuildCodeAnalyzer(semi); parser = builder.build(false); try { while (semi.getSemi()) { parser.parse(semi); } Console.Write("\n locations table contains:"); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", "category", "name", "bLine", "eLine", "bScop", "eScop", "size", "cmplx" ); Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", "--------", "----", "-----", "-----", "-----", "-----", "----", "-----" ); foreach (Elem e in table) { if (e.type == "class" || e.type == "struct") { Console.Write("\n"); } Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}", e.type, e.name, e.beginLine, e.endLine, e.beginScopeCount, e.endScopeCount + 1, e.endLine - e.beginLine + 1, e.endScopeCount - e.beginScopeCount + 1 ); if (e.type == "class" || e.type == "struct") { CClassInfo classInfo = rep.parsedData.getClassInfo(e.name); Console.WriteLine("Coupling: {0}", CCalculateMetrics.calculateCoupling(classInfo)); Console.WriteLine("Cohesion: {0}", CCalculateMetrics.calculateCohesion(classInfo)); } } Console.Write("\n"); semi.close(); } Console.Write("\n\n"); }
//----< Test Stub >-------------------------------------------------- #if (TEST_PARSER) static void Main(string[] args) { Console.Write("\n Demonstrating Parser"); Console.Write("\n ======================\n"); ShowCommandLine(args); //THIS RETURNS A LIST OF FILES THAT THE USER PASSED IN List <string> files = TestParser.ProcessCommandline(args); for (int i = 0; i < files.Count; i++) { Console.Write(files[i] + "\n"); } //sh - preprocess all user input files to get all user defined types UserType.parseUserDefinedTypes(files); HashSet <string> definedSet = UserType.getUserDefinedSet(); Console.Write("Parser size of definedset" + definedSet.Count.ToString()); foreach (string file in files) { Console.Write("\n Processing file {0}\n", System.IO.Path.GetFileName(file)); CSsemi.CSemiExp semi = new CSsemi.CSemiExp(); semi.displayNewLines = false; if (!semi.open(file as string)) { Console.Write("\n Can't open {0}\n\n", args[0]); return; } Console.Write("\n Type and Function Analysis"); Console.Write("\n ----------------------------"); BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi); Parser parser = builder.build(); try { while (semi.getSemi()) { parser.parse(semi); } Console.Write("\n locations table contains:"); } catch (Exception ex) { Console.Write("\n\n {0}\n", ex.Message); } //all data is stored in table object Repository rep = Repository.getInstance(); List <Elem> table = rep.locations; Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}, {8,10}, {9, 10}, {10,6}", "category", "name", "bLine", "eLine", "bScop", "eScop", "size", "cmplx", "coupling", "cohesion", "M-Index" ); Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}, {8,10}, {9,10}, {10,6}", "--------", "----", "-----", "-----", "-----", "-----", "----", "-----", "--------", "--------", "-------" ); foreach (Elem e in table) { if (e.type == "class" || e.type == "struct") { Console.Write("\n"); //get the maintainibility index e.mIndex = getMaintainibilityIndex(e); Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}, {8,10}, {9,10}, {10,6}", e.type, e.name, e.beginLine, e.endLine, e.beginScopeCount, e.endScopeCount + 1, e.endLine - e.beginLine + 1, e.endScopeCount - e.beginScopeCount + 1, e.coupling, e.cohesion, e.mIndex ); } else { Console.Write( "\n {0,10}, {1,25}, {2,5}, {3,5}, {4,5}, {5,5}, {6,5}, {7,5}, {8,10}, {9,10}", e.type, e.name, e.beginLine, e.endLine, e.beginScopeCount, e.endScopeCount + 1, e.endLine - e.beginLine + 1, e.endScopeCount - e.beginScopeCount + 1, e.coupling, e.cohesion ); } } Console.Write("\n\n"); semi.close(); } Console.Write("\n\n"); }