Hi everyone,
I am a beginner of Flex and Bison and just know litter about them ,I need
your help.
I want to encapsulate a C++ class ,which can works like a calculator,its
structure seems like this:
Class Calc
{
public:
Calc(){};
~Calc(){};
void setExpr(char *cExpr){this->cExpr = cExpr;}
char* getExpr(){ return this->cExpr;}
double getResult(){return this->result;}
void lexParse(){ yylex(this->cExpr);...}
//in yylex, result will be evaluated...
....
private:
char *cExpr;
double result;
};
If somebody wants to use my Calc, he just use it like this:
Calc calcer;
calcer.setExpr("1+2*3");//the expression to calculate
calcer.lexParse();
double dRet = calcer.getResult();//the result of the expression
As you know ,my calculator's core function in lexParse(), in which I want
to use Flex & Bison, I have install Bison2.3 on my HP-Unix OS and I have
view the bison manual and its example of calc++,but I find it is not as
easy as my calculator in use.
There are more wonders on my calculator' structure than its functions(I
just take it as an example ,even though it can only calculate "1+1").
In an other word, Can yylex ,yyparse() be encapsulated in a C++ Class ?
Anybody 's any help is appreciated very much!
_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison