From f8a192385685511fdc738ae91460d7290a40b90d Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 22 Sep 2015 20:34:47 -0500 Subject: [PATCH 1/3] 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); } From 37610790ac0407ea6af52843657c83454cf24cac Mon Sep 17 00:00:00 2001 From: William Bracho Blok Date: Tue, 22 Sep 2015 21:05:11 -0500 Subject: [PATCH 2/3] Update Parserv2.cpp --- Parserv2.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Parserv2.cpp b/Parserv2.cpp index a50b1f1..13486cb 100755 --- a/Parserv2.cpp +++ b/Parserv2.cpp @@ -120,6 +120,8 @@ vector showCMD(vector input) cout<<"\nPassing the following arguments to dbEngine: "< exitCMD(vector input) @@ -131,6 +133,8 @@ vector exitCMD(vector input) if (input[0] != "EXIT") { cout<<"Wrong function/syntax error!"< input) //calls par_command() or par_query() dependi showCMD(input); } + if ( input[0] == "EXIT") + { + exitCMD(input); + } + } @@ -288,12 +297,12 @@ int main () { string ss3 = "EXIT ; "; vector listOfTokens = tokenize(ss); - //vector listOfTokens2 = tokenize(ss2); - //vector listOfTokens3 = tokenize(ss3); + vector listOfTokens2 = tokenize(ss2); + vector listOfTokens3 = tokenize(ss3); par_line(listOfTokens); - //par_line(listOfTokens2); - //par_line(listOfTokens3); + par_line(listOfTokens2); + par_line(listOfTokens3); } From 4e33d9d5605263a8a53d73357cea4ed531823801 Mon Sep 17 00:00:00 2001 From: Brandon Jackson <1drummer@att.net> Date: Tue, 22 Sep 2015 21:54:13 -0500 Subject: [PATCH 3/3] Update Parserv2.cpp --- Parserv2.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Parserv2.cpp b/Parserv2.cpp index 13486cb..0db1a5a 100755 --- a/Parserv2.cpp +++ b/Parserv2.cpp @@ -62,7 +62,6 @@ void displayTokenList(vector input) } } - vector insertCMD(vector input) { //relation name will be the first element of the vector of data returned by this function @@ -137,6 +136,47 @@ vector exitCMD(vector input) return input; } +vector saveCMD(vector input) +{ + if (input.size() > 3) + { + cout<<"Syntax error!"< closeCMD(vector input) +{ + if (input.size() > 3) + { + cout<<"Syntax error!"< openCMD(vector input) +{ + if (input.size() > 3) + { + cout<<"Syntax error!"< createCMD(vector input) {