Re: Problems with alternative in X3
Joel de Guzman <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On 24/03/2016 11:19 PM, Lee Clagett wrote: > 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. Is this related to this ticket: https://svn.boost.org/trac/boost/ticket/12094 ? Cheers, -- Joel de Guzman http://www.ciere.com http://boost-spirit.com http://www.cycfi.com/ ------------------------------------------------------------------------------ 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