Re: Attribute ignored in first rule of alternatives

Joel de Guzman <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 06/12/2017 11:41 PM, Søren Enevoldsen wrote:
> Dear Spirit Community,
> 
> I have the following rule:
> 
> auto const bound = rule<Bound>("bound")
>      = (x3::lit("[") >> x3::lit("<=") > uint_ > x3::lit("]"))
>      | (x3::lit("[") >> x3::lit("<") > uint_[bound_dec1] > x3::lit("]"))
>      ;
> 
> Bound is a struct with a uint32_t member. I have a BOOST_ADAPT_STRUCT to ensure Spirit X3 
> can write to it.
> 
> When I parse "[<5]" I get a Bound with the value 4 (bound_dec1] decrements the parsed 
> number by one and stores that. But if I input "[<=5]", I would expect a bound with 5 after 
> all the magic. But I always get a 0. If I add a "no-op" function to the rule, such that 
> the number parsing becomes uint_[bound_dec0] , it parses correctly. But I don't really 
> think that should be necessary. How do I Spirit to not zero out my attribute?

Do you have a minimal cpp file we can try? It seems you are inhibiting attribute
propagation by having a semantic action, but I'm not sure.

Regards,
-- 
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
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.