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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

cppljevans
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?

-regards,
Larry


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

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

cppljevans
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
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel