From 97eaea15f22675f32189176c88d810712b44bd00 Mon Sep 17 00:00:00 2001 From: Rebecca Schofield Date: Tue, 22 Sep 2015 21:17:45 -0500 Subject: [PATCH] updates --- Attribute.cpp | 1 - DBEngine.cpp | 2 +- Parserv2.cpp | 262 -------------------------------------------------- Relation.h | 2 +- 4 files changed, 2 insertions(+), 265 deletions(-) delete mode 100755 Parserv2.cpp diff --git a/Attribute.cpp b/Attribute.cpp index 093aace..eb35167 100755 --- a/Attribute.cpp +++ b/Attribute.cpp @@ -45,7 +45,6 @@ bool Attribute::isKey(){ return key; } -//may need to change primary key implementation int Attribute::getSize(){ return size; } diff --git a/DBEngine.cpp b/DBEngine.cpp index db596e6..a082cd6 100755 --- a/DBEngine.cpp +++ b/DBEngine.cpp @@ -59,7 +59,7 @@ Relation DBEngine::projection(vector input, Relation r){ // } } -//TEST ERRORS MATCHING +//test error matching void DBEngine::rename(Relation& r, vector oldnames, vector newnames){ if (oldnames.size() != newnames.size()) { cout << "Failure to rename: number of attributes do not match."; diff --git a/Parserv2.cpp b/Parserv2.cpp deleted file mode 100755 index 17394b4..0000000 --- a/Parserv2.cpp +++ /dev/null @@ -1,262 +0,0 @@ - -#include // std::string -#include // std::cout -#include // std::stringstream -#include -#include - -using namespace std; - - - -vector tokenize(string ss) -{ - string tempString; - stringstream lineStream(ss); - vector output; - - while (lineStream >> tempString) - { - output.push_back(tempString); - } - - //testing--------------- - cout<<"TokenList: "; - - for (int i = 0; i input) -// { - // // if (input[0] != "(") - // // { - // // cout<<"ERROR! missing parenthesis"< input) -{ - cout<<"TokenList: "< insertCMD(vector input) -{ - //relation name will be the first element of the vector of data returned by this function - vector output; - - if (input[0] == "INTO") - { - input.erase(input.begin()); - - output.push_back(input[0]); //pushing relation name - - input.erase(input.begin()); - - if (input[0] == "VALUES" && input[1] == "FROM") - { - input.erase(input.begin()); - input.erase(input.begin()); - - - if(input[0] == "(") - { - input.erase(input.begin()); - - while(input[0] != ")") //inserting all values to relation - //for (int i = 0; i < 2; ++i) - { - if (input[0] == ",") input.erase(input.begin()); - - output.push_back(input[0]); - - input.erase(input.begin()); - } - - return output; - - } - - else cout<<"Syntax error!"< createCMD(vector input) -{ - //relation name will be the first element of the vector of data returned by this function - // vector output; - - // output.push_back(input[0]) //pushing relation name - - - - // if (input[0] == "VALUES" && input[1] == "FROM") - // { - // input.erase(input.begin()); - // input.erase(input.begin()); - - - // if(input[0] == "(") - // { - // input.erase(input.begin()); - - // while(input[0] != ")") //inserting all values to relation - // //for (int i = 0; i < 2; ++i) - // { - // if (input[0] == ",") input.erase(input.begin()); - - // output.push_back(input[0]); - - // input.erase(input.begin()); - // } - - // return output; - - // } - - // else cout<<"Syntax error!"< input) //calls par_command() or par_query() depending on first item from token list -{ -/* -• Match the first item in the token list and determine weather this is a command or a query. -• Call functions par_command() or par_query(); -• After either par_command() or par_query() returns, make sure the line ends properly with “;” token -*/ - string tempChar = input.back(); - if (tempChar != ";") - { - cout<<"ERROR! missing semicolon "< insertInput = insertCMD(input); - cout<<"arguments: "< insertInput = insertCMD(input); - cout<<"arguments: "< listOfTokens = tokenize(ss); - par_line(listOfTokens); - - -} diff --git a/Relation.h b/Relation.h index ffeadcd..faa89ea 100755 --- a/Relation.h +++ b/Relation.h @@ -17,7 +17,7 @@ public: void renameAttribute(string oldstr, string newstr); int getSize(); void display(); - void insertTuple(vector tuple); //we are assuming they are in order + void insertTuple(vector tuple); //assuming they are in order void insertFromRelation(Relation r); //void removeTuple(); }; \ No newline at end of file