33 * By lemonorangeapple
44**/
55void equal_or_less (vector<string>::iterator it, ifstream &file) {
6- // Check if the variable is undeclared
7- bool undeclared = true ;
8- // Loop through the variables
9- for (int i = 0 ; i <= variableCount; i++) {
10- // Check if the variable name matches
11- if (variables[i].name == *(it + 1 )) {
12- // Check if the second argument is an integer
13- if (isInteger (*(it + 2 ))) {
14- // Loop through the variables
15- for (int j = 0 ; j <= variableCount; j++) {
16- // Check if the third argument matches
17- if (variables[j].name == *(it + 3 )) {
18- // Set the undeclared flag to false
19- undeclared = false ;
20- // Set the value of the third argument to the comparison of the first and second arguments
21- variables[j].value = (variables[i].value <= atoi ((*(it + 2 )).c_str ()));
22- // Break out of the loop
23- break ;
24- }
25- }
26- // Break out of the loop
27- break ;
28- }
29- // If the second argument is not an integer
30- else {
31- // Set the undeclared flag to true
32- undeclared = true ;
33- // Loop through the variables
34- for (int j = 0 ; j <= variableCount; j++) {
35- // Check if the second argument matches
36- if (variables[j].name == *(it + 2 )) {
37- // Loop through the variables
38- for (int k = 0 ; k <= variableCount; k++) {
39- // Check if the third argument matches
40- if (variables[k].name == *(it + 3 )) {
41- // Set the undeclared flag to false
42- undeclared = false ;
43- // Set the value of the third argument to the comparison of the first and second arguments
44- variables[k].value = (variables[i].value <= variables[j].value );
45- // Break out of the loop
46- break ;
47- }
48- }
49- // Break out of the loop
50- break ;
51- }
52- }
53- }
54- }
6+ string a = *(it + 1 ), b = *(it + 2 ), c = *(it + 3 );
7+ if (isInteger (b)) {
8+ variables[c] = (variables[a] <= atoi (b.c_str ()));
559 }
56- // If the variable is undeclared
57- if (undeclared) {
58- // Print an error message
59- cerr << " [Error] Variable undeclared." << endl;
10+ else if (isInteger (a)){
11+ variables[c] = (atoi (a.c_str ()) <= variables[b]);
12+ }
13+ else {
14+ variables[c] = (variables[a] <= variables[b]);
6015 }
6116}
0 commit comments