How to access class member from bison action

Posted by yodhevauhe on Stack Overflow See other posts from Stack Overflow or by yodhevauhe
Published on 2010-12-24T17:52:02Z Indexed on 2010/12/24 17:54 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

I am calling yyparse from a member function. How to access the member variables/function from the bison action.

I am currently doing as

%{
#include "myclass.h"
#include "parse.tab.hh"

MyClass *ptr=NULL;

void MyClass::evaluate(string expression)
    {
    ptr=this;
    yy_scan_string(expression.c_str());               
    yyparse();
    }

%}

%%
EXPR :  EXPR PLUS EXPR {
       $$ = ptr->memberFunction("+",$1,$3);
        }

© Stack Overflow or respective owner

Related posts about c++

Related posts about flex