libfsm icon indicating copy to clipboard operation
libfsm copied to clipboard

Deduplication of alts does not preserve capture groups

Open hvdijk opened this issue 5 years ago • 2 comments

$ libfsm/build/bin/re -p -rpcre -lpcre '(foo)|(foo)'
(foo)
$ libfsm/build/bin/re -p -rpcre -lpcre '(foo)|(bar)'
(bar)|(foo)

In general, deduplicating alts is a good simple optimisation to speed up the generation of an FSM, but for regexes containing capture groups, the optimisation is not valid.

hvdijk avatar Oct 10 '20 19:10 hvdijk

There's also reordering, and I suppose we either refrain from doing that, or we error about it as an unsupported situation.

katef avatar Oct 10 '20 19:10 katef

This has definitely been addressed in my capture branch.

silentbicycle avatar Jun 12 '23 17:06 silentbicycle