Closed bengsparks closed 11 months ago
The documentation isn't entirely clear. The operator+ is for the result of an operator>>
, not just any branch. You want >>
, not +
.
Given a branch rule br
(e.g. dsl::position(dsl::p<name>)
) and an arbitrary rule r
(e.g. dsl::position
):
br >> r
is another branch rule.(br >> r) + r
is another branch rule (equivalent to br >> r + r
).br + r
is not a branch rule.I'll make it more clear.
Many thanks for quick answer!
TL;DR:
+ dsl::position
does not seem to retain branch rule status.I have been tracking locations of rules using
dsl::position
. Parsing something likeident:Hello
can be implemented as:Extracting the start position can be done with the following without losing the branch rule status.
due to
dsl::position(...)
supporting branch rulesExtracting the end position should be done with constexpr branch operator+(branch br, rule auto then), as
dsl::position
by itself counts as a rule, and theoperator+
should therefore retain the branch rule status:However, this last
static_assert
fails. Am I doing something wrong, or is this a bug? How can we best extract end positions?