From 1d974ce2b6f146224644414ca45464c7565183a3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 16 Jan 2013 19:09:06 +0100 Subject: [PATCH] [loose parser] Several small tweaks --- acorn_loose.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/acorn_loose.js b/acorn_loose.js index 59ea3c526c..7262e4c6e6 100644 --- a/acorn_loose.js +++ b/acorn_loose.js @@ -132,7 +132,7 @@ return count; } function closesBlock(closeTok, indent) { - return token.type === closeTok || token.type === tt.eof || indent > indentationAt(token.start); + return token.type === closeTok || token.type === tt.eof || indent > token.start - lineStart(token.start); } function node_t(start) { @@ -627,16 +627,17 @@ else node.id = null; node.params = []; expect(tt.parenL); - while (!eat(tt.parenR)) { + while (node.type == tt.name) { node.params.push(parseIdent()); eat(tt.comma); } + eat(tt.parenR); node.body = parseBlock(); return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); } function parseExprList(close) { - var elts = [], indent = indentationAt(token.start); + var elts = [], indent = indentationAt(token.start) + 1; while (!closesBlock(close, indent)) { elts.push(parseExpression$(true)); while (eat(tt.comma)) {}