iter-tools / regex

A streaming regex evaluation engine
MIT License
11 stars 1 forks source link

Improve capture data structure #44

Closed conartist6 closed 2 years ago

conartist6 commented 2 years ago

I've improved naming, reduced redundancy, and somehow changed the behavior regarding empty capturing groups. I believe the new behavior is more correct.

conartist6 commented 2 years ago

Ah crap, a lot of this was wrong. Captures can't be mutable. I just was lazy the first time around about writing the test that would have showed me I was breaking something.

conartist6 commented 2 years ago

This PR was merged, but I rewrote the history since the mistake was a day old, there are no forks yet, and there was no reason to make a mess of the history.

conartist6 commented 2 years ago

The particular test which I had neglected to write thus far and would have showed me the problem was:

  it('(a(bc|b))c', () => {
    const exp = parse('(a(bc|b))c');
    expect(exec(exp, 'abc')).toEqual(['abc', 'ab', 'b']);
  });