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

Add simple handling/workaround for chained quantifiers #69

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

jaynetics
Copy link
Collaborator

@ammar wanna take a look?

this adds support for chained quantifiers by wrapping their targets in passive groups.

it modifies the node tree while parsing, similar to the treatment of alternations, ranges in sets etc.

this seems to be the most pragmatic way to handle these edge cases. existing integrations of the gem will keep working without effort, and if someone really wants to treat these cases in a special way, they can check #implicit?.

i also explored some other approaches, which seemed worse:

  1. allowing Quantifier objects to have a #quantifier themselves
  • this would mirror Onigmo, where quantifiers are normal nodes and can thus have a quantifier (via a pointer)
  • this is bad IMO because it hides the problem: people will not usually check this method and existing implementations certainly don't
  1. replacing #quantifier with #quantifiers returning an Array of Quantifier objects for all expressions
  • this is really bad because:
  • everyone using the gem has to update the integration
  • everyone building an integration will have to understand the obscure reason for this pluralization
  1. same as 2, but leaving def quantifier; quantifiers[0] end as a fallback
  • this either suffers the same issue of hiding the problem as 1
  • or, if there is a deprecation warning, it forces people to think and decide about this very edgy case

@jaynetics jaynetics merged commit ee57858 into master Nov 25, 2020
@jaynetics jaynetics deleted the handle_chained_quantifiers branch November 25, 2020 11:56
jaynetics added a commit that referenced this pull request May 1, 2022
these characters were wrongly treated as possessive or reluctant mode flags for the interval quantifier.

Ruby/Onigmo does not support these modes for intervals, so it treats them as extra, chained quantifiers instead.

c.f. #3, #69
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.

1 participant