Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
466 B
3
Indexable
#include <bits/stdc++.h>
#include <string>

using namespace std;

bool isLeftRecursive(string s) {
    if (s[0] == s[3]) {
        return true;
    }
    return false;
}

int main(int argc, char const *argv[]) {
    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;
}