#ifndef __POLY_POLY_H__ #define __POLY_POLY_H__ #include "SymTable.h" #include #include #include class CPoly { public: CPoly(); virtual ~CPoly(); int Analyze(const char * pszStr = NULL); double Eval(); void SetStr(const std::string & str); int SetVar(const std::string & strName, double dVar); double GetVar(const std::string & strName); void Clear(); protected: int my_irandom(double start, double end); double my_frandom(double start, double end); void init(); int insert(const std::string & s, int tok); int find(const std::string & s); void emit(int t,int tval); void match(int t); void expo(); void factor(); void term(); int lexan(); void error(); void expr(); int iToken; double iNumToken; int iLookAhead; int iErrorPos; bool ErrorOccur; unsigned int uiLookPos; // NOTE: list is slight faster than vector, why?! std::vector tokenBase; std::vector numBase; std::vector lSymbol; std::vector SymbolIndex; int STSize; std::string strData; }; #endif