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