Fix parsing regexp after unary-prefix operator

++/x/.y

Fix #284
This commit is contained in:
Mihai Bazon
2013-09-02 09:56:27 +03:00
parent a89d233318
commit 78a217b94c

View File

@@ -688,12 +688,16 @@ function parse($TEXT, options) {
}; };
}; };
var statement = embed_tokens(function() { function handle_regexp() {
var tmp;
if (is("operator", "/") || is("operator", "/=")) { if (is("operator", "/") || is("operator", "/=")) {
S.peeked = null; S.peeked = null;
S.token = S.input(S.token.value.substr(1)); // force regexp S.token = S.input(S.token.value.substr(1)); // force regexp
} }
};
var statement = embed_tokens(function() {
var tmp;
handle_regexp();
switch (S.token.type) { switch (S.token.type) {
case "string": case "string":
var dir = S.in_directives, stat = simple_statement(); var dir = S.in_directives, stat = simple_statement();
@@ -1279,6 +1283,7 @@ function parse($TEXT, options) {
var start = S.token; var start = S.token;
if (is("operator") && UNARY_PREFIX(start.value)) { if (is("operator") && UNARY_PREFIX(start.value)) {
next(); next();
handle_regexp();
var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls)); var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls));
ex.start = start; ex.start = start;
ex.end = prev(); ex.end = prev();