Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented handling of expressions matching no input #6

Closed

Conversation

pjkundert
Copy link
Contributor

Previously, attempting to take the intersection of regular expressions with
non-overlapping multipliers (eg "aa" & "aaaa") would raise an Exception, instead
of producing a no match regular expression "[]". These (and other no-match)
expressions are now handled.

o Added a lego.multiplier representing 'never', by making the
multiplier.min/.max both 'inf' (bound(None)), a previously unused
configuration. This turns out to require little additional logic, and
actually cleans up some code.
o Handle multiplying an fsm by None to produce null (no match) fsm
o Optimize search for unused state number slightly to ~O(1) vs. O(n)
o Simplified - , while adding handling for never
o Allow representation of {} (never) and {0} (empty string) multipliers,
since they are always reduced
o Intersection of non-overlapping multipliers now produces new 'never'
multiplier, instead of producing invalid (inverted) multiplier Exception
o Prevent elimination of {}, {0} on lego string rendering; should virtually
never occur anyway, due to elimination by reduce()
o Moved bound/multiplier testing to start of unit tests, due to their
foundational nature.
o Added some empty/no-match unit tests
o Expand main.py to allow playing around with more expression variants,
including timing, and an interactive mode for testing input against union,
intersection and concatenation of supplied expression(s).
o Moved the lego.py multiplier tests to original order to minimize merge
o Restored restriction on representing zero/never multipliers in regexes
o Corrected processing of test input vectors in main.py example code

Previously, attempting to take the intersection of regular expressions with
non-overlapping multipliers (eg "aa" & "aaaa") would raise an Exception, instead
of producing a no match regular expression "[]".  These (and other no-match)
expressions are now handled.

o Added a lego.multiplier representing 'never', by making the
  multiplier.min/.max both 'inf' (bound(None)), a previously unused
  configuration.  This turns out to require little additional logic, and
  actually cleans up some code.
o Handle multiplying an fsm by None to produce null (no match) fsm
o Optimize search for unused state number slightly to ~O(1) vs. O(n)
o Simplified <bound> - <bound>, while adding handling for never
o Allow representation of {} (never) and {0} (empty string) multipliers,
  since they are always reduced
o Intersection of non-overlapping multipliers now produces new 'never'
  multiplier, instead of producing invalid (inverted) multiplier Exception
o Prevent elimination of {}, {0} on lego string rendering; should virtually
  never occur anyway, due to elimination by reduce()
o Moved bound/multiplier testing to start of unit tests, due to their
  foundational nature.
o Added some empty/no-match unit tests
o Expand main.py to allow playing around with more expression variants,
  including timing, and an interactive mode for testing input against union,
  intersection and concatenation of supplied expression(s).
o Moved the lego.py multiplier tests to original order to minimize merge
o Restored restriction on representing zero/never multipliers in regexes
o Corrected processing of test input vectors in main.py example code
@qntm
Copy link
Owner

qntm commented May 3, 2013

Hello Perry, I'm sorry I didn't accept your previous pull request earlier, I didn't realise this one had been queued up behind that one for such a long time.

Unfortunately I don't want to accept this pull request. There is a lot of cool other stuff here, but I think your main fix for the "aa & aaaa" defect is much more complicated than it needs to be. I think it's far simpler to make it so that this case is checked for, so that it never arises at all. In the same way that the multiplier.canmultiplyby() method can be used before calling self * other, a multiplier.canintersect() method can be used before calling self & other.

@qntm qntm closed this May 3, 2013
@pjkundert
Copy link
Contributor Author

No problem; I wondered if there might be a simpler way to achieve the same goal, without having to maintain the concept of "never" in the multiplier. I'll take another run at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants