Create Parser.cpp

as of now, this parser can take a string and break it into tokens
This commit is contained in:
William Bracho Blok 2015-09-22 07:32:39 -05:00
parent 9f5d3e5346
commit 7e221bf13e

44
Parser.cpp Normal file
View file

@ -0,0 +1,44 @@
#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;
}
}