almost done with commands
This commit is contained in:
parent
9953e7fe6a
commit
0cb05ed10a
3 changed files with 5 additions and 49 deletions
44
Parser.cpp
44
Parser.cpp
|
@ -1,44 +0,0 @@
|
||||||
|
|
||||||
#include <string> // std::string
|
|
||||||
#include <iostream> // std::cout
|
|
||||||
#include <sstream> // std::stringstream
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/*
|
|
||||||
as of now, this parser can take a string and break it into tokens
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> tokenize(string ss)
|
|
||||||
{
|
|
||||||
string tempString;
|
|
||||||
stringstream lineStream(ss);
|
|
||||||
vector<string> output;
|
|
||||||
|
|
||||||
while (lineStream >> tempString)
|
|
||||||
{
|
|
||||||
output.push_back(tempString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main () {
|
|
||||||
|
|
||||||
|
|
||||||
string ss = "INSERT INTO animals VALUES FROM ( Joe , cat , 4 ) ;";
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> listOfTokens = tokenize(ss);
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < listOfTokens.size(); ++i)
|
|
||||||
{
|
|
||||||
cout<<" slot "<<i<<" : ";
|
|
||||||
cout<<listOfTokens[i]<<endl;
|
|
||||||
}
|
|
||||||
}
|
|
10
Parserv2.cpp
10
Parserv2.cpp
|
@ -183,14 +183,14 @@ vector<string> deleteCMD(vector<string> input){
|
||||||
cout << "\nPassing the following arguments to dbEngine: " << endl;
|
cout << "\nPassing the following arguments to dbEngine: " << endl;
|
||||||
cout << "command :" << input[0] << endl;
|
cout << "command :" << input[0] << endl;
|
||||||
cout << "relation: " << input[2] << endl;
|
cout << "relation: " << input[2] << endl;
|
||||||
for (int i = 0; i < input.size(); ++i) {
|
cout << "condition: " << input[5] << input[6] << input[7] << endl;
|
||||||
cout << input[i] << "\n";
|
|
||||||
}
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
string ss = "DELETE FROM animals WHERE (age == 12);";
|
string s = "DELETE FROM animals WHERE ( age == 12 ) ;";
|
||||||
|
|
||||||
vector<string> listOfTokens = tokenize(s);
|
vector<string> listOfTokens = tokenize(s);
|
||||||
deleteCMD(listofTokens);
|
deleteCMD(listOfTokens);
|
||||||
}
|
}
|
||||||
|
|
BIN
a.out
Executable file
BIN
a.out
Executable file
Binary file not shown.
Reference in a new issue