Update Parserv3.h
This commit is contained in:
parent
670668124b
commit
6f10af0b32
1 changed files with 130 additions and 124 deletions
254
Parserv3.h
254
Parserv3.h
|
@ -7,17 +7,24 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
class Relation
|
class Relation
|
||||||
{
|
{
|
||||||
string name;
|
string name;
|
||||||
|
|
||||||
public:
|
Relation(string str)
|
||||||
|
{
|
||||||
|
name = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRelation(string str)
|
||||||
|
{
|
||||||
|
name = str;
|
||||||
|
}
|
||||||
string getName()
|
string getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +43,7 @@ class Union
|
||||||
{
|
{
|
||||||
return "Union of " + Un1 + " and " + Un2;
|
return "Union of " + Un1 + " and " + Un2;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Product
|
class Product
|
||||||
{
|
{
|
||||||
|
@ -53,9 +60,9 @@ class Product
|
||||||
{
|
{
|
||||||
return "Product of " + Pr1 + " and " + Pr2;
|
return "Product of " + Pr1 + " and " + Pr2;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Difference()
|
class Difference
|
||||||
{
|
{
|
||||||
string D1;
|
string D1;
|
||||||
string D2;
|
string D2;
|
||||||
|
@ -70,14 +77,14 @@ class Difference()
|
||||||
{
|
{
|
||||||
return "Difference of " + D1 + " and " + D2;
|
return "Difference of " + D1 + " and " + D2;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Rename()
|
class Renaming
|
||||||
{
|
{
|
||||||
string newName;
|
string newName;
|
||||||
string oldName;
|
string oldName;
|
||||||
|
|
||||||
Rename(string s1, string s2)
|
Renaming(string s1, string s2)
|
||||||
{
|
{
|
||||||
newName = s1;
|
newName = s1;
|
||||||
oldName = s2;
|
oldName = s2;
|
||||||
|
@ -87,156 +94,155 @@ class Rename()
|
||||||
{
|
{
|
||||||
return "Renaming " + oldName + " to " + newName;
|
return "Renaming " + oldName + " to " + newName;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Projection()
|
class Projection
|
||||||
{
|
{
|
||||||
string newName;
|
string newName;
|
||||||
string oldName;
|
string oldName;
|
||||||
|
|
||||||
Rename(string s1, string s2)
|
Projection(string s1, string s2)
|
||||||
{
|
{
|
||||||
newName = s1;
|
newName = s1;
|
||||||
oldName = s2;
|
oldName = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string doRename()
|
string doProjection()
|
||||||
{
|
{
|
||||||
return "Projecting " + oldName + " onto " + newName;
|
return "Projecting " + oldName + " onto " + newName;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Operand()
|
class Operand
|
||||||
{
|
{
|
||||||
string op;
|
string op;
|
||||||
|
|
||||||
Operand(string str)
|
public:
|
||||||
{
|
|
||||||
op = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOperand(string str)
|
Operand()
|
||||||
{
|
{
|
||||||
op = str;
|
}
|
||||||
}
|
|
||||||
|
Operand(string str)
|
||||||
string getOperand()
|
{
|
||||||
{
|
op = str;
|
||||||
return op;
|
}
|
||||||
}
|
|
||||||
}
|
void setOperand(string str)
|
||||||
|
{
|
||||||
|
op = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
string getOperand()
|
||||||
|
{
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Op()
|
class Op
|
||||||
{
|
{
|
||||||
string op;
|
string op;
|
||||||
|
|
||||||
Op(string str)
|
public:
|
||||||
{
|
Op()
|
||||||
op = str;
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOp(string str)
|
Op(string str)
|
||||||
{
|
{
|
||||||
op = str;
|
op = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getOp()
|
void setOp(string str)
|
||||||
{
|
{
|
||||||
return op;
|
op = str;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
string getOp()
|
||||||
|
{
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Comparison()
|
class Comparison
|
||||||
{
|
{
|
||||||
Op op;
|
Op op;
|
||||||
Operand operand1;
|
Operand operand1;
|
||||||
Operand operand2;
|
Operand operand2;
|
||||||
|
|
||||||
Comparison(string str1, string str2, string str3)
|
public:
|
||||||
{
|
|
||||||
operand1.setOperand(str1);
|
|
||||||
op.setOp(str2);
|
|
||||||
operand2.setOperand(str3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setComparison(string str1, string str2, string str3)
|
Comparison(string str1, string str2, string str3)
|
||||||
{
|
{
|
||||||
operand1.setOperand(str1);
|
operand1.setOperand(str1);
|
||||||
op.setOp(str2);
|
op.setOp(str2);
|
||||||
operand2.setOperand(str3);
|
operand2.setOperand(str3);
|
||||||
}
|
}
|
||||||
|
|
||||||
string getComparison()
|
void setComparison(string str1, string str2, string str3)
|
||||||
{
|
{
|
||||||
return op1.getOperand() + " " + op.getOp() + " " + op2.getOperand();
|
operand1.setOperand(str1);
|
||||||
}
|
op.setOp(str2);
|
||||||
}
|
operand2.setOperand(str3);
|
||||||
|
}
|
||||||
|
|
||||||
|
string getComparison()
|
||||||
|
{
|
||||||
|
return operand1.getOperand() + " " + op.getOp() + " " + operand2.getOperand();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Conjunction()
|
class Conjunction
|
||||||
{
|
{
|
||||||
string conj;
|
string conj;
|
||||||
|
public:
|
||||||
Conjunction(string str)
|
Conjunction(string str)
|
||||||
{
|
{
|
||||||
conj = str;
|
conj = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setConjunction(string str)
|
void setConjunction(string str)
|
||||||
{
|
{
|
||||||
conj = str;
|
conj = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getConjunction()
|
string getConjunction()
|
||||||
{
|
{
|
||||||
return conj;
|
return conj;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Condition()
|
class Condition
|
||||||
{
|
{
|
||||||
string cond;
|
string cond;
|
||||||
|
public:
|
||||||
Condition(string str)
|
Condition(string str)
|
||||||
{
|
{
|
||||||
cond = str;
|
cond = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCondition(string str)
|
void setCondition(string str)
|
||||||
{
|
{
|
||||||
cond = str;
|
cond = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getCondition()
|
string getCondition()
|
||||||
{
|
{
|
||||||
return cond;
|
return cond;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class Selection()
|
class Selection
|
||||||
{
|
{
|
||||||
string select;
|
string select;
|
||||||
|
public:
|
||||||
Selection(string str)
|
Selection(string str)
|
||||||
{
|
{
|
||||||
select = str;
|
select = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getSelection()
|
string getSelection()
|
||||||
{
|
{
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
class expr
|
|
||||||
{
|
|
||||||
Relation r;
|
|
||||||
|
|
||||||
selection
|
|
||||||
projection
|
|
||||||
renaming
|
|
||||||
Union
|
|
||||||
difference
|
|
||||||
product
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Reference in a new issue