I have a bison/flex C++ parser that has a class that I wrote as the return type for some of it's rules (defined in the parser file like %type <myClass> expr
). The class instance is then (usually) stored and printed out later. When the class instance is passed from one rule to another it loses all the values of it's members as if it's being instantiated but not fully copied. I have an = operator and a copy constructor defined for the class. I've also tried manually copying in the members like so:
expr: //Returns myClass
atomicexpr { //Also returns myClass
$$ = driver.returnClass($1)
$$.member1 = driver.returnClass($1).member1
$$.member2 = driver.returnClass($1).member2
}
Note that I am using variants instead of unions as demonstrated in the C++ example in the bison manual.
What do I need to do to get the class instantiated properly?