From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/formula.h | 77 ----------------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/formula.h (limited to 'src/formula.h') diff --git a/src/formula.h b/src/formula.h deleted file mode 100644 index 939eb09..0000000 --- a/src/formula.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef FORMULA_H -#define FORMULA_H - -#include - -#include -#include -#include "sbuffer.h" - -#include "exceptionbase.h" -#include "hash.h" - -subExceptionDecl( ParseException ); - -/** - * Implements a very simple formula parser that allows use of variables and - * custom functions. This is based on a simple calculator-type parser that - * executes as it processes, accounting for operator precedence and grouping. - */ -class Formula -{ -public: - Formula(); - virtual ~Formula(); - - double run( char *sFormula ); - - typedef Hash varHash; - varHash hVars; - - typedef struct Func - { - double operator()( double x ) - { - return 0.0; - } - } Func; - - typedef Hash funcHash; - funcHash hFunc; - - typedef struct FuncSin : Func - { - double operator()( double x ) - { - return sin( x ); - } - } FuncSin; - -private: - enum - { - symEOS, - symAdd, - symSubtract, - symMultiply, - symDivide, - symOpenParen, - symCloseParen, - symNumber, - symVariable, - symExponent, - symModulus - }; - - typedef uint8_t symType; - - std::stack sOper; - std::stack sValue; - -private: - symType getPrec( symType nOper ); - symType nextToken( char **sBuf ); - void reduce( bool bCloseParen = false ); -}; - -#endif -- cgit v1.2.3