bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ variants


From: Akim Demaille
Subject: Re: C++ variants
Date: Mon, 19 Jan 2015 09:01:35 +0100

> Le 18 janv. 2015 à 23:10, Hans Aberg <address@hidden> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]