Skip to content

Commit

Permalink
Merge pull request #192 from /issues/189
Browse files Browse the repository at this point in the history
Fixes #189 fixes regexp failure bug
  • Loading branch information
Brian Mock authored Jul 9, 2017
2 parents 10ac76e + c1be8e4 commit a5a597b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## version 1.6.2 (2017-07-08)

* Fixes another bug with match groups outside the correct range in `Parsimmon.regexp(regexp, group)`.

## version 1.6.1 (2017-07-01)

* **100% unit test coverage!** This does not mean bugs won't exist, but it keeps us much safer against regressions in the future.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parsimmon",
"version": "1.6.1",
"version": "1.6.2",
"description": "A monadic LL(infinity) parser combinator library",
"keywords": [
"parsing",
Expand Down
6 changes: 3 additions & 3 deletions src/parsimmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ function regexp(re, group) {
var groupMatch = match[group];
return makeSuccess(i + fullMatch.length, groupMatch);
}
return makeFailure(
'valid match group (0 to ' + match.length + ') in ' + expected
);
var message =
'valid match group (0 to ' + match.length + ') in ' + expected;
return makeFailure(i, message);
}
return makeFailure(i, expected);
});
Expand Down
6 changes: 5 additions & 1 deletion test/core/regexp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ suite('Parsimmon.regexp', function() {
assert.strictEqual(parser0.parse('a1').value, 'a1');
assert.strictEqual(parser1.parse('a1').value, 'a');
assert.strictEqual(parser2.parse('a1').value, '1');
assert.strictEqual(parser3.parse('a1').status, false);
assert.deepStrictEqual(parser3.parse('a1'), {
status: false,
expected: ['valid match group (0 to 3) in /(\\w)(\\d)/'],
index: {column: 1, line: 1, offset: 0},
});
});

});

0 comments on commit a5a597b

Please sign in to comment.