Update Parserv2
This commit is contained in:
parent
4afb431044
commit
ac43cf74b9
1 changed files with 44 additions and 11 deletions
51
Parserv2
51
Parserv2
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
return output;
|
||||||
{
|
|
||||||
cout<<"Syntax error!"<<endl;
|
|
||||||
}
|
}
|
||||||
//displayTokenList(input);
|
|
||||||
|
else cout<<"Syntax error!"<<endl;
|
||||||
|
}
|
||||||
|
else cout<<"Syntax error!"<<endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else cout<<"Syntax error!"<<endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue