diff --git a/poincare/src/simplify/rules_generation/builder.cpp b/poincare/src/simplify/rules_generation/builder.cpp index 9397b4e47..8a469e4c9 100644 --- a/poincare/src/simplify/rules_generation/builder.cpp +++ b/poincare/src/simplify/rules_generation/builder.cpp @@ -14,17 +14,17 @@ void Builder::generateFields(Rule * context, std::string &indentation) { switch (m_type) { case Type::ExpressionType: std::cout << indentation << ".m_action = ExpressionBuilder::Action::BuildFromTypeAndValue," << std::endl; - std::cout << indentation << ".m_expressionType = Expression::Type::" << *m_name << std::endl; + std::cout << indentation << ".m_expressionType = Expression::Type::" << *m_name << "," << std::endl; break; case Type::Variable: std::cout << indentation << ".m_action = ExpressionBuilder::Action::Clone," << std::endl; assert(m_children->size() == 0); - std::cout << indentation << ".m_matchIndex = " << selector->flatIndexOfChildNamed(*m_name) << std::endl; + std::cout << indentation << ".m_matchIndex = " << selector->flatIndexOfChildNamed(*m_name) << "," << std::endl; break; case Type::Wildcard: std::cout << indentation << ".m_action = ExpressionBuilder::Action::BringUpWildcard," << std::endl; assert(m_children->size() == 0); - std::cout << indentation << ".m_matchIndex = " << selector->flatIndexOfChildNamed(*m_name) << std::endl; + std::cout << indentation << ".m_matchIndex = " << selector->flatIndexOfChildNamed(*m_name) << "," << std::endl; break; } } diff --git a/poincare/src/simplify/rules_generation/rules_parser.y b/poincare/src/simplify/rules_generation/rules_parser.y index 1a7e4f06e..04d4b059b 100644 --- a/poincare/src/simplify/rules_generation/rules_parser.y +++ b/poincare/src/simplify/rules_generation/rules_parser.y @@ -106,7 +106,13 @@ int yyerror(std::vector ** rules, char *s) { int main(void) { std::vector * rules = new std::vector(); + yyparse(&rules); + + std::cout << "#include \"simplification_rules.h\"" << std::endl; + std::cout << "#include \"simplification_generator.h\"" << std::endl; + std::cout << std::endl; + int counter = 0; for (int i=0; isize(); i++) { std::stringstream name; @@ -125,6 +131,10 @@ int main(void) { } std::cout << "};" << std::endl; + std::cout << std::endl; + std::cout << "const int knumberOfSimplifications = " << rules->size() << ";" << std::endl; + + delete rules; return 0; } diff --git a/poincare/src/simplify/rules_generation/selector.cpp b/poincare/src/simplify/rules_generation/selector.cpp index 7fff9c532..ef700302c 100644 --- a/poincare/src/simplify/rules_generation/selector.cpp +++ b/poincare/src/simplify/rules_generation/selector.cpp @@ -20,7 +20,7 @@ void Selector::generateFields(Rule * context, std::string &indentation) { assert(parent->m_children->back() == this); break; case Type::ExpressionType: - std::cout << indentation << ".m_match = ExpressionSelector::Match::TypeAndValue," << std::endl; + std::cout << indentation << ".m_match = ExpressionSelector::Match::Type," << std::endl; std::cout << indentation << ".m_expressionType = Expression::Type::" << *m_name << "," << std::endl; break; }