bug-bison
[Top][All Lists]
Advanced

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

Re: Dynamic token kinds


From: Frank Heckenbach
Subject: Re: Dynamic token kinds
Date: Fri, 30 Nov 2018 00:40:06 +0100

Hans Åberg wrote:

> > Sure, though for my taste "unsafe" sounds a bit harsh, perhaps
> > "unchecked"? If you put in the next release, I'll change my code to
> > use it.
> 
> It seems pretty standard to have lookup tokens with different
> syntactic behavior, for example when they are declared of
> different type in a language. So it is worrisome that the typed
> parser deems the use unsafe.

What is potentially unsafe is that the actual type may not match the
declared type in the grammar. With std::variant, a mismatch would
cause an exception to be thrown. With Bison's static variant, a
mismatch might lead to UB.

So perhaps this function could actually do a type check (which
probably requires another auto-generated switch) and also throw or
(if this is not desired) call std::terminate or so on mismatch,
Akim?

Cheers,
Frank



reply via email to

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