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;
- int ForWhileFlag = 0;
- 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 (c == ';' or c=='.' or c=='\'' and !inFunctionName) {
- functionName.clear();
- 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;
- }
- }
- }
- else {
- // без костыля здесь не обойтись :)
- string previosline;
- //cout << line << "!!!" << functionName << " " << line.find(functionName) << endl;
- while (line != "}") {
- if (line.find(functionName) != string::npos) isRecursive = true;
- getline(input, line);
- }
- if (!functionName.empty()) {
- 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