#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); }