Skip to content

Commit a5a597b

Browse files
author
Brian Mock
authored
Merge pull request #192 from /issues/189
Fixes #189 fixes regexp failure bug
2 parents 10ac76e + c1be8e4 commit a5a597b

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## version 1.6.2 (2017-07-08)
2+
3+
* Fixes another bug with match groups outside the correct range in `Parsimmon.regexp(regexp, group)`.
4+
15
## version 1.6.1 (2017-07-01)
26

37
* **100% unit test coverage!** This does not mean bugs won't exist, but it keeps us much safer against regressions in the future.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parsimmon",
3-
"version": "1.6.1",
3+
"version": "1.6.2",
44
"description": "A monadic LL(infinity) parser combinator library",
55
"keywords": [
66
"parsing",

src/parsimmon.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@ function regexp(re, group) {
595595
var groupMatch = match[group];
596596
return makeSuccess(i + fullMatch.length, groupMatch);
597597
}
598-
return makeFailure(
599-
'valid match group (0 to ' + match.length + ') in ' + expected
600-
);
598+
var message =
599+
'valid match group (0 to ' + match.length + ') in ' + expected;
600+
return makeFailure(i, message);
601601
}
602602
return makeFailure(i, expected);
603603
});

test/core/regexp.test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ suite('Parsimmon.regexp', function() {
4747
assert.strictEqual(parser0.parse('a1').value, 'a1');
4848
assert.strictEqual(parser1.parse('a1').value, 'a');
4949
assert.strictEqual(parser2.parse('a1').value, '1');
50-
assert.strictEqual(parser3.parse('a1').status, false);
50+
assert.deepStrictEqual(parser3.parse('a1'), {
51+
status: false,
52+
expected: ['valid match group (0 to 3) in /(\\w)(\\d)/'],
53+
index: {column: 1, line: 1, offset: 0},
54+
});
5155
});
5256

5357
});

0 commit comments

Comments
 (0)