From 670668124b27d08890c7ea7ee11baf83e7953d80 Mon Sep 17 00:00:00 2001 From: Alex Huddleston Date: Tue, 22 Sep 2015 23:27:34 -0500 Subject: [PATCH] Create Parserv3.h --- Parserv3.h | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 Parserv3.h diff --git a/Parserv3.h b/Parserv3.h new file mode 100644 index 0000000..154cffe --- /dev/null +++ b/Parserv3.h @@ -0,0 +1,242 @@ +#include // std::string +#include // std::cout +#include // std::stringstream +#include +#include + +using namespace std; + + +class Relation +{ + string name; + + public: + + string getName() + { + return name; + } +} + + + +class Union +{ + string Un1; + string Un2; + + Union (string s1, string s2) + { + Un1 = s1; + Un2 = s2; + } + + string getUnion() + { + return "Union of " + Un1 + " and " + Un2; + } +} + +class Product +{ + string Pr1; + string Pr2; + + Product(string s1, string s2) + { + Pr1 = s1; + Pr2 = s2; + } + + string getProduct() + { + return "Product of " + Pr1 + " and " + Pr2; + } +} + +class Difference() +{ + string D1; + string D2; + + Difference(string s1, string s2) + { + D1 = s1; + D2 = s2; + } + + string getDifference() + { + return "Difference of " + D1 + " and " + D2; + } +} + +class Rename() +{ + string newName; + string oldName; + + Rename(string s1, string s2) + { + newName = s1; + oldName = s2; + } + + string doRename() + { + return "Renaming " + oldName + " to " + newName; + } +} + +class Projection() +{ + string newName; + string oldName; + + Rename(string s1, string s2) + { + newName = s1; + oldName = s2; + } + + string doRename() + { + return "Projecting " + oldName + " onto " + newName; + } +} + +class Operand() +{ + string op; + + Operand(string str) + { + op = str; + } + + void setOperand(string str) + { + op = str; + } + + string getOperand() + { + return op; + } +} + +class Op() +{ + string op; + + Op(string str) + { + op = str; + } + + void setOp(string str) + { + op = str; + } + + 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); + } + + void setComparison(string str1, string str2, string str3) + { + operand1.setOperand(str1); + op.setOp(str2); + operand2.setOperand(str3); + } + + string getComparison() + { + return op1.getOperand() + " " + op.getOp() + " " + op2.getOperand(); + } +} + +class Conjunction() +{ + string conj; + + Conjunction(string str) + { + conj = str; + } + + void setConjunction(string str) + { + conj = str; + } + + string getConjunction() + { + return conj; + } +} + +class Condition() +{ + string cond; + + Condition(string str) + { + cond = str; + } + + void setCondition(string str) + { + cond = str; + } + + string getCondition() + { + return cond; + } +} + +class Selection() +{ + string select; + + Selection(string str) + { + select = str; + } + + string getSelection() + { + return select; + } +} + +class expr +{ + Relation r; + + selection + projection + renaming + Union + difference + product + +} +