> Le 18 janv. 2015 à 23:10, Hans Aberg <haber...@telia.com> a écrit : > > Bison C++ variants do not save the type, however, if one wants to put data in > a lookup table or a return type, it may be needed. In the calc++ example .yy > file, one might have types say bool b, integer z, and rational r (using GMP): > assignment: > "identifier" ":=“ b-exp { driver.variables[$1] = $3; }; > "identifier" ":=“ z-exp { driver.variables[$1] = $3; }; > "identifier" ":=“ q-exp { driver.variables[$1] = $3; }; > and similarly for > unit: assignments exp { driver.result = $2; }; > > Do you have an example of that? - Before, I used a polymorphic type storing a > pointer, but the idea is to avoid that in the case the parser is statically > typed.
Hi Hans, I'm not sure I understand what you mean here. Since you store different types (b-exp, z-exp) in a single structure (driver.variables), you already certainly have support for polymorphic types.