From f8a192385685511fdc738ae91460d7290a40b90d Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 22 Sep 2015 20:34:47 -0500 Subject: [PATCH] Update Parserv2.cpp --- Parserv2.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Parserv2.cpp b/Parserv2.cpp index 17394b4..a50b1f1 100755 --- a/Parserv2.cpp +++ b/Parserv2.cpp @@ -7,6 +7,9 @@ using namespace std; +/* + as of now, this parser can take a string and break it into tokens +*/ vector tokenize(string ss) @@ -107,11 +110,33 @@ vector insertCMD(vector input) } +vector showCMD(vector input) +{ + if (input.size() > 3) + { + cout<<"Syntax error!"< exitCMD(vector input) +{ + if (input[1] != ";") + { + cout<<"ERROR: missing semicolon!"< createCMD(vector input) { - //relation name will be the first element of the vector of data returned by this function + // //relation name will be the first element of the vector of data returned by this function // vector output; // output.push_back(input[0]) //pushing relation name @@ -211,6 +236,12 @@ void par_line(vector input) //calls par_command() or par_query() dependi } + if ( input[0] == "SHOW") + { + showCMD(input); + } + + } @@ -253,10 +284,16 @@ int main () { string ss = "INSERT INTO animals VALUES FROM ( Joe , cat , 4 ) ;"; - string ss2 = "CREATE TABLE animals ( name VARCHAR(20) , kind VARCHAR(8) , years INTEGER ) PRIMARY KEY (name, kind);"; + string ss2 = "SHOW Dogs ;"; + string ss3 = "EXIT ; "; vector listOfTokens = tokenize(ss); + //vector listOfTokens2 = tokenize(ss2); + //vector listOfTokens3 = tokenize(ss3); + par_line(listOfTokens); + //par_line(listOfTokens2); + //par_line(listOfTokens3); }