From 0443f0fc182448c18437e2ba7d360eb13cbf5070 Mon Sep 17 00:00:00 2001 From: Osama Date: Tue, 7 Feb 2017 18:49:31 +0500 Subject: [PATCH] removed the testing code. refactoring --- Parser/Parser.cpp | 21 --------------- Parser/Parser.h | 1 - Parser/TableStack.cpp | 63 ------------------------------------------- 3 files changed, 85 deletions(-) diff --git a/Parser/Parser.cpp b/Parser/Parser.cpp index 77568b8..911459f 100644 --- a/Parser/Parser.cpp +++ b/Parser/Parser.cpp @@ -208,28 +208,7 @@ void Parser::inputAndSolve() } } -void Parser::display() -{ - cout << "FIRST SET" << endl; - for (int i = 0; i::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::iterator it; - for (it = follow_set[i].begin(); it != follow_set[i].end(); it++) - cout << *it << " "; - cout << endl; - } -} /* * getter section * diff --git a/Parser/Parser.h b/Parser/Parser.h index 5efd18b..d58955e 100644 --- a/Parser/Parser.h +++ b/Parser/Parser.h @@ -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 product); node *getAnalyString(); diff --git a/Parser/TableStack.cpp b/Parser/TableStack.cpp index 74975a2..2c565c5 100644 --- a/Parser/TableStack.cpp +++ b/Parser/TableStack.cpp @@ -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= 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 TableStack::getLeftAny(){ return this->left_any; @@ -104,15 +49,7 @@ vector 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); - }