updating with NO testing
This commit is contained in:
parent
f3a378672d
commit
18ba9c1112
1 changed files with 254 additions and 200 deletions
54
Parser.cpp
54
Parser.cpp
|
@ -45,6 +45,59 @@ void displayTokenList(vector<string> input)
|
||||||
Relation condition(vector<string> input, Relation &r)
|
Relation condition(vector<string> input, Relation &r)
|
||||||
{
|
{
|
||||||
Relation rfinal = r;
|
Relation rfinal = r;
|
||||||
|
|
||||||
|
//UNTESTED
|
||||||
|
//testing to see if there is an && or || present
|
||||||
|
if (input.size() > 3) {
|
||||||
|
//test print
|
||||||
|
for (int i = 0; i < input.size(); ++i)
|
||||||
|
cout << "input[i]: " << input[i] << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
//this is probably wrong, added a cout for testing
|
||||||
|
string bin_op = input[3];
|
||||||
|
cout << "bin_op, should be && or ||: " << bin_op << "\n";
|
||||||
|
|
||||||
|
//making each half a new vector, probably a better way to do this
|
||||||
|
vector<string> firsthalf;
|
||||||
|
vector<string> secondhalf;
|
||||||
|
|
||||||
|
//again, all untested. it's weird to not test this stuff
|
||||||
|
for (int i = 0; i < input.size(); ++i){
|
||||||
|
if (i < 3)
|
||||||
|
firsthalf.push_back(input[i]);
|
||||||
|
else
|
||||||
|
secondhalf.push_back(input[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//calling condition again with each half
|
||||||
|
Relation r1 = condition(firsthalf, rfinal);
|
||||||
|
Relation r2 = condition(secondhalf, rfinal);
|
||||||
|
|
||||||
|
//NO IDEA IF THIS ACTUALLY WORKS
|
||||||
|
//HOORAY
|
||||||
|
//HOW THE FUCK DO PEOPLE CODE LIKE THIS
|
||||||
|
if (bin_op == "&&"){
|
||||||
|
//with engine as the DBEngine object that maybe exists
|
||||||
|
return engine.crossProduct(r1, r2);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (bin_op == "||"){
|
||||||
|
//with engine as the DBEngine object that maybe exists
|
||||||
|
return engine.setUnion(r1, r2);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
cout << "Something strange happened. bin_op: " << bin_op << "\n";
|
||||||
|
cout << "Returning the initial relation.";
|
||||||
|
return rfinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
Attribute a1 = r.getAttributeByName(input[0]);
|
Attribute a1 = r.getAttributeByName(input[0]);
|
||||||
input.erase(input.begin());
|
input.erase(input.begin());
|
||||||
string op = input[0];
|
string op = input[0];
|
||||||
|
@ -311,6 +364,7 @@ Relation condition(vector<string> input, Relation &r)
|
||||||
}
|
}
|
||||||
return rfinal;
|
return rfinal;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tuple<vector<string>, Relation> expression(vector<string> input, DBEngine &engine)
|
tuple<vector<string>, Relation> expression(vector<string> input, DBEngine &engine)
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue