The ability to use | for regex-style alternation within groups would be nice. Probably can use a modified version of match_balance to find the end of the group, then match until encountering | or ). On success, make a recursive call to match beginning at the end of the group. If that returns success, pass it up the chain, else on NULL backtrack to the start of the group in the source string and attempt matching in the next alternative.
The major problem will be correctly counting capture groups, including capture groups passed over in unused alternatives. Also, need to handle groups that don't participate in the match (return nils in match table, but how to handle gsub() and :expand()?).
The ability to use
|for regex-style alternation within groups would be nice. Probably can use a modified version ofmatch_balanceto find the end of the group, then match until encountering|or). On success, make a recursive call tomatchbeginning at the end of the group. If that returns success, pass it up the chain, else onNULLbacktrack to the start of the group in the source string and attempt matching in the next alternative.The major problem will be correctly counting capture groups, including capture groups passed over in unused alternatives. Also, need to handle groups that don't participate in the match (return
nils in match table, but how to handlegsub()and:expand()?).