Update Parserv2

This commit is contained in:
William Bracho Blok 2015-09-22 17:11:51 -05:00
parent 4afb431044
commit ac43cf74b9

View file

@ -63,22 +63,51 @@ void displayTokenList(vector<string> input)
} }
void insertCMD(vector<string> input) vector<string> insertCMD(vector<string> input)
{ {
string relationName; //relation name will be the first element of the vector of data returned by this function
vector<string> output;
cout<<"insert-cmd function was called"<<endl;
if (input[0] == "INTO") if (input[0] == "INTO")
{ {
input.erase(input.begin()); input.erase(input.begin());
relationName = input[0];
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!"<<endl;
}
else cout<<"Syntax error!"<<endl;
} }
else else cout<<"Syntax error!"<<endl;
{
cout<<"Syntax error!"<<endl;
}
//displayTokenList(input);
} }
@ -121,8 +150,12 @@ void par_line(vector<string> input) //calls par_command() or par_query() dependi
if ( input[0] == "INSERT") if ( input[0] == "INSERT")
{ {
cout<<"\nPassing the following arguments to dbEngine: \nCommand type: "<<input[0]<<endl;
input.erase(input.begin()); input.erase(input.begin());
insertCMD(input); vector<string> insertInput = insertCMD(input);
cout<<"arguments: "<<endl;
displayTokenList(insertInput);
} }
} }