Give a good error message if an invalid regular expression is found.

This commit is contained in:
Chris Cowan
2015-05-14 12:03:54 -07:00
committed by Richard van Velzen
parent 252fc65558
commit d6814050dd

View File

@@ -480,7 +480,13 @@ function tokenizer($TEXT, filename, html5_comments) {
regexp += ch;
}
var mods = read_name();
return token("regexp", new RegExp(regexp, mods));
var r;
try {
r = new RegExp(regexp, mods);
} catch(e) {
parse_error("Invalid regular expression");
}
return token("regexp", r);
});
function read_operator(prefix) {