Comparing version 0.0.4 to 0.0.5
11
index.js
@@ -6,3 +6,3 @@ function parse(n) { | ||
} | ||
return index = 1, parser.parse(n); | ||
return index = 1, cgs = {}, parser.parse(n); | ||
} | ||
@@ -26,4 +26,5 @@ | ||
function CaptureGroup(n, t) { | ||
Group.call(this, "capture-group"), this.index = n, this.body = t; | ||
function CaptureGroup(n) { | ||
Group.call(this, "capture-group"), this.index = cgs[this.offset] || (cgs[this.offset] = index++), | ||
this.body = n; | ||
} | ||
@@ -504,3 +505,3 @@ | ||
}, tr = function(n) { | ||
return new CaptureGroup(index++, n); | ||
return new CaptureGroup(n); | ||
}, rr = "?:", er = '"?:"', lr = function(n) { | ||
@@ -576,3 +577,3 @@ return new Group("non-capture-group", n); | ||
}; | ||
}(), index = 1; | ||
}(), index = 1, cgs = {}; | ||
@@ -579,0 +580,0 @@ exports = module.exports = parse, exports.Token = Token, exports.Alternate = Alternate, |
{ | ||
"name": "regexp", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Regex Parser", | ||
@@ -9,3 +9,3 @@ "keywords": [], | ||
"uglify-js": "~2.3.6", | ||
"pegjs": "https://github.com/dmajda/pegjs/archive/798ed6a8a4fbfc36b312ba09d428a5832808d9d6.tar.gz", | ||
"pegjs": "https://github.com/dmajda/pegjs/archive/791034fad92c9cd7a9d1c71187df03441bbfd521.tar.gz", | ||
"bash-color": "0.0.3" | ||
@@ -12,0 +12,0 @@ }, |
@@ -217,3 +217,62 @@ module.exports = [ | ||
body: 'n', | ||
escaped: false } ] }] | ||
escaped: false } ] }], | ||
[/(a)(b)(?:c)(d)/, { type: 'match', | ||
offset: 0, | ||
text: '(a)(b)(?:c)(d)', | ||
body: | ||
[ { type: 'capture-group', | ||
offset: 1, | ||
text: 'a', | ||
body: | ||
{ type: 'match', | ||
offset: 1, | ||
text: 'a', | ||
body: | ||
[ { type: 'literal', | ||
offset: 1, | ||
text: 'a', | ||
body: 'a', | ||
escaped: false } ] }, | ||
index: 1 }, | ||
{ type: 'capture-group', | ||
offset: 4, | ||
text: 'b', | ||
body: | ||
{ type: 'match', | ||
offset: 4, | ||
text: 'b', | ||
body: | ||
[ { type: 'literal', | ||
offset: 4, | ||
text: 'b', | ||
body: 'b', | ||
escaped: false } ] }, | ||
index: 2 }, | ||
{ type: 'non-capture-group', | ||
offset: 7, | ||
text: '?:c', | ||
body: | ||
{ type: 'match', | ||
offset: 9, | ||
text: 'c', | ||
body: | ||
[ { type: 'literal', | ||
offset: 9, | ||
text: 'c', | ||
body: 'c', | ||
escaped: false } ] } }, | ||
{ type: 'capture-group', | ||
offset: 12, | ||
text: 'd', | ||
body: | ||
{ type: 'match', | ||
offset: 12, | ||
text: 'd', | ||
body: | ||
[ { type: 'literal', | ||
offset: 12, | ||
text: 'd', | ||
body: 'd', | ||
escaped: false } ] }, | ||
index: 3 } ] }] | ||
] |
37248
894