heregex: now allows bare slashes and empty body

This commit is contained in:
satyr
2010-10-04 11:55:49 +09:00
parent c605b3e232
commit 493fa7d8fe
3 changed files with 8 additions and 5 deletions

View File

@@ -205,11 +205,12 @@
return true;
};
Lexer.prototype.heregexToken = function(match) {
var _ref2, body, flags, heregex;
var _ref2, body, flags, heregex, re;
_ref2 = match, heregex = _ref2[0], body = _ref2[1], flags = _ref2[2];
this.i += heregex.length;
if (!(~body.indexOf('#{'))) {
this.token('REGEX', '/' + body.replace(HEREGEX_OMIT, '') + '/' + flags);
re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
this.token('REGEX', "/" + (re || '(?:)') + "/" + (flags));
return true;
}
this.token('IDENTIFIER', 'RegExp');