From 093bda019317a5a66699b35f8b25ab73802f1f1c Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 22 Jan 2017 23:36:54 +0100 Subject: Added infix notation parsing to the function parser. (nw) --- src/lib/netlist/plib/pfunction.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/lib/netlist/plib/pfunction.h') diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h index 2ad32106569..0f4960d4e1c 100644 --- a/src/lib/netlist/plib/pfunction.h +++ b/src/lib/netlist/plib/pfunction.h @@ -16,10 +16,10 @@ namespace plib { //============================================================ - // function evaluation - reverse polish notation + // function evaluation //============================================================ - /*! Class providing support for precompiled rpn expressions + /*! Class providing support for evaluating expressions * */ class pfunction @@ -47,12 +47,26 @@ namespace plib { { } + /*! Compile an expression + * + * @param inputs Vector of input variables, e.g. {"A","B"} + * @param expr infix or postfix expression. default is infix, postrix + * to be prefixed with rpn, e.g. "rpn:A B + 1.3 /" + */ + void compile(const std::vector &inputs, const pstring expr); + /*! Compile a rpn expression * * @param inputs Vector of input variables, e.g. {"A","B"} * @param expr Reverse polish notation expression, e.g. "A B + 1.3 /" */ void compile_postfix(const std::vector &inputs, const pstring expr); + /*! Compile an infix expression + * + * @param inputs Vector of input variables, e.g. {"A","B"} + * @param expr Infix expression, e.g. "(A+B)/1.3" + */ + void compile_infix(const std::vector &inputs, const pstring expr); /*! Evaluate the expression * * @param values for input variables, e.g. {1.1, 2.2} @@ -61,6 +75,10 @@ namespace plib { double evaluate(const std::vector &values); private: + + void compile_postfix(const std::vector &inputs, + const std::vector &cmds, const pstring expr); + std::vector m_precompiled; //!< precompiled expression }; -- cgit v1.2.3