Poincare: Add a Simplification class

Change-Id: Ide99e912262111722e11ae82dbc7eedb591ba14c
This commit is contained in:
Romain Goyet
2016-03-26 21:04:04 +01:00
parent e8b7a9bd83
commit a8feaefe82
4 changed files with 26 additions and 9 deletions

View File

@@ -34,6 +34,7 @@ objs += $(addprefix poincare/src/simplify/,\
simplify_product_zero.o\
expression_selector.o\
expression_builder.o\
simplification.o\
)
tests += $(addprefix poincare/test/,\
addition.cpp\

View File

@@ -41,13 +41,4 @@ public:
uint8_t m_numberOfChildren;
};
/*
{
my_tree_selector, my_expression_builder;
if (my_tree_selector->match(my_expression)) {
my_expression_builder->build(my_expression, *matchedData);
}
}
*/
#endif

View File

@@ -0,0 +1,10 @@
#include "simplification.h"
Expression * Simplification::simplify(Expression * expression) const {
Expression * matches[255]; //FIXME: The sized ca be given by our compiler
if (m_selector->match(expression, matches)) {
return m_builder->build(matches);
} else {
return nullptr;
}
}

View File

@@ -0,0 +1,15 @@
#ifndef POINCARE_SIMPLIFY_SIMPLIFICATION_H
#define POINCARE_SIMPLIFY_SIMPLIFICATION_H
#include <poincare/expression.h>
#include "expression_selector.h"
#include "expression_builder.h"
class Simplification {
public:
ExpressionSelector * m_selector;
ExpressionBuilder * m_builder;
Expression * simplify(Expression * expression) const;
};
#endif