Re: Problems with alternative in X3

Lee Clagett <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <20160324111957.4a64b28c@laptop-m1330>
On Wed, 23 Mar 2016 15:05:52 +0000
Mikael Asplund <[email protected]> wrote:
> Hi!
> 
> I have an issue with alternatives that I don't understand why it's
> happening. I've simplified it even down to just x3::attr():s and I
> still get the problem.
> 
> Example here (code also supplied in attachment):
> 
> http://coliru.stacked-crooked.com/a/bdf4718cdeb2db4d
> 
> Why does the commented out version on line 57 work, and the active
> one on line 58-59 not work? It's an alternative of two exactly equal
> sequences, shouldn't that result in them joining to the attribute
> type as the single sequence?
> 
> Regards,
>    Mikael
> 

SpiritX3 does not collapse when alternative branches are identical.
Instead, X3 requires the attribute after the expect parser to be a
variant type [0]; only `variant<Foo>` is permitted as an attribute.
SpiritV2 would remove the variant type from the expected type if it
held only a single type element, allowing `Foo`, `optional<Foo>`, and
`variant<Foo>` in this situation. Joel, which is the preferred
behavior? I can work on a patch + tests if the SpiritV2 approach should
be taken.

Lee

[0] http://coliru.stacked-crooked.com/a/e92c2c33db69af38

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.