From d54c9ad84064466da965b24c9f412b388f4c8b61 Mon Sep 17 00:00:00 2001 From: fintarin Date: Wed, 31 Jan 2024 13:02:23 +0300 Subject: [PATCH] Refactor Parser --- include/fintamath/core/IArithmetic.hpp | 16 +- include/fintamath/core/IComparable.hpp | 11 +- include/fintamath/core/IMathObject.hpp | 11 +- include/fintamath/core/Parser.hpp | 173 +++++------------- include/fintamath/expressions/Expression.hpp | 31 ++-- include/fintamath/expressions/IExpression.hpp | 11 +- .../interfaces/IPolynomExpression.hpp | 2 + include/fintamath/functions/FunctionUtils.hpp | 4 +- include/fintamath/functions/IFunction.hpp | 19 +- include/fintamath/functions/IOperator.hpp | 11 +- include/fintamath/literals/ILiteral.hpp | 15 +- .../literals/constants/IConstant.hpp | 9 +- include/fintamath/numbers/IInteger.hpp | 10 +- include/fintamath/numbers/INumber.hpp | 15 +- src/fintamath/config/ExpressionConfig.cpp | 137 +++++++------- src/fintamath/config/ParserConfig.cpp | 75 ++++---- src/fintamath/expressions/Expression.cpp | 18 +- .../expressions/binary/CompExpression.hpp | 2 + tests/src/core/ParserTests.cpp | 6 +- 19 files changed, 250 insertions(+), 326 deletions(-) diff --git a/include/fintamath/core/IArithmetic.hpp b/include/fintamath/core/IArithmetic.hpp index d002c353e..48dbbe829 100644 --- a/include/fintamath/core/IArithmetic.hpp +++ b/include/fintamath/core/IArithmetic.hpp @@ -6,6 +6,8 @@ namespace fintamath { class IArithmetic : public IMathObject { + using ArithmeticParser = Parser>; + public: friend inline std::unique_ptr operator+(const IArithmetic &lhs, const IArithmetic &rhs) { return lhs.addAbstract(rhs); @@ -32,17 +34,16 @@ class IArithmetic : public IMathObject { } template T> - static void registerType() { - Parser::registerType(getParser()); + static void registerConstructor() { + getParser().registerConstructor(); } - template T> - static void registerType(Parser::Function, const std::string &> &&parserFunc) { - Parser::registerType(getParser(), std::move(parserFunc)); + static void registerConstructor(ArithmeticParser::Constructor constructor) { + getParser().registerConstructor(std::move(constructor)); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -61,13 +62,14 @@ class IArithmetic : public IMathObject { virtual std::unique_ptr negateAbstract() const = 0; private: - static Parser::Vector, const std::string &> &getParser(); + static ArithmeticParser &getParser(); }; template class IArithmeticCRTP : public IArithmetic { #define I_ARITHMETIC_CRTP IArithmeticCRTP #include "fintamath/core/IArithmeticCRTP.hpp" + #undef I_ARITHMETIC_CRTP }; diff --git a/include/fintamath/core/IComparable.hpp b/include/fintamath/core/IComparable.hpp index 60030559a..61a152c40 100644 --- a/include/fintamath/core/IComparable.hpp +++ b/include/fintamath/core/IComparable.hpp @@ -6,18 +6,19 @@ namespace fintamath { class IComparable : public IArithmetic { + using ComparableParser = Parser>; + public: friend inline std::strong_ordering operator<=>(const IComparable &lhs, const IComparable &rhs) { return lhs.compareAbstract(rhs); } - template T> - static void registerType(Parser::Function, const std::string &> &&parserFunc) { - Parser::registerType(getParser(), std::move(parserFunc)); + static void registerConstructor(ComparableParser::Constructor constructor) { + getParser().registerConstructor(std::move(constructor)); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -28,7 +29,7 @@ class IComparable : public IArithmetic { virtual std::strong_ordering compareAbstract(const IComparable &rhs) const = 0; private: - static Parser::Vector, const std::string &> &getParser(); + static ComparableParser &getParser(); }; template diff --git a/include/fintamath/core/IMathObject.hpp b/include/fintamath/core/IMathObject.hpp index a2862f229..93126f7fb 100644 --- a/include/fintamath/core/IMathObject.hpp +++ b/include/fintamath/core/IMathObject.hpp @@ -11,6 +11,8 @@ namespace fintamath { class IMathObject { + using MathObjectParser = Parser>; + public: virtual ~IMathObject() = default; @@ -32,13 +34,12 @@ class IMathObject { return lhs.equalsAbstract(rhs); } - template T> - static void registerType(Parser::Function, const std::string &> &&parserFunc) { - Parser::registerType(getParser(), std::move(parserFunc)); + static void registerConstructor(MathObjectParser::Constructor constructor) { + getParser().registerConstructor(std::move(constructor)); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -49,7 +50,7 @@ class IMathObject { virtual bool equalsAbstract(const IMathObject &rhs) const = 0; private: - static Parser::Vector, const std::string &> &getParser(); + static MathObjectParser &getParser(); }; template diff --git a/include/fintamath/core/Parser.hpp b/include/fintamath/core/Parser.hpp index 886c76f5c..37c64daa7 100644 --- a/include/fintamath/core/Parser.hpp +++ b/include/fintamath/core/Parser.hpp @@ -10,171 +10,86 @@ #include "fintamath/core/Tokenizer.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include + namespace fintamath { +template class Parser final { public: - template - using Function = std::function; - - template - using Comparator = std::function; - - template - using Map = std::unordered_multimap>; - - template - using Vector = std::vector>; - - template - static void add(Map &parserMap) { - Function constructor = [](const Args &...args) { - return std::make_unique(args...); - }; - - static const std::string name = Type().toString(); - parserMap.emplace(name, constructor); + using Validator = std::function; - Tokenizer::registerToken(name); - } + using Constructor = std::function; - template - static void add(Map &parserMap, Function &&parserFunc) { - static const std::string name = Type().toString(); - parserMap.emplace(name, std::move(parserFunc)); - - Tokenizer::registerToken(name); - } + using TypeConstructor = std::function; - template - static void add(Vector &parserVect) { - Function constructor = [](const Args &...args) { - try { - return std::make_unique(args...); - } - catch (const InvalidInputException &) { - return std::unique_ptr(); - } - }; + using ConstructorVector = std::vector; - parserVect.emplace_back(constructor); - } + using ConstructorMap = std::unordered_multimap; - template - static void add(Vector &parserVect, Function &&parserFunc) { - parserVect.emplace_back(std::move(parserFunc)); +public: + Return parse(const std::string &str, Args &&...args) const { + static constexpr auto trueValidator = [](const Return &) { return true; }; + return parse(trueValidator, str, std::forward(args)...); } - template - static Return parse(const Map &parserMap, - const std::string &parsedStr, - const Args &...args) { - - const auto &valuePairs = parserMap.equal_range(parsedStr); + Return parse(const Validator &validator, const std::string &str, Args &&...args) const { + for (const auto &valuePairs = constructorMap.equal_range(str); + const auto &pair : stdv::iota(valuePairs.first, valuePairs.second)) { - for (const auto &pair : stdv::iota(valuePairs.first, valuePairs.second)) { - if (Return value = pair->second(args...)) { + if (Return value = pair->second(std::forward(args)...); value && validator(value)) { return value; } } - return nullptr; - } - - template - requires(sizeof...(Args) > 0) - static Return parse(const Map &parserMap, - const std::string &parsedStr, - Args &&...args) { - - const auto &valuePairs = parserMap.equal_range(parsedStr); - - for (const auto &pair : stdv::iota(valuePairs.first, valuePairs.second)) { - if (Return value = pair->second(std::forward(args)...)) { + for (const auto &constructor : extraConstructors) { + if (Return value = constructor(str, std::forward(args)...); value && validator(value)) { return value; } } - return nullptr; + return Return{}; } - template - static Return parse(const Map &parserMap, - const Comparator &comp, - const std::string &parsedStr, - const Args &...args) { - - const auto &valuePairs = parserMap.equal_range(parsedStr); - - for (const auto &pair : stdv::iota(valuePairs.first, valuePairs.second)) { - if (Return value = pair->second(args...); value && comp(value)) { - return value; - } - } + template + void registerType() { + TypeConstructor constructor = [](Args &&...args) -> Return { + return std::make_unique(std::forward(args)...); + }; - return nullptr; + registerType(std::move(constructor)); } - template - requires(sizeof...(Args) > 0) - static Return parse(const Map &parserMap, - const Comparator &comp, - const std::string &parsedStr, - Args &&...args) { - - const auto &valuePairs = parserMap.equal_range(parsedStr); - - for (const auto &pair : stdv::iota(valuePairs.first, valuePairs.second)) { - if (Return value = pair->second(std::forward(args)...); value && comp(value)) { - return value; - } - } + template + void registerType(TypeConstructor constructor) { + static const std::string name = Type().toString(); + constructorMap.emplace(name, std::move(constructor)); - return nullptr; + Tokenizer::registerToken(name); } - template - static Return parse(const Vector &parserVect, const Args &...args) { - for (const auto &constructor : parserVect) { - if (Return value = constructor(args...)) { - return value; + template + void registerConstructor() { + Constructor constructor = [](const std::string &str, Args &&...args) -> Return { + try { + return std::make_unique(str, std::forward(args)...); } - } - - return nullptr; - } - - template - requires(sizeof...(Args) > 0) - static Return parse(const Vector &parserVect, Args &&...args) { - for (const auto &constructor : parserVect) { - if (Return value = constructor(std::forward(args)...)) { - return value; + catch (const InvalidInputException &) { + return std::unique_ptr(); } - } - - return nullptr; - } + }; - template - static void registerType(Map &parserMap) { - add(parserMap); + registerConstructor(std::move(constructor)); } - template - static void registerType(Map &parserMap, const Function &parserFunc) { - add(parserMap, parserFunc); + void registerConstructor(Constructor constructor) { + extraConstructors.emplace_back(std::move(constructor)); } - template - static void registerType(Vector &parserVect) { - add(parserVect); - } +private: + ConstructorMap constructorMap; - template - static void registerType(Vector &parserVect, Function &&parserFunc) { - add(parserVect, std::move(parserFunc)); - } + ConstructorVector extraConstructors; }; } diff --git a/include/fintamath/expressions/Expression.hpp b/include/fintamath/expressions/Expression.hpp index 4f33fee9b..1bc897674 100644 --- a/include/fintamath/expressions/Expression.hpp +++ b/include/fintamath/expressions/Expression.hpp @@ -2,7 +2,6 @@ #include -#include "fintamath/core/IArithmetic.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Real.hpp" @@ -27,6 +26,10 @@ using TermVector = std::vector>; using OperandStack = std::stack>; class Expression : public IExpressionCRTP { + using TermParser = Parser>; + using ExpressionParser = Parser, ArgumentPtrVector &&>; + using ExpressionMaker = std::function(ArgumentPtrVector &&)>; + public: Expression(); @@ -53,12 +56,12 @@ class Expression : public IExpressionCRTP { void setVariable(const Variable &var, const Expression &val); - static void registerTermMaker(Parser::Function, const Token &> &&maker) { - Parser::add(getTermMakers(), std::move(maker)); + static void registerTermParser(TermParser::Constructor constructor) { + getTermParser().registerConstructor(std::move(constructor)); } template - static void registerFunctionExpressionMaker(auto &&maker); + static void registerFunctionExpressionMaker(ExpressionMaker maker); static MathObjectType getTypeStatic() { return MathObjectType::Expression; @@ -114,15 +117,13 @@ class Expression : public IExpressionCRTP { static ArgumentPtr compress(const ArgumentPtr &child); - friend std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector &&args); - - friend std::unique_ptr makeExpr(const IFunction &func, const ArgumentPtrVector &args); + friend std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector args); friend std::unique_ptr parseFintamath(const std::string &str); - static Parser::Vector, const Token &> &getTermMakers(); + static TermParser &getTermParser(); - static Parser::Map, ArgumentPtrVector &&> &getExpressionMakers(); + static ExpressionParser &getExpressionParser(); private: mutable ArgumentPtr child; @@ -159,9 +160,9 @@ Expression operator/(const Expression &lhs, const Variable &rhs); Expression operator/(const Variable &lhs, const Expression &rhs); template -inline void Expression::registerFunctionExpressionMaker(auto &&maker) { - Parser::Function, ArgumentPtrVector &&> constructor = - [maker = std::forward(maker)](ArgumentPtrVector &&args) { +void Expression::registerFunctionExpressionMaker(ExpressionMaker maker) { + ExpressionParser::TypeConstructor constructor = + [maker = std::forward(maker)](ArgumentPtrVector &&args) { static const IFunction::Type type = Function().getFunctionType(); std::unique_ptr res; @@ -169,12 +170,12 @@ inline void Expression::registerFunctionExpressionMaker(auto &&maker) { res = maker(std::move(args)); } else if constexpr (isPolynomial) { - if (size_t(type) <= args.size()) { + if (static_cast(type) <= args.size()) { res = maker(std::move(args)); } } else { - if (size_t(type) == args.size()) { + if (static_cast(type) == args.size()) { res = maker(std::move(args)); } } @@ -182,7 +183,7 @@ inline void Expression::registerFunctionExpressionMaker(auto &&maker) { return res; }; - Parser::add(getExpressionMakers(), std::move(constructor)); + getExpressionParser().registerType(std::move(constructor)); } } diff --git a/include/fintamath/expressions/IExpression.hpp b/include/fintamath/expressions/IExpression.hpp index adbaa2378..2200a085c 100644 --- a/include/fintamath/expressions/IExpression.hpp +++ b/include/fintamath/expressions/IExpression.hpp @@ -2,12 +2,13 @@ #include "fintamath/core/IMathObject.hpp" #include "fintamath/functions/IFunction.hpp" -#include "fintamath/functions/IOperator.hpp" #include "fintamath/literals/Variable.hpp" namespace fintamath { class IExpression : public IArithmetic { + using ExpressionParser = Parser>; + public: virtual const std::shared_ptr &getFunction() const = 0; @@ -24,12 +25,12 @@ class IExpression : public IArithmetic { virtual std::shared_ptr getOutputFunction() const; template T> - static void registerType() { - Parser::registerType(getParser()); + static void registerConstructor() { + getParser().registerConstructor(); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -67,7 +68,7 @@ class IExpression : public IArithmetic { static ArgumentPtrVector convertToApproximatedNumbers(const ArgumentPtrVector &args); private: - static Parser::Vector, const std::string &> &getParser(); + static ExpressionParser &getParser(); }; template diff --git a/include/fintamath/expressions/interfaces/IPolynomExpression.hpp b/include/fintamath/expressions/interfaces/IPolynomExpression.hpp index b3f2ae137..4a9f025f2 100644 --- a/include/fintamath/expressions/interfaces/IPolynomExpression.hpp +++ b/include/fintamath/expressions/interfaces/IPolynomExpression.hpp @@ -7,6 +7,8 @@ namespace fintamath { +class IOperator; + class IPolynomExpression : public IExpression { public: explicit IPolynomExpression(const IFunction &inFunc, ArgumentPtrVector args); diff --git a/include/fintamath/functions/FunctionUtils.hpp b/include/fintamath/functions/FunctionUtils.hpp index cf3c573b6..e2740e2ef 100644 --- a/include/fintamath/functions/FunctionUtils.hpp +++ b/include/fintamath/functions/FunctionUtils.hpp @@ -16,9 +16,7 @@ class IFunction; extern bool isExpression(const IMathObject &arg); -extern std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector &&args); - -extern std::unique_ptr makeExpr(const IFunction &func, const ArgumentPtrVector &args); +extern std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector args); extern std::unique_ptr makeExpr(const IFunction &func, const ArgumentRefVector &args); diff --git a/include/fintamath/functions/IFunction.hpp b/include/fintamath/functions/IFunction.hpp index 6bbb060d1..14d4aa369 100644 --- a/include/fintamath/functions/IFunction.hpp +++ b/include/fintamath/functions/IFunction.hpp @@ -14,8 +14,11 @@ template struct IsFunctionTypeAny : std::false_type {}; class IFunction : public IMathObject { + using FunctionOrderMap = std::unordered_map; + using FunctionParser = Parser>; + public: - enum class Type : uint16_t { + enum class Type : uint8_t { None, // 0 arguments Unary, // 1 argument Binary, // 2 arguments @@ -51,17 +54,17 @@ class IFunction : public IMathObject { template T> static void registerType() { - Parser::registerType(getParser()); + getParser().registerType(); getFunctionOrderMutableMap()[T().toString()] = maxFunctionOrder; maxFunctionOrder++; } static std::unique_ptr parse(const std::string &parsedStr, IFunction::Type type = IFunction::Type::Any) { - Parser::Comparator &> comp = [type](const std::unique_ptr &func) { - return type == IFunction::Type::Any || func->getFunctionType() == type; + const auto validator = [type](const std::unique_ptr &func) { + return type == Type::Any || func->getFunctionType() == type; }; - return Parser::parse>(getParser(), comp, parsedStr); + return getParser().parse(validator, parsedStr); } static MathObjectType getTypeStatic() { @@ -71,14 +74,14 @@ class IFunction : public IMathObject { protected: virtual std::unique_ptr callAbstract(const ArgumentRefVector &argVect) const = 0; - static const std::unordered_map &getFunctionOrderMap() { + static const FunctionOrderMap &getFunctionOrderMap() { return getFunctionOrderMutableMap(); } private: - static std::unordered_map &getFunctionOrderMutableMap(); + static FunctionOrderMap &getFunctionOrderMutableMap(); - static Parser::Map> &getParser(); + static FunctionParser &getParser(); static inline size_t maxFunctionOrder = 0; }; diff --git a/include/fintamath/functions/IOperator.hpp b/include/fintamath/functions/IOperator.hpp index 08fc3e305..3597ca052 100644 --- a/include/fintamath/functions/IOperator.hpp +++ b/include/fintamath/functions/IOperator.hpp @@ -5,9 +5,10 @@ namespace fintamath { class IOperator : public IFunction { + using OperatorParser = Parser>; public: - enum class Priority : uint16_t { + enum class Priority : uint8_t { Highest, Exponentiation, // e.g. a ^ b PostfixUnary, // e.g. a! @@ -32,14 +33,14 @@ class IOperator : public IFunction { template T> static void registerType() { IFunction::registerType(); - Parser::registerType(getParser()); + getParser().registerType(); } static std::unique_ptr parse(const std::string &parsedStr, IOperator::Priority priority = IOperator::Priority::Lowest) { - Parser::Comparator &> comp = [priority](const std::unique_ptr &oper) { + const auto validator = [priority](const std::unique_ptr &oper) { return priority == IOperator::Priority::Lowest || oper->getOperatorPriority() == priority; }; - return Parser::parse>(getParser(), comp, parsedStr); + return getParser().parse(validator, parsedStr); } static MathObjectType getTypeStatic() { @@ -47,7 +48,7 @@ class IOperator : public IFunction { } private: - static Parser::Map> &getParser(); + static OperatorParser &getParser(); }; template diff --git a/include/fintamath/literals/ILiteral.hpp b/include/fintamath/literals/ILiteral.hpp index 33e81fb50..6351fd6fa 100644 --- a/include/fintamath/literals/ILiteral.hpp +++ b/include/fintamath/literals/ILiteral.hpp @@ -5,19 +5,20 @@ namespace fintamath { class ILiteral : public IMathObject { + using LiteralParser = Parser>; + public: template T> - static void registerType() { - Parser::registerType(getParser()); + static void registerConstructor() { + getParser().registerConstructor(); } - template T> - static void registerType(Parser::Function, const std::string &> &&parserFunc) { - Parser::registerType(getParser(), std::move(parserFunc)); + static void registerConstructor(LiteralParser::Constructor constructor) { + getParser().registerConstructor(std::move(constructor)); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -25,7 +26,7 @@ class ILiteral : public IMathObject { } private: - static Parser::Vector, const std::string &> &getParser(); + static LiteralParser &getParser(); }; template diff --git a/include/fintamath/literals/constants/IConstant.hpp b/include/fintamath/literals/constants/IConstant.hpp index 81437d873..679f3a843 100644 --- a/include/fintamath/literals/constants/IConstant.hpp +++ b/include/fintamath/literals/constants/IConstant.hpp @@ -5,6 +5,8 @@ namespace fintamath { class IConstant : public ILiteral { + using ConstantParser = Parser>; + public: virtual MathObjectType getReturnType() const = 0; @@ -14,11 +16,11 @@ class IConstant : public ILiteral { template T> static void registerType() { - Parser::registerType(getParser()); + getParser().registerType(); } static std::unique_ptr parse(const std::string &parsedStr) { - return Parser::parse>(getParser(), parsedStr); + return getParser().parse(parsedStr); } static MathObjectType getTypeStatic() { @@ -29,13 +31,14 @@ class IConstant : public ILiteral { virtual std::unique_ptr call() const = 0; private: - static Parser::Map> &getParser(); + static ConstantParser &getParser(); }; template class IConstantCRTP : public IConstant { #define I_CONSTANT_CRTP IConstantCRTP #include "fintamath/literals/constants/IConstantCRTP.hpp" + #undef I_CONSTANT_CRTP }; diff --git a/include/fintamath/numbers/IInteger.hpp b/include/fintamath/numbers/IInteger.hpp index 9ae862289..723b29598 100644 --- a/include/fintamath/numbers/IInteger.hpp +++ b/include/fintamath/numbers/IInteger.hpp @@ -5,6 +5,8 @@ namespace fintamath { class IInteger : public INumber { + using IntegerParser = Parser>; + public: friend inline std::unique_ptr operator%(const IInteger &lhs, const IInteger &rhs) { return lhs.modAbstract(rhs); @@ -55,12 +57,12 @@ class IInteger : public INumber { } template T> - static void registerType() { - Parser::registerType(getParser()); + static void registerConstructor() { + getParser().registerConstructor(); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -87,7 +89,7 @@ class IInteger : public INumber { virtual IInteger &decreaseAbstract() = 0; private: - static Parser::Vector, const std::string &> &getParser(); + static IntegerParser &getParser(); }; template diff --git a/include/fintamath/numbers/INumber.hpp b/include/fintamath/numbers/INumber.hpp index d211b582f..393ad97e8 100644 --- a/include/fintamath/numbers/INumber.hpp +++ b/include/fintamath/numbers/INumber.hpp @@ -6,6 +6,8 @@ namespace fintamath { class INumber : public IComparable { + using NumberParser = Parser>; + public: virtual bool isPrecise() const { return true; @@ -16,17 +18,16 @@ class INumber : public IComparable { } template T> - static void registerType() { - Parser::registerType(getParser()); + static void registerConstructor() { + getParser().registerConstructor(); } - template T> - static void registerType(Parser::Function, const std::string &> &&parserFunc) { - Parser::registerType(getParser(), std::move(parserFunc)); + static void registerConstructor(NumberParser::Constructor constructor) { + getParser().registerConstructor(std::move(constructor)); } static std::unique_ptr parse(const std::string &str) { - return Parser::parse(getParser(), str); + return getParser().parse(str); } static MathObjectType getTypeStatic() { @@ -34,7 +35,7 @@ class INumber : public IComparable { } private: - static Parser::Vector, const std::string &> &getParser(); + static NumberParser &getParser(); }; inline std::unique_ptr operator+(const INumber &lhs, const INumber &rhs) { diff --git a/src/fintamath/config/ExpressionConfig.cpp b/src/fintamath/config/ExpressionConfig.cpp index 02bd5d968..02ce84cee 100644 --- a/src/fintamath/config/ExpressionConfig.cpp +++ b/src/fintamath/config/ExpressionConfig.cpp @@ -87,17 +87,16 @@ #include "fintamath/functions/trigonometry/Sin.hpp" #include "fintamath/functions/trigonometry/Tan.hpp" #include "fintamath/literals/constants/E.hpp" -#include "fintamath/literals/constants/Pi.hpp" namespace fintamath { -Parser::Vector, const Token &> &Expression::getTermMakers() { - static Parser::Vector, const Token &> maker; - return maker; +Expression::TermParser &Expression::getTermParser() { + static TermParser parser; + return parser; } -Parser::Map, ArgumentPtrVector &&> &Expression::getExpressionMakers() { - static Parser::Map, ArgumentPtrVector &&> maker; +Parser, ArgumentPtrVector &&> &Expression::getExpressionParser() { + static Parser, ArgumentPtrVector &&> maker; return maker; } @@ -110,7 +109,7 @@ namespace { struct ExpressionConfig final { ExpressionConfig() { // TODO! move to other file - static const unsigned defaultPrecision = 80; + constexpr unsigned defaultPrecision = 80; Real::setPrecision(defaultPrecision); registerTermsMakers(); @@ -118,7 +117,7 @@ struct ExpressionConfig final { } static void registerTermsMakers() { - Expression::registerTermMaker([](const Token &token) { + Expression::registerTermParser([](const Token &token) { if (auto arg = IFunction::parse(token, IFunction::Type::Binary)) { return std::make_unique(token, std::move(arg)); } @@ -130,7 +129,7 @@ struct ExpressionConfig final { return std::unique_ptr(); }); - Expression::registerTermMaker([](const Token &token) { + Expression::registerTermParser([](const Token &token) { if (auto arg = ILiteral::parse(token)) { return std::make_unique(token, std::move(arg)); } @@ -138,7 +137,7 @@ struct ExpressionConfig final { return std::unique_ptr(); }); - Expression::registerTermMaker([](const Token &token) { + Expression::registerTermParser([](const Token &token) { if (auto arg = INumber::parse(token)) { return std::make_unique(token, std::move(arg)); } @@ -152,7 +151,7 @@ struct ExpressionConfig final { return AddExpression(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -165,7 +164,7 @@ struct ExpressionConfig final { return MulExpression(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker
([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker
([](const ArgumentPtrVector &args) { return DivExpression(args.front(), args.back()).clone(); }); @@ -173,7 +172,7 @@ struct ExpressionConfig final { return divExpr(std::move(args)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr integ = args[0]; ArgumentPtr numer = args[1]; ArgumentPtr denom = args[2]; @@ -189,7 +188,7 @@ struct ExpressionConfig final { return OrExpression(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return PowExpression(args.front(), args.back()).clone(); }); @@ -197,31 +196,31 @@ struct ExpressionConfig final { return powExpr(std::move(args)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(Eqv(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(Neqv(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(Less(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(More(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(LessEqv(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return CompExpression(MoreEqv(), args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const Index func; ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -233,7 +232,7 @@ struct ExpressionConfig final { return Expression(func(*lhs, *rhs)).clone(); // TODO: looks weird }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -242,7 +241,7 @@ struct ExpressionConfig final { return orExpr(notLhs, rhs); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -255,7 +254,7 @@ struct ExpressionConfig final { return orExpr(lhsAndRhs, notLhsAndNotRhs); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -268,75 +267,75 @@ struct ExpressionConfig final { return orExpr(notLhsAndRhs, lhsAndNotRhs); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr negOne = Integer(-1).clone(); return mulExpr(negOne, args.front()); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return args.front()->clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return NotExpression(args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return DerivativeExpression(args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return IntegralExpression(args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return LogExpression(args.front(), args.back()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr logBase = E().clone(); return logExpr(logBase, args.front()); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr logBase = Integer(2).clone(); return logExpr(logBase, args.front()); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr logBase = Integer(10).clone(); return logExpr(logBase, args.front()); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr powBase = E().clone(); return powExpr(powBase, args.front()); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr percentValue = Integer(100).clone(); return divExpr(args.front(), percentValue); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return MinMaxExpression(Min(), std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return MinMaxExpression(Max(), std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr powRate = Integer(2).clone(); return powExpr(args.front(), powRate); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr powRate = Rational(1, 2).clone(); return powExpr(args.front(), powRate); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { ArgumentPtr lhs = args.front(); ArgumentPtr rhs = args.back(); @@ -350,120 +349,120 @@ struct ExpressionConfig final { return powExpr(lhs, invRhs); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Sin(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Cos(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Tan(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Cot(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Sec(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return TrigExpression(Csc(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Asin(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Acos(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Atan(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Acot(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Asec(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvTrigExpression(Acsc(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Sinh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Cosh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Tanh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Coth(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Sech(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return HyperbExpression(Csch(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Asinh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Acosh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Atanh(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Acoth(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Asech(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return InvHyperbExpression(Acsch(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { static const ArgumentPtr deg1 = Deg()(Integer(1)); return mulExpr(args.front(), deg1); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return FloorCeilExpression(Floor(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return FloorCeilExpression(Ceil(), args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return AbsExpression(args.front()).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { return SignExpression(args.front()).clone(); }); } diff --git a/src/fintamath/config/ParserConfig.cpp b/src/fintamath/config/ParserConfig.cpp index 361014576..65c1260f2 100644 --- a/src/fintamath/config/ParserConfig.cpp +++ b/src/fintamath/config/ParserConfig.cpp @@ -1,7 +1,7 @@ -#include "fintamath/core/Parser.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/Parser.hpp" #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/IFunction.hpp" @@ -91,7 +91,6 @@ #include "fintamath/numbers/INumber.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" -#include "fintamath/numbers/Real.hpp" namespace fintamath { @@ -100,58 +99,58 @@ TokenVector &Tokenizer::getRegisteredTokens() { return registeredTokens; } -Parser::Vector, const std::string &> &IMathObject::getParser() { - static Parser::Vector, const std::string &> parser; +IMathObject::MathObjectParser &IMathObject::getParser() { + static MathObjectParser parser; return parser; } -Parser::Vector, const std::string &> &IArithmetic::getParser() { - static Parser::Vector, const std::string &> parser; +IArithmetic::ArithmeticParser &IArithmetic::getParser() { + static ArithmeticParser parser; return parser; } -Parser::Vector, const std::string &> &IComparable::getParser() { - static Parser::Vector, const std::string &> parser; +IComparable::ComparableParser &IComparable::getParser() { + static ComparableParser parser; return parser; } -Parser::Vector, const std::string &> &INumber::getParser() { - static Parser::Vector, const std::string &> parser; +INumber::NumberParser &INumber::getParser() { + static NumberParser parser; return parser; } -Parser::Vector, const std::string &> &IInteger::getParser() { - static Parser::Vector, const std::string &> parser; +IInteger::IntegerParser &IInteger::getParser() { + static IntegerParser parser; return parser; } -Parser::Vector, const std::string &> &ILiteral::getParser() { - static Parser::Vector, const std::string &> parser; +ILiteral::LiteralParser &ILiteral::getParser() { + static LiteralParser parser; return parser; } -Parser::Map> &IConstant::getParser() { - static Parser::Map> parser; +IConstant::ConstantParser &IConstant::getParser() { + static ConstantParser parser; return parser; } -std::unordered_map &IFunction::getFunctionOrderMutableMap() { - static std::unordered_map orderMap; +IFunction::FunctionOrderMap &IFunction::getFunctionOrderMutableMap() { + static FunctionOrderMap orderMap; return orderMap; } -Parser::Map> &IFunction::getParser() { - static Parser::Map> parser; +IFunction::FunctionParser &IFunction::getParser() { + static FunctionParser parser; return parser; } -Parser::Map> &IOperator::getParser() { - static Parser::Map> parser; +IOperator::OperatorParser &IOperator::getParser() { + static OperatorParser parser; return parser; } -Parser::Vector, const std::string &> &IExpression::getParser() { - static Parser::Vector, const std::string &> parser; +IExpression::ExpressionParser &IExpression::getParser() { + static ExpressionParser parser; return parser; } @@ -163,25 +162,23 @@ namespace { struct ParserConfig final { ParserConfig() { - IMathObject::registerType(&ILiteral::parse); - IMathObject::registerType([](const std::string &str) { - return IFunction::parse(str); - }); - IMathObject::registerType(&IArithmetic::parse); + IMathObject::registerConstructor(&ILiteral::parse); + IMathObject::registerConstructor([](const std::string &str) { return IFunction::parse(str); }); + IMathObject::registerConstructor(&IArithmetic::parse); - IArithmetic::registerType(&IComparable::parse); - IArithmetic::registerType(); + IArithmetic::registerConstructor(&IComparable::parse); + IArithmetic::registerConstructor(); - IComparable::registerType(&INumber::parse); + IComparable::registerConstructor(&INumber::parse); - INumber::registerType(&IInteger::parse); - INumber::registerType(); + INumber::registerConstructor(&IInteger::parse); + INumber::registerConstructor(); - IInteger::registerType(); + IInteger::registerConstructor(); - ILiteral::registerType(&IConstant::parse); - ILiteral::registerType(); - ILiteral::registerType(); + ILiteral::registerConstructor(&IConstant::parse); + ILiteral::registerConstructor(); + ILiteral::registerConstructor(); IConstant::registerType(); IConstant::registerType(); @@ -263,7 +260,7 @@ struct ParserConfig final { IOperator::registerType(); IOperator::registerType(); - IExpression::registerType(); + IExpression::registerConstructor(); } }; diff --git a/src/fintamath/expressions/Expression.cpp b/src/fintamath/expressions/Expression.cpp index 085f581a6..ba6eeea4d 100644 --- a/src/fintamath/expressions/Expression.cpp +++ b/src/fintamath/expressions/Expression.cpp @@ -174,7 +174,7 @@ TermVector Expression::tokensToTerms(const TokenVector &tokens) { TermVector terms(tokens.size()); for (const auto i : stdv::iota(0U, terms.size())) { - if (auto term = Parser::parse(getTermMakers(), (tokens[i]))) { + if (auto term = getTermParser().parse(tokens[i])) { terms[i] = std::move(term); } else { @@ -435,21 +435,15 @@ ArgumentPtr Expression::compress(const ArgumentPtr &child) { return child; } -std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector &&args) { - ArgumentPtrVector compressedArgs = std::move(args); - stdr::transform(compressedArgs, compressedArgs.begin(), &Expression::compress); +std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector args) { + stdr::transform(args, args.begin(), &Expression::compress); + Expression::validateFunctionArgs(func, args); - Expression::validateFunctionArgs(func, compressedArgs); - - if (auto expr = Parser::parse(Expression::getExpressionMakers(), func.toString(), std::move(compressedArgs))) { + if (auto expr = Expression::getExpressionParser().parse(func.toString(), std::move(args))) { return expr; } - return FunctionExpression(func, compressedArgs).clone(); -} - -std::unique_ptr makeExpr(const IFunction &func, const ArgumentPtrVector &args) { - return makeExpr(func, ArgumentPtrVector(args)); + return FunctionExpression(func, std::move(args)).clone(); } std::unique_ptr makeExpr(const IFunction &func, const ArgumentRefVector &args) { diff --git a/src/fintamath/expressions/binary/CompExpression.hpp b/src/fintamath/expressions/binary/CompExpression.hpp index 7d5eb3a95..7f5fa09ad 100644 --- a/src/fintamath/expressions/binary/CompExpression.hpp +++ b/src/fintamath/expressions/binary/CompExpression.hpp @@ -4,6 +4,8 @@ namespace fintamath { +class IOperator; + class CompExpression final : public IBinaryExpressionCRTP { public: CompExpression(const IOperator &inOper, ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); diff --git a/tests/src/core/ParserTests.cpp b/tests/src/core/ParserTests.cpp index 2d2ce7b39..626c638d8 100644 --- a/tests/src/core/ParserTests.cpp +++ b/tests/src/core/ParserTests.cpp @@ -4,14 +4,14 @@ using namespace fintamath; -TEST(ParserTests, addTest) { +TEST(ParserTests, parseTest) { // TODO: implement } -TEST(ParserTests, parseTest) { +TEST(ParserTests, registerTypeTest) { // TODO: implement } -TEST(ParserTests, registerTypeTest) { +TEST(ParserTests, registerConstructorTest) { // TODO: implement }