From 6bf8311061807e719bfa4c6efe156e8db7214bca Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Fri, 31 Oct 2014 01:09:21 +0200 Subject: [PATCH] Loose: fix #33. --- acorn_loose.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/acorn_loose.js b/acorn_loose.js index 261d9e76b5..4c5806a179 100644 --- a/acorn_loose.js +++ b/acorn_loose.js @@ -59,15 +59,14 @@ var lastEnd, token = {start: 0, end: 0}, ahead = []; var curLineStart, nextLineStart, curIndent, lastEndLoc, sourceFile; - function next() { + function next(forceRegexp) { lastEnd = token.end; if (options.locations) lastEndLoc = token.endLoc; + if (forceRegexp) + ahead.length = 0; - if (ahead.length) - token = ahead.shift(); - else - token = readToken(); + token = ahead.shift() || readToken(forceRegexp); if (token.start >= nextLineStart) { while (token.start >= nextLineStart) { @@ -78,10 +77,10 @@ } } - function readToken() { + function readToken(forceRegexp) { for (;;) { try { - var tok = fetchToken(); + var tok = fetchToken(forceRegexp); if (tok.type === tt.dot && input.substr(tok.end, 1) === '.') { tok = fetchToken(); tok.start--; @@ -309,6 +308,9 @@ } function parseStatement() { + if (token.type === tt.slash || token.type === tt.assign && token.value === "/=") + next(true); + var starttype = token.type, node = startNode(); switch (starttype) {