bug-bison
[Top][All Lists]
Advanced

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

Re: Bison C++ mid-rule value lost with variants


From: Hans Åberg
Subject: Re: Bison C++ mid-rule value lost with variants
Date: Sun, 17 Jun 2018 18:46:47 +0200

> On 17 Jun 2018, at 16:02, Akim Demaille <address@hidden> wrote:

> Or go for a lighter syntax...

Indeed.

> expr:
>  NUM
> | expr <int>{ $$ = 42; } '+' NUM { std::cout << $2 << '\n'; };

> Personally, I prefer the prefix forms, but they don’t blend
> nicely with named references:
> 
> expr:
>  NUM
> | expr <int>{ $$ = 42; }[val] '+' NUM { std::cout << $val << '\n'; };

This is fact consistent with the order in the other declarations: <type> 
<variable> <name>.

> I wish we had chosen a prefix syntax for named references, say
> 
> expr:
>  NUM
> | expr val={ $<int>$ = 42; } '+' NUM { std::cout << $<int>val << '\n'; };

If the type is in the variable, it implies a runtime variant cast, which one 
might want for some reason.

(Just some bystander inputs.)





reply via email to

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