I am trying to get Handango automatic registration working within my game. Having tried various RPN expression evaluators (needed to process the RPN string required by Handango I cannot get any of them to work, either because they are too simple (but PF likes them) or they are OO code which I don't know how to plug in to PF.
I have an expression evaluator which works fine stand alone. It's based on a class
which is used in the code like this:-
If I cannot get this to work I will just write a function to hard code the calculations needed.
I have an expression evaluator which works fine stand alone. It's based on a class
- Code:
class wzparser
{
// Members
protected:
wzstack<wzoperator*> m_arroperators;
wzarray<wzelement*> m_arrelements;
long m_nLastError;
TCHAR m_cArgumentSeparator;
// Construction
public:
wzparser();
virtual ~wzparser();
// Methods
// compiles a formula into byte-code
BOOL parse(LPSTR szFormula);
// eval a parsed formula (values being passed replace the variable placeholders)
BOOL eval(wzarray<wzvariable*> &arrVariables, wzstring &result);
// Accessors
void setArgumentSeparator(TCHAR c); // used between function arguments. Default is ';'
TCHAR getArgumentSeparator();
long getSize();
wzelement* get(long i); // ith element
long getLastError(); // valid if parse() returns FALSE
void dump(); // output content in the debug console
protected:
void free();
long add(wzelement* );
BOOL isOperator(/*in*/LPSTR* pp, /*out*/wzoperator** ppop);
BOOL isStringLitteral(/*in*/LPSTR pin, /*in*/LPSTR pout);
BOOL evalOperator(long &i, wzstring &result);
};
which is used in the code like this:-
- Code:
wzparser* p = new wzparser();
If I cannot get this to work I will just write a function to hard code the calculations needed.