bug-bison
[Top][All Lists]
Advanced

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

Re: C++ variants


From: Hans Aberg
Subject: Re: C++ variants
Date: Mon, 19 Jan 2015 11:20:23 +0100

> On 19 Jan 2015, at 09:01, Akim Demaille <address@hidden> wrote:
> 
> 
>> 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.

I guess so. What is the idea of the Bison static type system here? 





reply via email to

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