Re: [x3-devel][design]add is_default_parse_rule=true flag to rule_definition::parse

Larry Evans <[email protected]> Sat, 17 Dec 2016 01:45:43 -0600
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <[email protected]>
On 12/16/2016 11:55 AM, Larry Evans wrote:
> In the parse_rhs_main function here:
>
> https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp#L204
>
> there's a flag, is_default_parse_rule, calculated earlier in the
> function.  Why couldn't this flag be passed as an argument instead?
> Then, here:
>
> https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/rule.hpp#L162
>
> it would be passed as false, and the default value of true could be
> added to the rule_definition::parse function here:
>
> https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/x3/nonterminal/rule.hpp#L58
>
> This would be clearer because there would be no need for the calculation
> in the earlier part of parse_rhs_main, and, since it's being passed
> as false when called from the BOOST_SPIRIT_DEFINE macro, the correctness
> of the value would be obvious in this case.
>
> Is there any downside to this?
>
Yes.  Tried this and the default parse_rule static_assert fires
even though it will never be called at runtime :(

Sorry for noise.

-Larry




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot