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

Regex operators for sequences #12

Open
prayerslayer opened this issue Nov 30, 2016 · 2 comments
Open

Regex operators for sequences #12

prayerslayer opened this issue Nov 30, 2016 · 2 comments

Comments

@prayerslayer
Copy link
Owner

prayerslayer commented Nov 30, 2016

From clojure.spec, but we need to rename some as ?, + and * are not valid in javascript identifiers.

  • cat
  • alt
  • ? => qm? atMostOne?
  • + => plus? atLeastOne?
  • * => star? any?

So that we could

import {define, spec} from 'js.spec'

define("ingredient", spec.cat(
  "quantity", spec.number,
  "unit", spec.string))

define("odds-then-maybe-even", spec.cat(
  "odds", spec.plus(spec.odd),
  "even", spec.star(spec.even)))

Check to what extent we can leverage pamatcher.

@scotttrinh
Copy link

I like the idea of naming them after what they do rather than describing the symbol, even though the symbol names are shorter.

One interesting thought is that all three of those quantifier (which is what the Perl docs call them) operators are really shorthand for {n,m}: ? === {0,1} * === {0,} + === {1,}. I wonder if we just use a single quantify or repeat method that takes three parameters (low, high, spec)? This is similar to the linked pamatcher's repeat.

@prayerslayer
Copy link
Owner Author

I wonder if we just use a single quantify or repeat method that takes three parameters (low, high, spec)? This is similar to the linked pamatcher's repeat.

I think that's a good idea. We can still expose this function bound to predefined values for +, ?, *.

prayerslayer added a commit that referenced this issue Dec 4, 2016
prayerslayer added a commit that referenced this issue Dec 29, 2016
prayerslayer added a commit that referenced this issue Dec 29, 2016
prayerslayer added a commit that referenced this issue Dec 29, 2016
prayerslayer added a commit that referenced this issue Dec 30, 2016
prayerslayer added a commit that referenced this issue Dec 30, 2016
prayerslayer added a commit that referenced this issue Dec 30, 2016
prayerslayer added a commit that referenced this issue Dec 30, 2016
prayerslayer added a commit that referenced this issue Jan 6, 2017
prayerslayer added a commit that referenced this issue Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants