int main(int argc, char* argv[]) { //collecting tokens from files, named on the command line if (argc < 2) { std::cout<< "\n please enter name of file to process on command line\n\n"; return 1; } FileManager fileManager; std::vector<std::string> patterns = { "*.h" , "*.cpp" }; std::vector<std::string> files = fileManager.getFiles("..//", patterns); for (int i = 1; i<argc; ++i) { std::string fileSpec = FileSystem::Path::getFullFileSpec(argv[i]); std::string msg = "Processing file" + fileSpec; ConfigParseToConsole configure; Parser* pParser = configure.Build(); MetricAnalyzer *test = new MetricAnalyzer; try { if (pParser) { if (!configure.Attach(argv[i])) { std::cout << "\n could not open file " << fileSpec << std::endl; continue; } } else { std::cout << "\n\n Parser not built\n\n"; return 1; } while (pParser->next()) { pParser->parse(); } std::cout << "\n"; configure.printTree(); test->setRoot(configure.getRoot()); test->getComplexity(test->getRoot()); test->getComplexity(test->getRoot()); } catch (std::exception& ex) { std::cout << "\n\n " << ex.what() << "\n\n"; } } }
int main(int argc, char* argv[]) { Util::Title("Testing Parser Class", '='); putline(); // collecting tokens from files, named on the command lines std::string path = "C:\\Users\\Sruthi Guvvala\\Desktop\\Project2HelperCode\\Project2HelperCode\\Parser"; std::vector<std::string> a = FileSystem::Directory::getFiles(path, "*.cpp"); std::vector<std::string>::iterator iter = a.begin(); //std::cout << *iter; while (iter != a.end()) { std::string fileSpec = path + "\\" + *iter; std::cout << fileSpec; std::string msg = "Processing file" + fileSpec; Util::title(msg); putline(); ConfigParseToConsole configure; Parser* pParser = configure.Build(); try { if(pParser) { if(!configure.Attach(fileSpec)) { std::cout << "\n could not open file " << fileSpec << std::endl; continue; }} else { std::cout << "\n\n Parser not built\n\n"; return 1; } while (pParser->next()) { pParser->parse(); } std::cout << "\n"; configure.printTree(); } catch(std::exception& ex) { std::cout << "\n\n " << ex.what() << "\n\n"; }iter++; std::cout << "\n"; } }