// (#<identifier> rule)
function namedCaptures(re) {
var map = [];
var ret = new RegExp( re.source.replace( /#<([^>]+)> /g, function(q, e) {
map.push(e);
return '';
} ), (re.global ? 'g' : '') + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') );
function assign(m) {
if (m == null) {
return m;
}
var i = map.length, j, o = {};
while (i) {
j = i;
o[ map[--i] ] = m[j];
}
return o;
}
ret.exec = function(str) {
return assign( RegExp.prototype.exec.call(this, str) );
}
return ret;
}