diff --git a/Parser.cpp b/Parser.cpp index cebedb2..86ac480 100755 --- a/Parser.cpp +++ b/Parser.cpp @@ -641,16 +641,13 @@ vector openCMD(vector input, DBEngine &engine) vector exitCMD(vector input, DBEngine &engine) { - exit(0); - return input; } vector createCMD(vector input, DBEngine &engine) { - if (input[0] == "TABLE") { input.erase(input.begin()); @@ -1034,7 +1031,6 @@ void par_line(vector input, DBEngine &engine) //calls par_command() or p cout<<"\nPassing the following arguments to dbEngine: \nCommand: "< insertInput = insertCMD(input, engine); - } else if ( input[0] == "CREATE") @@ -1043,7 +1039,6 @@ void par_line(vector input, DBEngine &engine) //calls par_command() or p input.erase(input.begin()); vector insertInput = createCMD(input, engine); - } else if ( input[0] == "DELETE") @@ -1052,7 +1047,6 @@ void par_line(vector input, DBEngine &engine) //calls par_command() or p input.erase(input.begin()); vector insertInput = deleteCMD(input, engine); - } else if ( input[0] == "UPDATE") @@ -1061,7 +1055,6 @@ void par_line(vector input, DBEngine &engine) //calls par_command() or p input.erase(input.begin()); vector insertInput = updateCMD(input, engine); - } else if ( input[0] == "SHOW") @@ -1119,3 +1112,9 @@ void parse(string input, DBEngine &engine) vector listOfTokens = tokenize(input); par_line(listOfTokens, engine); } + +void parseList(vector input, DBEngine &engine) { + for (int i = 0; i < input.size(); ++i){ + parse(input[i], engine); + } +} diff --git a/Parser.h b/Parser.h index 63ed38a..8418339 100755 --- a/Parser.h +++ b/Parser.h @@ -257,10 +257,11 @@ class PExpression public: - PExpression() { select = "~"; } + PExpression(); PExpression(string str) { temp = str; } void setPExpression(string str) { temp = str; } string getPExpression() { return temp; } }; -void parse(string s, DBEngine &e); \ No newline at end of file +void parse(string s, DBEngine &e); +void parseList(vector input, DBEngine &engine); \ No newline at end of file diff --git a/a.out b/a.out index 2a0ac99..4753e8d 100755 Binary files a/a.out and b/a.out differ diff --git a/parsertest.cpp b/parsertest.cpp index c3a5aa6..4a72962 100755 --- a/parsertest.cpp +++ b/parsertest.cpp @@ -1,7 +1,7 @@ #include #include #include "Parser.h" -//#include "Condition.h" +#include "Condition.h" #include "DBEngine.h" //#include "user.h" @@ -10,5 +10,10 @@ using namespace std; int main () { DBEngine engine; - // + vector s; + s.push_back("CREATE TABLE animals ( name VARCHAR(20), kind VARCHAR(8), years INTEGER ) PRIMARY KEY ( name, kind ) ;"); + s.push_back("CREATE TABLE animals2 ( name VARCHAR(20), kind VARCHAR(8), years INTEGER ) PRIMARY KEY ( name, kind ) ;"); + s.push_back("SHOW animals2 ;"); + s.push_back("SHOW animals2 ;"); + parseList(s, engine); }