Professional Documents
Culture Documents
Parser 2
Parser 2
#include<iostream>
#include<stack>
#include<string>
using namespace std;
string input;
it = st.end()-1;
while(*it != '>'){
if(*it == 'd'){
it--;
s.push("id");
}
else if( *it == '\'' ){
it--;
if(*it == 'E'){
s.push("E'");
}
else if(*it == 'T'){
s.push("T'");
}
}
else
{
s.push( string() + *it );
}
--it;
if(s.top() == " "){
s.pop();
}
}
}
void display_stack(){
stack<string> st = s;
while(!st.empty()){
cout<<st.top()<<endl;
st.pop();
}
cout<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
if(flag)
{
if(input[i]=='i'){
i++;
temp = "id";
}
else{
temp = string()+input[i];
}
//algorithm
if(s.empty()){
cout<<"accepted"<<endl;
}
else{
cout<<"not accepted"<<endl;
}
return 0;
}