From fcecd0e7dc0bf103986c02e2f29fb518cd5571c5 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Thu, 3 May 2012 15:35:39 +1000 Subject: Add a parser for linear equations (Also add the antlr jar and C runtime) --- impl/Expression.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'impl/Expression.hpp') 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 +struct Variable; + int ExpressionCount; template @@ -12,7 +15,9 @@ struct Expression { Expression(Operator* op, const std::vector< Expression* >& args) : _operator(op), _arguments(args) { } virtual ~Expression() { - delete _operator; + if (!dynamic_cast*>(_operator)) { + delete _operator; + } } virtual T operator() (const VariableAssignment& assignment) const { return (*_operator)(_arguments, assignment); @@ -52,4 +57,6 @@ struct MaxExpression : public Expression { unsigned int _id; }; +#include "Variable.hpp" + #endif -- cgit v1.2.3