I have a flow on how to do this program but I need so help. PLEASE GIVE ME A HINT NOT THE ANSWER.
THE FLOW CHART IS IN THE ATTACHMENT. PLEASE CHECK IT OUT BEFORE GIVING HINTS
/***************************************************
The following program will take user's input
and check whether it is in the following language:
<S> ---> a <B> | <A> | b
<A> ---> c <A> | c
<B> ---> d | <A>
****************************************************/
#include<iostream>
#include<string>
using namespace std;
#include<stdlib.h> // for the exit(1) function
char* SProd(char* ThisOne ); // <S> --> a <B> | <A> | b
char* AProd(char* ThisOne ); // <A> --> c <A> | c
char* BProd(char* ThisOne ); // <B> --> d | <A>
char* XProd(char* ThisOne, char x);
int main()
{
string text;
char *ThisOne;
// cout<<"Enter a string"<<endl;
// cin>>text;
cout<<"Enter a string"<<endl;
cin>>text;
*ThisOne = text.begin();
ThisOne = SProd(ThisOne);
if(*ThisOne== '\0') //Check whether there is an extra character at the end
cout<<"valid"<<endl;
else
cout<<"Invalid"<<endl;
system("pause");
return 0;
}
char* XProd(char* ThisOne, char x)
{
ThisOne = XProd(ThisOne, 'a');
ThisOne = XProd(ThisOne, 'b');
ThisOne = XProd(ThisOne, 'c');
ThisOne = XProd(ThisOne, 'd');
}
// <S> --> a <B> | <A> | b
char* SProd(char* ThisOne )
{
if (*ThisOne == 'b')
{
ThisOne++;
return ThisOne;
}
else {
if (*ThisOne == 'a')
{
ThisOne++;
ThisOne = BProd(ThisOne);
return ThisOne;
}
else
{
ThisOne = AProd(ThisOne);
return ThisOne;
}
}
}
// <A> --> c <A> | c
char* AProd(char* ThisOne)
{
if(*ThisOne != 'c')
{
cout<<"Invalid"<<endl;
exit(1);
}
else
{
ThisOne++;
while (*ThisOne == 'c')
ThisOne++;
return ThisOne;
}
}
// <B> --> d | <A>
char* BProd(char* ThisOne)
{
if(*ThisOne = 'd')
{
ThisOne++;
return ThisOne;
}
else
{
ThisOne = AProd(ThisOne);
}
}