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

Fix handling of repeats and alternative options in Tabular #75

Merged
merged 3 commits into from
May 13, 2022

Conversation

petoalbert
Copy link
Contributor

I have noticed that tests in RegexSpec for atMost and between were ignored and that they would fail. In this PR I attempt to make them green.

There were two bigger areas that I fixed.

  1. Handling of the | operator between Steps. In the original version, combining anything with Matched would be a Matched state as well. This would, however, reduce alternatives like aaa | aa | a to the shortest possible sequence. To help with this, I "uncommented" the MatchedOrJump type and interpreted it as some kind of "checkpoint". If in the while loop in the implementation of test we encounter a MatchedOrJump, we set returnV to the current index but otherwise continue the loop. Combining Matched with Jump(...) in this case would resuld a MatchedOrJump.

  2. Handling Empty matchers: The current implementation of LookupFunction can only tell if a character matches or not. It cannot tell if it can match without consuming any input. There is an object Empty which extends Tabular, but it cannot be combined with a LookupFunction currently (Empty | lookup = lookup). This will fail for uses of atMost, or generally Repeat where 0 matches are allowed as well. To fix this, I moved Empty under LookupFunction and introduced a supportsEmpty value to LookupFunction. Combining lookup functions sequentially where supportsEmpty=true will create MatchedOrJump steps as well.

@vigoo
Copy link
Collaborator

vigoo commented May 5, 2022

Please run scalafmtAll

@vigoo vigoo requested a review from jdegoes May 5, 2022 08:41
Copy link
Collaborator

@vigoo vigoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@vigoo vigoo merged commit e9ebd3d into zio:master May 13, 2022
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.

2 participants