Skip to content

Properly bound reps for machine parser#57

Merged
goodmami merged 1 commit intomainfrom
gh-53-bounded-machine
Jun 18, 2025
Merged

Properly bound reps for machine parser#57
goodmami merged 1 commit intomainfrom
gh-53-bounded-machine

Conversation

@goodmami
Copy link
Copy Markdown
Owner

Bounded repetitions were buggy for both machine parsers, except for character classes because they implement their own repetition. The problems were due mainly to (a) not accounting for the parsing success that occurred in order to reach the UPDATE instruction, and (b) not accounting for the mincount matches that have already occurred, as they are not tracked by the UPDATE's counter.

Before:

>>> pe.compile('"a"{1,2}', parser="machine-python").match('aaaaaa')
<Match object; span=(0, 4), match='aaaa'>

Now:

>>> pe.compile('"a"{1,2}', parser="machine-python").match('aaaaaa')
<Match object; span=(0, 2), match='aa'>

Fixes #53

Bounded repetitions were buggy for both machine parsers, except for
character classes because they implement their own repetition. The
problems were due mainly to (a) not accounting for the parsing success
that occurred in order to reach the UPDATE instruction, and (b) not
accounting for the mincount matches that have already occurred, as they
are not tracked by the UPDATE's counter.

Before:

>>> pe.compile('"a"{1,2}', parser="machine-python").match('aaaaaa')
<Match object; span=(0, 4), match='aaaa'>

Now:

>>> pe.compile('"a"{1,2}', parser="machine-python").match('aaaaaa')
<Match object; span=(0, 2), match='aa'>

Fixes #53
@goodmami goodmami merged commit 402f6ee into main Jun 18, 2025
6 checks passed
@goodmami goodmami deleted the gh-53-bounded-machine branch June 18, 2025 18:53
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.

Bounded repetition of non-character classes broken for machine parsers

1 participant