lark
lark copied to clipboard
Interegular integration, allowing checks for intersections between regexes.
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.
A few notes:
- 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.
-
Why does lark have to call
markandis_marked? Seems unnecessary. If you want to avoid duplicate warnings, just keep a set. -
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. -
skip_validationmeans you never use the comparator. So why even create it in the first place?
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.
Well, this is now a messed up git history.