-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsymbolTableProcess.cpp
More file actions
833 lines (823 loc) · 23.9 KB
/
Copy pathsymbolTableProcess.cpp
File metadata and controls
833 lines (823 loc) · 23.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
/*
Author - Brandon Streets-McLeod
Last modified - 03/05/2021
A C file information system - this takes an inputted C file and returns all variables and functions plus the number of times they are referenced
*/
#include "symbolTableProcess.h"//includes the function definitions of all functions
using namespace std;
//countIf is used to count all if statements
int countIf (string line[100], int length)//function to find all occurences of If statements
{
int ifCount = 0;
int lineLength = length;
for (int x = 0; x < lineLength; x++)//loops through each line
{
int found = line[x].find("if");//checks if the line has "if" on it
if (found != string::npos)//if the line does have if then it breaks in
{
ifCount++;//increments the counter
}
}
return ifCount;//returns counter
}
//countFor is used to count all for statements
int countFor (string line[100], int length)
{
int forCount = 0;
int lineLength = length;
string identName;
static const string stringArr[] = {"int ","short ","long long","long ","double ","char ","float ","void ", "char*"};//array of all possible prefixes for variables and functions
int arrLength = 8, forFlag = 5;
for (int x = 0; x < lineLength; x++)//loops through each line of file
{
int found = line[x].find("for");//checks for "for" occurences
if (found != string::npos)//breaks in if true
{
forCount++;//increments counter
}
for (int y = 0;y < arrLength;y++)//loops through each array reference
{
istringstream iss{line[x]};//creates a string stream with the array value x
vector<string> stringSplit//vector to store each part of the line - "this is a test" would be stored as "this" "is" "a" "test"
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()//iterates through the string, inserting each value into the string stream 'iss'
};
for (auto sepWord : stringSplit)//assigns the value of stringSplit to sepWord
{
if (sepWord.compare(")") == 0)//uses .compare to see if the variable is equal to the values ASCII value
{
forFlag = 5;
}
else if (sepWord.compare("for") == 0)
{
forFlag = 0;
}
else if (sepWord.compare("(") == 0 && forFlag == 0)
{
forFlag = 1;
}
else if (forFlag == 1)
{
sepWord = sepWord + " ";
if (sepWord.compare(stringArr[y]) == 0)
{
forFlag = 2;
}
}
else if (forFlag == 2)
{
int semiCPos = sepWord.find(";");//checks for semi-colons on the end of words
string name = sepWord.substr(0,semiCPos);//removes the semi-colon if there
identName.assign(name);
forFlag = 0;
outputIdentifier(line, lineLength, identName, x+1, "var", stringArr[y]);//calls function to output to file
}
}
}
}
return forCount;//returns counter
}
//countWhile is used to count all while statements
int countWhile (string line[100], int length)
{
int whileCount = 0;
int lineLength = length;
for (int x = 0; x < lineLength; x++)//loops through each line
{
int found = line[x].find("while");
if (found != string::npos)
{
whileCount++;//increments counter
}
}
return whileCount;//returns counter
}
//remove_spaces is used to remove spaces from the end of variables
string remove_spaces(const string &string)
{
int last = string.size() - 1;
while (last >= 0 && string[last] == ' ')//loops through each character in the string looking for a space on the end
--last;
return string.substr(0, last + 1);//returns a new string with all the spaces on the end removed
}
//outputIdentifier is used to output identifiers to the identifiers.txt file
void outputIdentifier (string line[100], int length, string identName, int lineNum, string identType, string identReturnType)
{
int fileLength = length;
int numOfRef = 0, jump = 0, funcFound = 0, oBrackCount, returnJump = 0;
string funcName;
string name, arrName;
string blackList;
if (identType.compare("func") != 0)//checks if the identifier type is not a function
{
for (int x = lineNum-1; x < fileLength; x++)//loops through file
{
if (line[x].find("return ") != string::npos)//checks if the line contains a return statement
{
if (identName.find(funcName) == string::npos)//checks if the identifier name doesnt equal the function name
{
x = fileLength-1;//assigns the last line value to x
}
}
else if (identName.find("(") != string::npos && identName.find(")") != string::npos)//checks for brackets in the identifier name
{
int bracketPos = identName.find("(");
name = identName.substr(0,bracketPos);//gets the name of the variable from the identifier name
int endBracketPos = identName.length();
funcName = identName.substr(bracketPos+1,endBracketPos-bracketPos-2);//gets function name from the identifier name
}
else if (identName.find("(") == string::npos && identName.find(")") == string::npos)//checks there isnt any brackets in the identifier name
{
int bracketPos = identName.find("[");
name = identName.substr(0,bracketPos);//removes the square brackets from the end of the array type
int endBracketPos = identName.length();
arrName = identName.substr(bracketPos+1,endBracketPos-bracketPos-2);
istringstream iss{line[x]};//creates strign stream from line[x]
vector<string> stringSplit//creates a vector
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)//loops through vector
{
if (sepWord.compare(arrName) == 0)//checks that sepWord doesnt equal array name
{
numOfRef++;//increments counter
}
}
}
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
if (line[x].find("return ") != string::npos || line[x].find("main") != string::npos)//checks if the line contains return or main
{
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)//checks if sepWord is equal to the variable name
{
numOfRef++;//increments counter
}
else if (sepWord.compare("main") == 0)//checks if sepWord is equal to "main"
{
x = fileLength;//assigns fileLength to x
}
}
x = fileLength;//assigns fileLength to x
}
else if (line[x].find(funcName) != string::npos && line[x].find("}") == string::npos && blackList.compare(name) != 0)//checks if the line has the function name on it and the name isnt on the blacklist already
{
if (line[x].find("{") != string::npos)//checks for curly bracket
{
oBrackCount++;//increments counter
}
else if (line[x].find("}") != string::npos)//checks for curly bracket
{
oBrackCount--;//decrements counter
}
jump = 1;
funcFound = 1;
for (auto sepWord : stringSplit)//loops through vector
{
name = remove_spaces(name);//removes spaces from the end of the variable
if (sepWord.compare(name) == 0)//checks if sepWord is equal to name
{
numOfRef++;//increments counter
}
}
}
else if (line[x].find(funcName) == string::npos && line[x].find("}") == string::npos && blackList.compare(name) != 0)//checks if there is no function name on the line
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 1;
funcFound = 1;
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)
{
numOfRef++;//increments counter
blackList = name;//assigns name to blacklist
}
}
}
else if (line[x].find("main") != string::npos)//checks if line has main on it
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 1;
}
else if ((jump == 1 || funcFound == 1) && line[x].find("}") == string::npos)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)
{
numOfRef++;//increments counter
blackList = name;//assigns name to blacklist
}
}
}
else if (line[x].find("}") == string::npos)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
istringstream iss{line[x+1]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare("\n") == 0)//checks if line has a new line character on it
{
x = fileLength;//sets x to equal fileLength
}
}
}
else
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 0;
funcFound = 0;
}
}
}
else if (identType.compare("func") == 0)//checks if the identifier type does equal function
{
for (int x = lineNum-1; x < fileLength; x++)
{
if (identName.find("(") != string::npos && identName.find(")") != string::npos)
{
int bracketPos = identName.find("(");
name = identName.substr(0,bracketPos);
int endBracketPos = identName.length();
funcName = identName.substr(bracketPos+1,endBracketPos-bracketPos-2);
}
else if (identName.find("(") == string::npos && identName.find(")") == string::npos)
{
int bracketPos = identName.find("[");
name = identName.substr(0,bracketPos);
int endBracketPos = identName.length();
arrName = identName.substr(bracketPos+1,endBracketPos-bracketPos-2);
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare(arrName) == 0)
{
numOfRef++;
}
}
}
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
if (line[x].find(funcName) != string::npos && line[x].find("}") == string::npos && blackList.compare(name) != 0)//checks there isnt a function name on the line
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 1;
funcFound = 1;
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)
{
numOfRef++;
}
}
}
else if (line[x].find(funcName) == string::npos && line[x].find("}") == string::npos && blackList.compare(name) != 0)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 1;
funcFound = 1;
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)
{
numOfRef++;
blackList = name;
}
}
}
else if (line[x].find("main") != string::npos)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 1;
}
else if ((jump == 1 || funcFound == 1) && line[x].find("}") == string::npos)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
for (auto sepWord : stringSplit)
{
name = remove_spaces(name);
if (sepWord.compare(name) == 0)
{
numOfRef++;
blackList = name;
}
}
}
else if (line[x].find("}") == string::npos)
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
istringstream iss{line[x+1]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare("\n") == 0)
{
x = fileLength;
}
}
}
else
{
if (line[x].find("{") != string::npos)
{
oBrackCount++;
}
else if (line[x].find("}") != string::npos)
{
oBrackCount--;
}
jump = 0;
funcFound = 0;
}
}
}
ofstream outFile("identifiers.txt",ios_base::app);//opens file stream with the type to append on the end of the file
outFile << identName << " , " << lineNum << " , " << identType << " , " << identReturnType << ", " << numOfRef-1 << endl;//outputs to file
outFile.close();//closes file
}
//printToFile is used to get names of variables and add their function to the end of them if they are function definitions
void printToFile (string line[100], int length, int x, string stringType)
{
int lineLength = length;
string identName;
int flag = 0, count = 0;
string returnType = stringType;
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (line[x].find("(") == string::npos)//checks there is no brackets
{
if (sepWord.compare(returnType) != 0 && flag == 0)//checks if sepWord and the return type are the same
{
flag = 1;
if (returnType.compare("long long") == 0 && count == 0)//checks if return type is long long
{
flag = 0;
count = 1;
}
}
else if (flag == 1)
{
int semiCPos = sepWord.find(";");
string name = sepWord.substr(0,semiCPos);//removes semi-colon
identName.assign(name);
flag = 2;
if (line[x].find("[") != string::npos)//checks for square brackets
{
string arrName = identName + "[]";
outputIdentifier(line, lineLength, arrName, x+1, "arr", stringType);//calls function with correct parameters
}
else if (line[x].find("main") == string::npos)
{
outputIdentifier(line, lineLength, identName, x+1, "var", stringType);//calls function with correct parameters
}
}
}
}
}
//prints functions to file
void funcPrintToFile (string line[100], int length, int x, string stringType, string funcName)
{
int lineLength = length;
string identName;
int flag = 0, count = 0, jump = 0;
string returnType = stringType;
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (funcName.compare("main") == 0)
{
if (sepWord.compare(returnType) == 0)
{
flag = 3;
}
else if (flag == 3)
{
string fullName = sepWord;
flag = 0;
outputIdentifier(line, lineLength, fullName, x+1, "var", stringType);
}
}
else if (sepWord.compare(returnType) == 0 && flag == 0)
{
flag = 1;
if (returnType.compare("long long") == 0 && count == 0)
{
flag = 0;
count = 1;
}
}
else if (sepWord.compare(returnType) != 0 && flag == 0)
{
flag = 1;
if (returnType.compare("long long") == 0 && count == 0)
{
flag = 0;
count = 1;
}
}
else if (flag == 0 && sepWord.compare("for ") != 0)
{
if (sepWord.compare("(") != 0)
{
flag = 2;
}
}
else if (flag == 1 && sepWord.compare("main ") != 0)
{
if (sepWord.compare("(") != 0)
{
flag = 2;
}
}
else if (flag == 2)
{
if (sepWord.compare("(") == 0 || sepWord.compare(")") == 0)
{
jump = 1;
}
else if (jump == 1)
{
jump = 2;
}
else if (jump == 2)
{
if (sepWord.compare(returnType) != 0)
{
int semiCPos = sepWord.find(";");
string name = sepWord.substr(0,semiCPos);
identName.assign(name);
string fullName = identName + "(" + funcName + ")";
flag = 0;
outputIdentifier(line, lineLength, fullName, x+1, "var", stringType);
}
}
}
else
{
jump = 1;
}
}
}
//countFunctions is used to count total number of functions
int countFunctions (string line[100], int length)
{
int lineLength = length;
static const string stringArr[] = {"int ","short ","long long","long ","double ","char ","float ","void ", "char*"};
int arrLength = 8, funcCount = 0, delimitLength = 3;
string identName, funcName;
int flag = 0, inFunc = 0, forFlag;
for (int x = 0;x < lineLength;x++)//loops through file
{
for (int y = 0;y < arrLength;y++)//loops through array of prefixes
{
flag = 0;
int found = line[x].find(stringArr[y]);
int found2 = line[x].find("(");
int found3 = line[x].find("{");
int found4 = line[x].find("=");
int found5 = line[x].find("}");
int found6 = line[x].find("main");
if (found6 != string::npos)
{
identName.assign("main");
funcCount++;
outputIdentifier(line, lineLength, identName, x+1, "func", stringArr[y]);//calls function with correct parameters
funcPrintToFile (line, lineLength, x, stringArr[y], identName);//calls function with correct parameters
x = lineLength;
}
else if (found != string::npos && found2 != string::npos && found4 == string::npos)
{
funcCount++;
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare(stringArr[y]) != 0 && flag == 0)//checks if sepWord is equal to the value in stringArr[y]
{
flag = 1;
}
else if (flag == 1)
{
identName.assign(sepWord);
flag = 2;
outputIdentifier(line, lineLength, identName, x+1, "func", stringArr[y]);//calls function with correct parameters
funcPrintToFile (line, lineLength, x, stringArr[y], identName);//calls function with correct parameters
}
}
}
else if (found3 != string::npos)
{
istringstream iss{line[x+1]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
sepWord = sepWord + " ";
if (sepWord.compare(stringArr[y]) == 0 && flag == 0)
{
flag = 1;
}
else if (flag == 1)
{
funcName.assign(identName);
int semiCPos = sepWord.find(";");
string name = sepWord.substr(0,semiCPos);
identName.assign(name);
string fullName = identName + "(" + funcName + ")";
flag = 0;
outputIdentifier(line, lineLength, fullName, x+2, "var", stringArr[y]);//calls function with correct parameters
}
}
}
}
}
return funcCount;//returns counter
}
//countVariables counts the total number of variables in a file
int countVariables (string line[100], int length)
{
int lineLength = length;
int varCount = 0, funcCount = 0;
static const string stringArr[] = {"int","int*","short","long","double","char","char*","long*","float","void"};
static const string stringArr2[] = {"int ","int* ","short ","long ","double ","char ","char* ","long* ","float ","void "};
int arrLength = 10, found2 = 0;
string identName;
int flag = 0, allFound = 0, mainFound = 0;
for (int x = 0;x < lineLength;x++)
{
for (int y = 0;y < arrLength;y++)
{
int found = line[x].find(stringArr2[y]);
if (found != string::npos)
{
int found2 = line[x].find("main", found+1);
int found3 = line[x].find("long ", found+1);
if (found2 != string::npos)
{
mainFound = 1;
}
else if (found3 == string::npos && mainFound == 1)
{
if (line[x].find("(", found) == string::npos)
{
found = line[x].find(stringArr2[y], found+1);
if (found != string::npos)
{
for (int z = 0; z < arrLength;z++)
{
while (found != string::npos)
{
varCount++;
printToFile (line, lineLength, x, stringArr2[y]);//calls function with correct parameters
found = line[x].find(stringArr2[z], found+1);
}
}
}
else
{
for (int z = 0; z < arrLength;z++)
{
found = line[x].find(stringArr2[z], found+1);
while (found != string::npos && line[x].find("(", found+1) == string::npos)
{
varCount++;
printToFile (line, lineLength, x, stringArr2[y]);
found = line[x].find(stringArr2[z], found+1);
}
}
}
}
else
{
varCount++;
funcPrintToFile (line, lineLength, x, stringArr[y], "main");//calls function with correct parameters
}
}
else if (mainFound == 0)
{
found = line[x].find(stringArr[y], found+1);
if (found != string::npos)
{
for (int z = 0; z < arrLength;z++)
{
while (found != string::npos)
{
varCount++;
printToFile (line, lineLength, x, stringArr[y]);//calls function with correct parameters
found = line[x].find(stringArr[z], found+1);
}
}
}
else
{
for (int z = 0; z < arrLength;z++)
{
found = line[x].find(stringArr2[z]);
found2 = line[x].find("(", found+1);
if (found != string::npos && found2 != string::npos)
{
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare("(") == 0)
{
flag = 1;
}
else if (sepWord.compare("(") != 0 && flag == 0 && line[x].find("(") == string::npos)
{
if (sepWord.compare(stringArr[z]) == 0)
{
varCount++;
printToFile(line, lineLength, x, stringArr[y]);//calls function with correct parameters
flag = 0;
}
}
else if (flag == 1 && sepWord.compare(stringArr[z]) == 0)
{
flag = 2;
}
else if (flag == 2)
{
varCount++;
printToFile(line, lineLength, x, stringArr[y]);
flag = 0;
}
}
}
else if (found != string::npos && found2 == string::npos)
{
istringstream iss{line[x]};
vector<string> stringSplit
{
istream_iterator<std::string>(iss),
istream_iterator<std::string>()
};
for (auto sepWord : stringSplit)
{
if (sepWord.compare(stringArr2[z]) == 0)
{
flag = 1;
}
else if (flag == 1)
{
varCount++;
printToFile (line, lineLength, x, stringArr2[y]);//calls function with correct parameters
found = line[x].find(stringArr2[z], found+1);
flag = 0;
}
}
}
}
}
}
else if (found3 != string::npos)
{
varCount++;
printToFile (line, lineLength, x, "long long");//calls function with correct parameters
}
else if (line[x].find("(", found) == string::npos)
{
found = line[x].find(stringArr[y], found+1);
if (found != string::npos)
{
varCount++;
printToFile (line, lineLength, x, stringArr[y]);//calls function with correct parameters
}
}
}
}
}
return varCount;//returns counter
}