[Pkg-javascript-commits] [node-acorn-jsx] 14/484: More or less finish comments
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:19:57 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 42d0c4535a9ab5f95267b61aa96cf9098c3d844f
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Tue Oct 2 16:14:18 2012 +0200
More or less finish comments
---
acorn.js | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/acorn.js b/acorn.js
index 18b2e9f..9dc277f 100644
--- a/acorn.js
+++ b/acorn.js
@@ -3,6 +3,15 @@
// Acorn was written by Marijn Haverbeke and released under an MIT
// license. The Unicode regexps (for identifiers and whitespace) were
// taken from [Esprima](http://esprima.org) by Ariya Hidayat.
+//
+// Git repositories for Acorn are available at
+//
+// http://marijnhaverbeke.nl/git/acorn
+// https://github.com/marijnh/acorn.git
+//
+// Please use the [github bug tracker][ghbt] to report issues.
+//
+// [ghbt]: https://github.com/marijnh/acorn/issues
(function(exports) {
"strict mode";
@@ -1477,9 +1486,16 @@
node.params.push(parseIdent());
}
+ // Start a new scope with regard to labels and the `inFunction`
+ // flag (restore them to their old value afterwards).
var oldInFunc = inFunction, oldLabels = labels;
inFunction = true; labels = [];
node.body = parseBlock(true);
+ inFunction = oldInFunc; labels = oldLabels;
+
+ // If this is a strict mode function, verify that argument names
+ // are not repeated, and it does not try to bind the words `eval`
+ // or `arguments`.
if (strict || node.body.body.length && isUseStrict(node.body.body[0])) {
for (var i = node.id ? -1 : 0; i < node.params.length; ++i) {
var id = i < 0 ? node.id : node.params[i];
@@ -1490,10 +1506,15 @@
}
}
- inFunction = oldInFunc; labels = oldLabels;
return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
}
+ // Parses a comma-separated list of expressions, and returns them as
+ // an array. `close` is the token type that ends the list, and
+ // `allowEmpty` can be turned on to allow subsequent commas with
+ // nothing in between them to be parsed as `null` (which is needed
+ // for array literals).
+
function parseExprList(close, allowTrailingComma, allowEmpty) {
var elts = [], first = true;
while (!eat(close)) {
@@ -1508,12 +1529,13 @@
return elts;
}
+ // Parse the next token as an identifier. If `liberal` is true (used
+ // when parsing properties), it will also convert keywords into
+ // identifiers.
+
function parseIdent(liberal) {
var node = startNode();
- if (tokType !== _name) {
- if (liberal && tokType.keyword) node.name = tokType.keyword;
- else unexpected();
- } else node.name = tokVal;
+ node.name = tokType === _name ? tokVal : (liberal && tokType.keyword) || unexpected();
next();
return finishNode(node, "Identifier");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list