Example #1
0
        /// <summary>
        /// Performs type analysis and generates type table for every file.
        /// </summary>
        /// <param name="files"></param>
        /// <returns>type tabeles for every file</returns>
        public Dictionary <string, List <Elem> > DoTypeAnalysis(List <string> files)
        {
            Dictionary <string, List <Elem> > dicTables = new Dictionary <string, List <Elem> >();

            foreach (string file in files)
            {
                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    //return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                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;
                dicTables.Add(file, table);
                semi.close();
            }
            return(dicTables);
        }
Example #2
0
        //----------<parse1 starts here, it identifies all the types>-----------------
        public void doAnalysis(string[] files)
        {
            foreach (object file in files)
            {
                string filename = Convert.ToString(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", file);
                    return;
                }


                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser            parser  = builder.build();

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi, filename);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository  rep   = Repository.getInstance();
                List <Elem> table = rep.locations;           //storing the repository data into a List

                semi.close();
            }
        }
        public void Execute_Parser(List <string> files)
        {
            foreach (string file in files)
            {
                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", files[0]);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser            parser  = builder.build();

                try
                {
                    while (semi.get().Count > 0)
                    {
                        parser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Console.Write("\n");

                semi.close();
            }
        }
        // function that parse all the files and build a inquiry table
        static void doAnalysis(string[] files, bool relation, bool xml)
        {
            List<Elem> fileSetInfo = new List<Elem>();      // store type and name of file set, use for relationship analysis
            List<Elem> summaryTAB = new List<Elem>();          // store size and complexity, use for display summary of the whole file set
            
            foreach (object file in files)
            {
                CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
                semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);    // creat a repository
                Parser parser = builder.build();        // creat a parser object and five rule object, attach the rules to parser
                try
                {
                    while (semi.getSemi())
                        parser.parse(semi);
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository rep = Repository.getInstance();
                fileSetInfo.AddRange(rep.locations);        // push all elements in current file into inquiry table
                semi.close();
            }

            secondAnalysis(files, fileSetInfo, summaryTAB, relation, xml);
        }
Example #5
0
        //----------<parse1 starts here, it identifies all the types>-----------------
        public void doAnalysis(string[] files)
        {

            foreach (object file in files)
            {
                string filename = Convert.ToString(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", file);
                    return;
                }


                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser parser = builder.build();

                try
                {
                    while (semi.getSemi())
                        parser.parse(semi, filename);
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository rep = Repository.getInstance();
                List<Elem> table = rep.locations;           //storing the repository data into a List

                semi.close();
            }
        }
Example #6
0
        //----< setup and execute the parser >-----------------
        static void parse(string file)
        {
            CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
            semi.displayNewLines = false;
            if (!semi.open(file as string))
            {
                Console.WriteLine("  Can't open {0}", file);
                return;
            }

            BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
            Parser            parser  = builder.build(true);

            try
            {
                while (semi.getSemi())
                {
                    parser.parse(semi);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("  {0}", ex.Message);
            }

            semi.close();
        }
    static public void doAnalysis(string[] files)
    {

      int skipCount = 0;

      CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
      semi.displayNewLines = false;

      BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
      Parser parser = builder.build();
      Repository rep = Repository.getInstance();
      List<Elem> fileSetInfo = new List<Elem>();      // store type and name of file set, use for relationship analysis

      foreach (string file in files)
      {
        if(Display.showFiles)
          Display.displayString("");
        Display.displayFiles(act, "Processing file: " + file);

        if (!semi.open(file as string))
        {
          Console.Write("\n  Can't open {0}\n\n", file);
          return;
        }

        try
        {
          while (semi.getSemi())
          {
            parser.parse(semi);
          }
        }
        catch (Exception ex)
        {
          Console.Write("\n\n  {0}\n", ex.Message);
        }
        foreach (Elem e in rep.locations)
        {
            e.filename = file;
        }
        List<Elem> table = rep.locations;
        
        if (table.Count == 0)
        {
          ++skipCount;
          continue;
        }
       
        fileSetInfo.AddRange(rep.locations);        // push all elements in current file into inquiry table
        semi.close();

        rep.LocationsTable[file] = table;   // Obtained all the types and names of the file set, locationTable is actually a inquiry table
        rep.locations = new List<Elem>();
      }

      doAnalysis_Again(fileSetInfo, files);
      displaySkipped(skipCount);
      //displayAnalysis(rep);
      //analysisSummary(rep);
    }
Example #8
0
        //-----------------------<Generates Type Table by performing type analysis>--------------------------
        static public List <List <Elem> > TypeTableGenerator(List <string> files)
        {
            List <List <Elem> > tableList = new List <List <Elem> >();

            foreach (string file in files)
            {
                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi, System.IO.Path.GetFileName(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;
                tableList.Add(table);
                semi.close();
            }
            return(tableList);
        }
Example #9
0
        //----< Test Stub >--------------------------------------------------

#if (TEST_PARSER)
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            ShowCommandLine(args);

            /* If the package is run as stand alone application
             * then add the default values for the member variables
             */
            try
            {
                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.locations;
                    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();
                    semi.close();
                    Console.ReadLine();
                }
            }
            catch
            {
                Console.WriteLine("Error in parsing");
            }
        }
        static void Main(string[] args)
        {
            ShowCommandLine(args);
            Executive test = new Executive();

            test.requirementOne();
            test.requirementTwo();
            test.requirementThree();
            test.requirementFour();
            List <string> files = ProcessCommandline(args);

            foreach (string file in files)
            {
                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                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; semi.close();
            }
            test.setAllParameters(files);
            foreach (string file in files)
            {
                Console.Write("\nFilename : {0}\n", System.IO.Path.GetFileName(file));
                DAnalysis        depAnls = new DAnalysis();
                ITokenCollection semi    = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }
                try{
                    while (semi.get().Count > 0)
                    {
                        depAnls.parse(semi, file);
                    }
                }
                catch (Exception ex) {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                semi.close(); Graph.addGraph();
            }
            test.setAllParams();
            test.requirementSix();
            test.requirementSeven();
        }
        //----< 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");
        }
Example #12
0
        static public void doAnalysis(string[] files)
        {
            int skipCount = 0;

            CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
            semi.displayNewLines = false;

            BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
            Parser            parser  = builder.build();
            Repository        rep     = Repository.getInstance();

            foreach (string file in files)
            {
                if (Display.showFiles)
                {
                    Display.displayString("");
                }
                Display.displayFiles(act, "Processing file: " + file);

                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    return;
                }

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                List <Elem> table = rep.locations;
                if (table.Count == 0)
                {
                    ++skipCount;
                    continue;
                }

                semi.close();
                rep.LocationsTable[file] = table;
                rep.locations            = new List <Elem>();
            }

            displaySkipped(skipCount);
            displayAnalysis(rep);
            analysisSummary(rep);
        }
Example #13
0
        //----< Test Stub for Parser >--------------------------------------------------

#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)
            {
                string filename = Convert.ToString(file);
                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, filename);
                    }
                    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.locations;

                foreach (Elem e in table)
                {
                    if (e.type == "function")
                    {
                        Console.Write("\n  {0,10}, {1,25}, {2,5}, {3,5}, {4,5}", e.type, e.name, e.begin, e.end, e.functionComplexity);
                    }
                }
                Console.WriteLine();
                Console.Write("\n\n  That's all folks!\n\n");
                semi.close();
            }
        }
Example #14
0
 static public void doAnalysis(string[] files,bool relationship) { 
   BuildCodeAnalyzer builder;
   BuildCodeAnalyzer_relation builder_relation;
   Parser parser;
   Parser parser_;
   for(int i=0;i<2;i++) {  
       foreach (object file in files) {
           CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
           CSsemi.CSemiExp semi_relation = new CSsemi.CSemiExp();
           semi.displayNewLines = false;
           if (!semi.open(file as string)) {
               Console.Write("\n  Can't open {0}\n\n", file);
               return;
           }
           if (!semi_relation.open(file as string)) {
               Console.Write("\n  Can't open {0}\n\n", file);
               return;
           }
           if (i == 0)  {
               builder = new BuildCodeAnalyzer(semi);
               parser = builder.build();
               Repository rep1 = Repository.getInstance();
               rep1.setfilename(Path.GetFileName(file.ToString()));
               try {
                  while (semi.getSemi())
                      parser.parse(semi);
               }
               catch (Exception ex)
               {
                   Console.Write("\n\n  {0}\n", ex.Message);
               }
           }
           else  {
               builder_relation = new BuildCodeAnalyzer_relation(semi_relation);
               parser_ = builder_relation.build_relation();
               Repository rep1 = Repository.getInstance();
               rep1.setfilename(Path.GetFileName(file.ToString()));
               try {
                   while (semi_relation.getSemi())
                       parser_.parse(semi_relation);
               }
               catch (Exception ex) {
                   Console.Write("\n\n  {0}\n", ex.Message);
               }
           }
           semi.close(); }
       if (!relationship)
           return;
     }
 }
Example #15
0
        // Parses the files to extract relationships among userdefined types
        protected override bool ParseFile(String file)
        {
            CSsemi.CSemiExp semi = GetSemiExpressionFromFile(file);
            if (semi == null)
            {
                return(false);
            }
            BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
            Parser            parser  = builder.buildParserForRelationships(interestedTypes, allTypes);

            ParseSemi(semi, parser);
            semi.close();
            return(true);
        }
Example #16
0
        public List <Elem> typesBetweenFiles        = new List <Elem>();         //list to store info between files
        public void doAnalysis(string[] files)
        {
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            //**processes it for every file one after another*********

            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", file);
                    return;
                }

                Console.Write("\n  Type and Function Analysis");
                Console.Write("\n ----------------------------\n");

                CodeAnalysis.BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser parser = builder.build();

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi); //parses every semi expression
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository  rep   = Repository.getInstance();
                List <Elem> table = rep.locations;
                typesBetweenFiles = rep.locations;
                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();
            }
        }
Example #17
0
        //----< 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();

                Console.Write("\n\n  That's all folks!\n\n");
                semi.close();
            }
        }
Example #18
0
        static void doAnalysis(string[] files)
        {
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            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", file);
                    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.locations;
                foreach (Elem e in table)
                {
                    Console.Write("\n  {0,10}, {1,25}, {2,5}, {3,5} , {4,5}", e.type, e.name, e.begin, e.end, e.end - e.begin + 1);
                }
                Console.WriteLine();
                Console.Write("\n\n  That's all folks!\n\n");
                semi.close();
            }
        }
Example #19
0
        //----< Test Stub >--------------------------------------------------

#if (TEST_PARSER)
        static void Main(string[] args)
        {
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");
            FileFinder filef = new FileFinder();

            args = filef.get_cs();
            foreach (string file in args)
            {
                Console.Write("\n  Processing file {0}\n", System.IO.Path.GetFileName(file));
                ITokenCollection semi = Factory.create();
                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.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");
            Console.ReadKey();
        }
Example #20
0
        public static void performTypeAnalysis(List <string> files)
        {
            foreach (string file in files)
            {
                // Console.Write("\n  Processing file {0}\n", System.IO.Path.GetFileName(file));

                Lexer.ITokenCollection semi = Factory.create();
                //semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", files);
                    return;
                }

                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                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;

                Console.Write("\n");
                rep.nameSpace = "";
                semi.close();
            }
        }
        public List <List <Elem> > generateTypeTable()
        {
            string nameofFile;
            List <List <Elem> > listOfTables = new List <List <Elem> >();

            foreach (string file in files)
            {
                nameofFile = 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", nameofFile);
                }

                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi, nameofFile);
                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;
                listOfTables.Add(table);
                semi.close();
            }
            return(listOfTables);
        }
        public void show_result(string[] args)
        {
            Console.WriteLine("below is the all processing files : ");
            Console.WriteLine("\n");
            foreach (var csfile in args)
            {
                Console.WriteLine(csfile);
            }
            Console.Write("\n ======================\n");
            TestParser tp = new TestParser();

            foreach (string file in args)
            {
                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]);
                }
                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);
                }
                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();
            }
        }
Example #23
0
        //----< analyzer execution start here! >-----------------
        static int Main(string[] args)
        {
            List <string> files            = processCommandline(args);
            FileStream    outputFileStream = null;
            StreamWriter  streamWriter     = null;

            if (files == null)
            {
                return(0);
            }

            if (optOutputToFile)
            {
                try
                {
                    outputFileStream = new FileStream(optOutputToFileFilepath, FileMode.Create);
                }
                catch
                {
                    Console.WriteLine("error: can create output file {0}.", optOutputToFileFilepath);
                }

                streamWriter = new StreamWriter(outputFileStream);
                Console.SetOut(streamWriter);
            }

            Console.WriteLine();
            Console.WriteLine("===============================================================================");
            Console.WriteLine("  Code Maintainability Analyzer");
            Console.WriteLine("===============================================================================");

            Parser            parser;
            BuildCodeAnalyzer builder = null;

            foreach (string file in files)
            {
                CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
                semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.WriteLine("  Can't open {0}", args[0]);
                    return(-1);
                }

                builder = new BuildCodeAnalyzer(semi);
                parser  = builder.build(true);

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("  {0}", ex.Message);
                }
                semi.close();
            }



            foreach (string file in files)
            {
                CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
                semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.Write("  Can't open {0}", args[0]);
                    return(-1);
                }

                Console.WriteLine();
                Console.WriteLine("-------------------------------------------------------------------------------");
                Console.WriteLine("  Type and Function Analysis for {0}", System.IO.Path.GetFileName(file));
                Console.WriteLine("-------------------------------------------------------------------------------");

                builder = new BuildCodeAnalyzer(semi);
                parser  = builder.build(false);

                try
                {
                    while (semi.getSemi())
                    {
                        parser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("  {0}", ex.Message);
                }

                semi.close();

                showOutput();
            }

            showSummary(files.Count);

            showRelationships();


            if (optOutputToFile)
            {
                streamWriter.Close();
            }

            return(0);
        }
Example #24
0
        //----< 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");
        }
Example #25
0
        static void Main(string[] args)
        {
            Console.Write("This project contains 13 packages demonstrating requirement 3:\n");
            Console.Write("1) DemoExecutive\n");
            Console.Write("2) DemoReqs\n");
            Console.Write("3) DependencyAnalysis\n");
            Console.Write("4) Display\n");
            Console.Write("5) Element\n");
            Console.Write("6) FileMgr\n");
            Console.Write("7) Parser\n");
            Console.Write("8) SemiExp\n");
            Console.Write("9) StrongComponent\n");
            Console.Write("10) TestHarness\n");
            Console.Write("11) Toker\n");
            Console.Write("12) TypeTable\n");
            Console.Write("13) AutomatedTestUnit\n");
            Console.Write("\n ======================\n");
            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            ShowCommandLine(args);

            List <string> files = ProcessCommandline(args);
            DepAnalysis   da    = new DepAnalysis();

            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);
                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;
                TypeTable.TypeTable tt    = new TypeTable.TypeTable();
                ///shows typetable
                foreach (Elem e in table)
                {
                    tt.add(e.type, e.name);
                    if (e.type == "using")
                    {
                        da.add(System.IO.Path.GetFileName(file), e.name);
                    }
                }
                tt.show();
                Console.WriteLine("Showing TypeTables of files demonstrating requirement 5:\n");
                Console.Write("\n  TypeTable contains types: ");
                foreach (var elem in tt.table)
                {
                    Console.Write("{0} ", elem.Key);
                }
                ////Display.showMetricsTable(table);

                Console.Write("\n");
                semi.close();
            }
            var nodes = new List <CsNode <string, string> >();

            foreach (var elem in da.table)
            {
                nodes.Add(new CsNode <string, string>(elem.Key));
                //Console.Write("\n  {0} depends on", elem.Key);
            }
            nodes.ToArray();

            //foreach (var elem in da.table)
            //{
            //    foreach (var item in elem.Value)
            //    {
            //        //nodes[IndexOf(elem.Key)].addChild(nodes[IndexOf(item.file)], "edge" + elem.Key + " " + item.file);
            //        //nodes[0].addChild(item.file, "edge" + elem.Key + " " + item.file);
            //        //nodes[nodes.IndexOf(elem.Value)].addChild(nodes[nodes.IndexOf(item.file)], "edge" + elem.Key + " " + item.file);

            //        Console.Write("\n    {0}.cs", item.file);
            //    }
            //}
            //iterate through list of list elements of a file
            //da.table --gets table,
            for (int i = 0; i < da.table.Count; i++)
            {
                var item = da.table.ElementAt(i);
                for (int j = 0; j < item.Value.Count; j++)
                {
                    //Console.WriteLine(i+"^"+ da.table.Values);
                    nodes[i].addChild(nodes[j], "edge" + i + j);
                }
            }
            Graph <string, string> graph = new Graph <string, string>("Fred");

            for (int i = 0; i < da.table.Count; i++)
            {
                graph.addNode(nodes[i]);
            }

            graph.startNode = nodes[0];
            //Console.WriteLine("\n Showing graph walk starting at node[0]\n");
            //Console.Write("\n\n  starting walk at {0}", graph.startNode.name);
            //Console.Write("\n  not showing backtracks");
            //graph.walk();

            Console.WriteLine("Showing dependencies between files demonstrating requrement 4:\n\n");
            //shows dependency analysis
            da.show();
            Console.Write("\n\n");
            Console.Write("Showing all strong components, if any, in the file collection, based on the dependency analysis demonstrating requirement 6:\n\n");
            graph.startNode = nodes[0];
            graph.Tarjan();
            Console.Write("\n\n");
            Console.WriteLine("This demo executive file demonstrates all the outputs and is well formatted as per requirement 7 and 8\n");
            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);
      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);
        }
        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();
      }
      Console.Write("\n\n");
    }
Example #27
0
        //----< 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");
        }
Example #28
0
        static void doAnalysis(string[] files, bool relation_flag, bool xml_flag)
        {
            List<Elem> TABLE = new List<Elem>();
            foreach (object file in files)
            {
                CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
                semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser parser = builder.build();
                try
                {
                    while (semi.getSemi())
                        parser.parse(semi);
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository rep = Repository.getInstance();
                TABLE.AddRange(rep.locations);          // Build a TABLE to store all the elements, provided to be searched for relationshipAnalysis class
                semi.close();
            }

            Console.Write("\n  Demonstrating Parser");
            Console.Write("\n ======================\n");

            // parse all files and store the elements into table for each file
            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", file);
                    return;
                }

                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.locations;

                // display basic information for elements including size and complexity
                Console.Write("\n    type                 name          begin      end       size     complexity");
                foreach (Elem e in table)
                {
                    if (e.type == "function")
                    {
                        ComplexityAnalysis ca = new ComplexityAnalysis();
                        e.complexity = ca.ComplexityAnalyze(e, file);
                    }
                        Console.Write("\n  {0,9}, {1,20}, {2,8}, {3,8}, {4,8}, {5,8}", e.type, e.name, e.begin, e.end, e.end - e.begin + 1, e.complexity);

                }
                //display the relationships between classes
                if (relation_flag == true)
                {
                    foreach (Elem e in table)
                    {
                        e.AggregationFlag = false;
                        e.CompositionFlag = false;
                        e.UsingFlag = false;
                        if (e.type == "class" || e.type == "struct" || e.type == "interface")
                        {
                            Console.Write("\n\n {0} {1}", e.type, e.name);
                            Console.Write("------------------------------------------------------\n");
                            RelationshipAnalysis ra = new RelationshipAnalysis();
                            ra.RelationshipAnalyzer(e, file, TABLE);
                            foreach (Elem ele in TABLE)
                            {
                                ele.AggregationFlag = false;
                                ele.CompositionFlag = false;
                                ele.UsingFlag = false;
                            }
                        }
                    }
                }
                Console.WriteLine();

                //display xml files for each file
                if (xml_flag == true)
                {
                    XML x = new XML();
                    x.XmlBuilder(table, (string)file);
                }
            }
            Console.Write("\n");
            DisplaySummary(TABLE);
        }
Example #29
0
    //----< Test Stub >--------------------------------------------------

#if(TEST_PARSER)

    static void Main(string[] args)
    {
      Console.Write("\n  Demonstrating Parser");
      Console.Write("\n ======================\n");

      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();

        while (semi.getSemi())
          parser.parse(semi);
        //Console.Write("\n\n  locations table contains:");

        Repository rep = Repository.getInstance();
        List<Elem> table = rep.locations;
          
        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();
      }
    }
Example #30
0
        public void Requirement4_5(string[] args)
        {
            Console.Write("\n\t \tOutput of Requirement4\n");
            Console.Write("-----------------------------------------------------------------------------\n");
            Console.Write("This Project3 implements packages that evaluate all the dependencies between files in a specified file set  \n");
            ShowCommandLine(args);

            List<string> files = ProcessCommandline(args);


            foreach (string file in files)
            {
                Console.Write("\n  Processing file {0}\n", System.IO.Path.GetFileName(file));

                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser parser = builder.build();

                try
                {
                    while (semi.get().Count > 0)
                        parser.parse(semi);
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Console.Write("\n");

                semi.close();
            }


            DepAnalysis.DepAnalysis dep = new DepAnalysis.DepAnalysis();
            StrongComp.filesGraph = files;
            StrongComp.filesGraphs = files;
            StrongComp.filenumber = files.Count();
            StrongComp.setGraph();
            StrongComp.filesGraph = files;
            StrongComp.setGraphDictionary();
            DepAnalysis.DepAnalysis.filesDepAnalysis = files;
            DepAnalysis.DepAnalysis.setDictionary();


            foreach (string file in files)
            {
                Console.Write("\n  Processing file {0}\n", System.IO.Path.GetFileName(file));

                ITokenCollection semi = Factory.create();
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }


                try
                {
                    while (semi.get().Count > 0)
                        dep.HoldUsingValue(semi);

                }

                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                semi.close();
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", args[0]);
                    return;
                }
                try
                {
                    while (semi.get().Count > 0)
                        dep.analyze(semi, file);
                }

                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }

                semi.close();
                StrongComp.addGraph();


            }
            Console.Write("\n\n");
        }
        // function that parse each file, detect class relationship, function size and complexity
        static void secondAnalysis(string[] files, List<Elem> fileSetInfo, List<Elem> summaryTAB, bool relation, bool xml)
        {
            foreach (object file in files)
            {
                CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
                semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    Console.Write("\n  Can't open {0}\n\n", file);
                    return;
                }
                BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
                Parser parser = builder.build();
                try
                {
                    while (semi.getSemi())
                        parser.parse(semi);                    
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository rep = Repository.getInstance();
                List<Elem> table = rep.locations;
                ComplexityAnalyzer comxAna = new ComplexityAnalyzer();
                foreach (Elem e in table)                                   // analysis each element's complexity if it is a function
                {
                    if (e.type == "function")
                        e.complexity = comxAna.complexityAnalysis(e, file, fileSetInfo);
                }

                summaryTAB.AddRange(table);

                RelationshipAnalyzer relshAna = new RelationshipAnalyzer();
                foreach (Elem e in table)                                   // analysis each element's relationship if it is a class or struct or interface
                {
                    if (e.type == "class" || e.type == "struct" || e.type == "interface")
                        relshAna.relationshipanalysis(e, file, fileSetInfo);
                }
                display(table, file, relation, xml);              
                semi.close();
            }// all the files in file set had been parsed

            summary(summaryTAB, relation);           
        }
    static public void doAnalysis_Again(List<Elem> fileSetInfo, string[] files)
    {
        CSsemi.CSemiExp semi = new CSsemi.CSemiExp();
        semi.displayNewLines = false;

        BuildCodeAnalyzer builder = new BuildCodeAnalyzer(semi);
        Parser parser = builder.build();
        Repository rep = Repository.getInstance();

        foreach (string file in files)
        {
            if (Display.showFiles)
                Display.displayString("");
            Display.displayFiles(act, "Processing file: " + file);

            if (!semi.open(file as string))
            {
                Console.Write("\n  Can't open {0}\n\n", file);
                return;
            }

            try
            {
                while (semi.getSemi())
                {
                    parser.parse(semi);
                }
            }
            catch (Exception ex)
            {
                Console.Write("\n\n  {0}\n", ex.Message);
            }
            foreach (Elem e in rep.locations)
            {
                e.filename = file;
            }
            List<Elem> table = rep.locations;

            if (table.Count == 0)
            {
                continue;
            }
            List<string> filename = new List<string>();
            filename.Add("");
            fileDependencyTable.Add(file, filename);
            foreach (Elem e in table)      // analysis each element's dependency if it is a class or struct or interface
            {
                if (e.type == "class" || e.type == "struct" || e.type == "interface")
                    dependencyAnalyzer.dependencyAnalysis(e, file, fileSetInfo);

                foreach (Elem ee in fileSetInfo)
                {
                    if (e.dependency.Contains(ee.name) && !fileDependencyTable[file].Contains(ee.filename) && ee.filename != file)
                    {
                        fileDependencyTable[file].Add(ee.filename);
                    }
                }
            }

            semi.close();
            rep.LocationsTable[file] = table;   // obtained all the types and names of the file set, locationTable is actually a inquiry table
            rep.locations = new List<Elem>();
        }

        displayAnalysis(rep);
        analysisSummary(rep);
    }
    //----< Test Stub >--------------------------------------------------

#if(TEST_PARSER)

    static void Main(string[] args)
    {
      Console.Write("\n  Demonstrating Parser");
      Console.Write("\n ======================\n");

      //Repository rep_global;
      //List<Elem> table_global;

      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.locations;
////////
        ComplexityAnalyzer comxAna = new ComplexityAnalyzer();
        foreach (Elem e in table)
        {
            if (e.type == "function")
                e.complexity = comxAna.complexityAnalysis(e, file);
        }

        RelationshipAnalyzer relshAna = new RelationshipAnalyzer();
        foreach (Elem e in table)
        {
            if (e.type == "class" || e.type == "struct" || e.type == "interface")
                relshAna.relationshipanalysis(e, file);

        }
/////////
        foreach (Elem e in table)
        {
          Console.Write("\n  {0,10}, {1,25}, {2,5}, {3,5}, {4,50}", e.type, e.name, e.end-e.begin+1, e.complexity, e.relationship);
        }
        Console.WriteLine();
        Console.Write("\n\n  That's all folks!\n\n");
        semi.close();
      }
    }