This kind of grammar definition does not alter the semantics of the internal attribute as it's unused_type in the first place. Therefore, there's no reason that we must inhibit the rule parser's attribute handling even when semantic action is attached.
constexpr auto some_rule_grammar_def =
lit("prefix").on_match([](auto&& ctx) {
if (x4::get<some_local_variable>(ctx) == 42) {
do_something();
return true;
}
return false;
}) >>
body_parser
;
Fundamentally, the code above shall match the semantics below:
constexpr auto some_rule_grammar_def =
eps([](auto&& ctx) {
if (x4::get<some_local_variable>(ctx) == 42) {
do_something();
return true;
}
return false;
}) >>
body_parser
;
Workaround
We can currently use x4::as<x4::unused_type>(...) to explicitly re-enable the inhibited attribute. However it's actually a hack (which I introduced for some good reason) when I implemented x4::as, so it's solely a workaround and should not be the desired way of expressing it in application code.
constexpr auto some_rule_grammar_def =
as<unused_type>(lit("prefix").on_match([](auto&& ctx) { // <----- as<unused_type>(...) added
if (x4::get<some_local_variable>(ctx) == 42) {
do_something();
return true;
}
return false;
})) >>
body_parser
;
Additional info
Related: #100
This kind of grammar definition does not alter the semantics of the internal attribute as it's
unused_typein the first place. Therefore, there's no reason that we must inhibit the rule parser's attribute handling even when semantic action is attached.Fundamentally, the code above shall match the semantics below:
Workaround
We can currently use
x4::as<x4::unused_type>(...)to explicitly re-enable the inhibited attribute. However it's actually a hack (which I introduced for some good reason) when I implementedx4::as, so it's solely a workaround and should not be the desired way of expressing it in application code.Additional info
Related: #100