aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-23 21:06:23 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-23 21:06:23 +0000
commit3a8cbbd0c0b9b8bc80d4346d98a305671f0869a9 (patch)
tree4cb81cea231e243b003065d705bf592a62132aa1
parent64d1100ea5a2f749db3a635d5fb2a688a551ecb7 (diff)
downloadCompiler-3a8cbbd0c0b9b8bc80d4346d98a305671f0869a9.tar.gz
Compiler-3a8cbbd0c0b9b8bc80d4346d98a305671f0869a9.zip
Making hierarchy better
-rw-r--r--c_compiler/include/expression.hpp9
-rw-r--r--c_compiler/src/c_parser.y2
-rw-r--r--c_compiler/src/expression.cpp10
3 files changed, 5 insertions, 16 deletions
diff --git a/c_compiler/include/expression.hpp b/c_compiler/include/expression.hpp
index 0ded5c2..57c24ef 100644
--- a/c_compiler/include/expression.hpp
+++ b/c_compiler/include/expression.hpp
@@ -30,9 +30,7 @@ public:
virtual int postfixStackPosition(VariableStackBindings bindings) const;
virtual void setPostfixExpression(Expression *postfix_expression);
virtual std::string id() const;
- virtual ExpressionPtr getLhs() const;
- virtual ExpressionPtr getRhs() const;
-
+
void linkExpression(Expression* next_expression);
ExpressionPtr nextExpression() const;
};
@@ -51,8 +49,9 @@ public:
virtual int constantFold() const;
virtual void expressionDepth(unsigned &depth_count) const;
- virtual ExpressionPtr getLhs() const;
- virtual ExpressionPtr getRhs() const;
+
+ ExpressionPtr getLhs() const;
+ ExpressionPtr getRhs() const;
void evaluateExpression(VariableStackBindings bindings, unsigned &label_count) const;
};
diff --git a/c_compiler/src/c_parser.y b/c_compiler/src/c_parser.y
index 2f26ade..1bdfe12 100644
--- a/c_compiler/src/c_parser.y
+++ b/c_compiler/src/c_parser.y
@@ -286,7 +286,7 @@ AssignmentExpression:
ConditionalExpression { $$ = $1; }
| UnaryExpression ASSIGN_OPER AssignmentExpression
{
- Expression* tmp;
+ OperationExpression* tmp;
if(*$2 == "=") {
$$ = new AssignmentExpression($1, $3);
} else if(*$2 == "+=") {
diff --git a/c_compiler/src/expression.cpp b/c_compiler/src/expression.cpp
index f55246b..b07a31e 100644
--- a/c_compiler/src/expression.cpp
+++ b/c_compiler/src/expression.cpp
@@ -44,16 +44,6 @@ std::string Expression::id() const
return "";
}
-ExpressionPtr Expression::getLhs() const
-{
- throw std::runtime_error("Error : Cannot get lhs");
-}
-
-ExpressionPtr Expression::getRhs() const
-{
- throw std::runtime_error("Error : Cannot get rhs");
-}
-
void Expression::linkExpression(Expression *next_expression)
{
ExpressionPtr expression_ptr(next_expression);