Closed mosel00 closed 3 years ago
Thanks for reporting! This has to do with a current limitation of optionals, where they refuse to consume elements that also match the next element in sequence. Before the underscore, the rule is evaluated right to left, so the next element after b?
is b
. Since anything that b?
could consume also matches b
, this optional will never consume anything.
I'm planning to implement proper backtracking at some point to make this easier on the user, and the more complaints I get about it, the higher a priority it will be!
For now, there are a couple possible workarounds, depending on the details that you've taken out to create the minimal reproducible example.
You can use parentheses to group the b
with the previous element:
label:
a => c / (a b) b? _
Now there's no overlap between what b?
can match and what the next element, (a b)
, can match.
Or you can switch the order of the b
and b?
:
label:
a => c / a b? b _
Again, this removes the overlap with the next element, which is now a
.
Hope this helps!
Minimal reproducible example:
Input:
Output
Bug:
abba
should get changed toabbc
, but instead is unaffected by the change.