22BRS1006 CD Lab3
22BRS1006 CD Lab3
Experiment 3
string input;
int index = 0;
bool F();
bool T();
bool E();
bool F() {
if (match('(')) {
if (E() && match(')')) {
return true;
}
return false;
} else if (input[index] == 'a') {
index++;
return true;
}
return false;
}
bool T() {
if (F()) {
while (match('*')) {
if (!F()) return false;
}
return true;
}
return false;
}
bool E() {
if (T()) {
while (match('+')) {
if (!T()) return false;
}
return true;
}
return false;
}
int main() {
cout << "Enter the arithmetic expression: ";
cin >> input;
return 0;
}
Output: