lark icon indicating copy to clipboard operation
lark copied to clipboard

Interegular integration, allowing checks for intersections between regexes.

Open MegaIng opened this issue 5 years ago • 2 comments

Fixes #76.

This is a first attempt.

You can install interegular via pip: pip install interegular. If you want, you can also take a look at the interegular source code.

MegaIng avatar Oct 07 '20 19:10 MegaIng

A few notes:

  1. Basically, this is the real functional code (which resides in interregular):
        for a, b in combinations(keys, 2):
            if not self.isdisjoint(a, b):
                yield a, b

I see you already cache the FSMs, so all that's required to prevent duplicate work is to call memoized_disjoint instead.

  1. Why does lark have to call mark and is_marked? Seems unnecessary. If you want to avoid duplicate warnings, just keep a set.

  2. Why compare regexps (expensive) and only afterwards check a.priority == b.priority? This should be the first test, otherwise comparing them with interregular is pointless.

  3. skip_validation means you never use the comparator. So why even create it in the first place?

erezsh avatar Oct 09 '20 07:10 erezsh

P.S. re point 3, you can do something like classify(regexps, lambda r: r.priority) to get all the subgroups that should be tested together.

erezsh avatar Oct 10 '20 16:10 erezsh

Well, this is now a messed up git history.

MegaIng avatar Mar 02 '23 16:03 MegaIng