45 lines
718 B
C++
45 lines
718 B
C++
![]() |
|
||
|
#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;
|
||
|
}
|
||
|
}
|