Allow parsing regexp after arrow token (#1439)

This commit is contained in:
Anthony Van de Gejuchte
2017-01-26 12:06:46 +01:00
committed by Richard van Velzen
parent 52ce9a333c
commit 4728bc73ad
2 changed files with 11 additions and 1 deletions

View File

@@ -335,7 +335,8 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
function token(type, value, is_comment) {
S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX(value)) ||
(type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value)) ||
(type == "punc" && PUNC_BEFORE_EXPRESSION(value)));
(type == "punc" && PUNC_BEFORE_EXPRESSION(value))) ||
(type == "arrow");
prev_was_dot = (type == "punc" && value == ".");
var ret = {
type : type,

View File

@@ -126,3 +126,12 @@ arrow_binding_pattern_strict: {
}
expect_exact: 'var foo=([,])=>"foo";'
}
arrow_with_regexp: {
input: {
num => /\d{11,14}/.test( num )
}
expect: {
num => /\d{11,14}/.test( num )
}
}