Skip to content

Commit

Permalink
removed the testing code. refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bullheadandplato committed Feb 7, 2017
1 parent 1921e54 commit 0443f0f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 85 deletions.
21 changes: 0 additions & 21 deletions Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,28 +208,7 @@ void Parser::inputAndSolve()
}
}

void Parser::display()
{
cout << "FIRST SET" << endl;
for (int i = 0; i<non_colt.size(); i++)
{
cout << non_colt[i] << ": ";
set<char>::iterator it;
for (it = first_set[i].begin(); it != first_set[i].end(); it++)
cout << *it << " ";
cout << endl;
}

cout << "FOLLOW SET" << endl;
for (int i = 0; i<non_colt.size(); i++)
{
cout << non_colt[i] << ": ";
set<char>::iterator it;
for (it = follow_set[i].begin(); it != follow_set[i].end(); it++)
cout << *it << " ";
cout << endl;
}
}
/*
* getter section
*
Expand Down
1 change: 0 additions & 1 deletion Parser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Parser
void get_first(char target);
void get_follow(char target);
void inputAndSolve();
void display();
void setT(int t);
void setProductions(std::vector<string> product);
node *getAnalyString();
Expand Down
63 changes: 0 additions & 63 deletions Parser/TableStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,7 @@ void TableStack::get_table()
}
}
}
void TableStack::analyExp(string s)
{
for (int i = s.length() - 1; i >= 0; i--)
left_any.push_back(s[i]);

to_any.push_back('#');
to_any.push_back(non_colt[0]);


while (left_any.size()>0)
{

string outs = "";
for (int i = 0; i<to_any.size(); i++)
outs += to_any[i];
cout << setw(15) << outs;


outs = "";
for (int i = left_any.size() - 1; i >= 0; i--)
outs += left_any[i];
cout << setw(15) << outs;

char char1 = to_any[to_any.size() - 1];
char char2 = left_any[left_any.size() - 1];
if (char1 == char2 && char1 == '#')
{
cout << setw(15) << "Accepted!" << endl;
return;
}
if (char1 == char2)
{
to_any.pop_back();
left_any.pop_back();
cout << setw(15) << char1 << "match" << endl;
}
else if (tableMap[get_index(char1)][get_nindex(char2)] != -1)
{
int tg = tableMap[get_index(char1)][get_nindex(char2)];
to_any.pop_back();

if (analy_str[tg].right != "$")
{
for (int i = analy_str[tg].right.length() - 1; i >= 0; i--)
to_any.push_back(analy_str[tg].right[i]);
}

cout << setw(15) << analy_str[tg].right << endl;
}
else
{
cout << setw(15) << "error!" << endl;
return;
}
}
}

vector<char> TableStack::getLeftAny(){
return this->left_any;
Expand All @@ -104,15 +49,7 @@ vector<char> TableStack::getRightAny(){
void TableStack::getAns()
{
inputAndSolve();
display();
get_table();

//string ss;
//cout << "Please enter the symbol string:" << endl;
//cin >> ss;
//cout << setw(15) << "Analysis of the stack" << setw(15) << "Remaining input string" << setw(15) << "Derivation" << endl;
//analyExp(ss);

}


0 comments on commit 0443f0f

Please sign in to comment.