Untitled
unknown
plain_text
3 years ago
462 B
8
Indexable
#include <iostream>
#include <string>
using namespace std;
bool isLeftRecursive(string s) {
if (s[0] == s[3]) {
return true;
}
return false;
}
int main() {
string s;
cout << "Enter a grammar: ";
cin >> s;
if (isLeftRecursive(s)) {
cout << s << " is a left recursive grammar." << endl;
} else {
cout << s << " is not a left recursive grammar." << endl;
}
return 0;
}
Editor is loading...