Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- #include "library.h"
- int main()
- {
- ifstream input("input.txt");
- ofstream nonRecursiveFile("non_recursive.txt");
- ofstream recursiveFile("recursive.txt");
- List functionsList;
- bool inFunctionName = false;
- string functionName;
- bool isRecursive = false;
- bool inFunction = false;
- string ForWhileFlag = "";
- while (!input.eof()) {
- string line;
- getline(input, line);
- if (!inFunction) {
- for (char c : line) {
- if (inFunctionName && (c == ' ' or c == ':') && line.find("(") != string::npos) {
- functionName="";
- }
- if (c == '(') {
- inFunctionName = false;
- }
- if (inFunctionName and c!='{' and c!=' ' and c!=':') {
- functionName += c;
- }
- if (!inFunctionName && (c == ' ' or c == ':') && line.find("(") != string::npos && functionName.empty()) {
- inFunctionName = true;
- }
- if (!functionName.empty() and c == '{' or functionsList.InList(functionName)) {
- inFunction = true;
- }
- }
- }
- // можно убрать условие но тогда будут находится различные вызовы функций из разряда functionsList.InList(){...
- else if (functionName.find(";") == string::npos and functionName.find(",") == string::npos and functionName.find(".") == string::npos and functionName.find("'") == string::npos){
- //cout << line << "!!!" << functionName << " " << line.find(functionName) << endl;
- if (line.find("return") != string::npos) {
- if (line.find(functionName)!=string::npos) isRecursive = true;
- if (!functionName.empty()) {
- functionsList.addFunction(functionName, isRecursive);
- }
- }
- else {
- functionsList.addFunction(functionName, isRecursive);
- }
- if (functionsList.InList(functionName)) {
- inFunctionName = false;
- functionName.clear();
- isRecursive = false;
- inFunction = false;
- }
- }
- }
- functionsList.PrintR(recursiveFile);
- functionsList.PrintNR(nonRecursiveFile);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement