diff options
author | Carlo Zancanaro <carlo@carlo-laptop> | 2012-05-03 15:35:39 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@carlo-laptop> | 2012-05-03 15:35:39 +1000 |
commit | fcecd0e7dc0bf103986c02e2f29fb518cd5571c5 (patch) | |
tree | 518bf3fcb3733bb8cc2ef584346aa409ea618a77 /impl/Expression.hpp | |
parent | 9fd34b8cdc98ee757fc047216bd51c698cb7b82f (diff) |
Add a parser for linear equations
(Also add the antlr jar and C runtime)
Diffstat (limited to 'impl/Expression.hpp')
-rw-r--r-- | impl/Expression.hpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/impl/Expression.hpp b/impl/Expression.hpp index 668f4fd..913bf7a 100644 --- a/impl/Expression.hpp +++ b/impl/Expression.hpp @@ -5,6 +5,9 @@ #include "VariableAssignment.hpp" #include "Operator.hpp" +template<typename T> +struct Variable; + int ExpressionCount; template<typename T> @@ -12,7 +15,9 @@ struct Expression { Expression(Operator<T>* op, const std::vector< Expression<T>* >& args) : _operator(op), _arguments(args) { } virtual ~Expression() { - delete _operator; + if (!dynamic_cast<Variable<T>*>(_operator)) { + delete _operator; + } } virtual T operator() (const VariableAssignment<T>& assignment) const { return (*_operator)(_arguments, assignment); @@ -52,4 +57,6 @@ struct MaxExpression : public Expression<T> { unsigned int _id; }; +#include "Variable.hpp" + #endif |