[Pkg-javascript-commits] [node-ast-types] 01/03: New upstream version 0.9.10

Julien Puydt julien.puydt at laposte.net
Thu Mar 23 20:37:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-ast-types.

commit 84fa789f2268c9f129d6ae4d63f8f49c2a600ff7
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Thu Mar 23 21:32:32 2017 +0100

    New upstream version 0.9.10
---
 .travis.yml                       |  17 +-
 README.md                         |   5 +-
 def/{babel6.js => babel6-core.js} |   9 +-
 def/babel6.js                     | 163 +-------------
 def/es6.js                        | 440 +++++++++++++++++++-------------------
 def/flow.js                       |  11 +
 def/jsx.js                        | 178 +++++++--------
 def/mozilla.js                    |   9 -
 package.json                      |  10 +-
 test/run.js                       |  19 +-
 10 files changed, 358 insertions(+), 503 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4bce056..4d29cc1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,21 +1,12 @@
 language: node_js
 node_js:
-  - "6.0"
-  - "5.0"
-  - "4.0"
+  - "7"
+  - "6"
+  - "5"
+  - "4"
   - "iojs"
   - "0.12"
   - "0.11"
   - "0.10"
-  - "0.8"
-  - "0.6"
 
 sudo: false
-  
-before_install:
-  npm install -g npm@'>=1.4.3'
-
-matrix:
-  allow_failures:
-    - node_js: "0.8"
-    - node_js: "0.6"
diff --git a/README.md b/README.md
index fc8ca80..500a16d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-AST Types
-===
+# AST Types [![Build Status](https://travis-ci.org/benjamn/ast-types.svg?branch=master)](https://travis-ci.org/benjamn/ast-types) [![Greenkeeper badge](https://badges.greenkeeper.io/benjamn/ast-types.svg)](https://greenkeeper.io/)
 
 This module provides an efficient, modular,
 [Esprima](https://github.com/ariya/esprima)-compatible implementation of
@@ -8,8 +7,6 @@ tree](http://en.wikipedia.org/wiki/Abstract_syntax_tree) type hierarchy
 pioneered by the [Mozilla Parser
 API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API).
 
-[![Build Status](https://travis-ci.org/benjamn/ast-types.png?branch=master)](https://travis-ci.org/benjamn/ast-types)
-
 Installation
 ---
 
diff --git a/def/babel6.js b/def/babel6-core.js
similarity index 96%
copy from def/babel6.js
copy to def/babel6-core.js
index 95c90ff..9934419 100644
--- a/def/babel6.js
+++ b/def/babel6-core.js
@@ -1,6 +1,5 @@
 module.exports = function (fork) {
   fork.use(require("./babel"));
-  fork.use(require("./flow"));
 
   // var types = fork.types;
   var types = fork.use(require("../lib/types"));
@@ -44,7 +43,8 @@ module.exports = function (fork) {
 
   def("NullLiteral")
     .bases("Literal")
-    .build();
+    .build()
+    .field("value", null, defaults["null"]);
 
   def("BooleanLiteral")
     .bases("Literal")
@@ -55,7 +55,10 @@ module.exports = function (fork) {
     .bases("Literal")
     .build("pattern", "flags")
     .field("pattern", String)
-    .field("flags", String);
+    .field("flags", String)
+    .field("value", RegExp, function () {
+      return new RegExp(this.pattern, this.flags);
+    });
 
   var ObjectExpressionProperty = or(
     def("Property"),
diff --git a/def/babel6.js b/def/babel6.js
index 95c90ff..9c405b6 100644
--- a/def/babel6.js
+++ b/def/babel6.js
@@ -1,165 +1,4 @@
 module.exports = function (fork) {
-  fork.use(require("./babel"));
+  fork.use(require("./babel6-core"));
   fork.use(require("./flow"));
-
-  // var types = fork.types;
-  var types = fork.use(require("../lib/types"));
-  // var defaults = fork.shared.defaults;
-  var defaults = fork.use(require("../lib/shared")).defaults;
-  var def = types.Type.def;
-  var or = types.Type.or;
-
-  def("Directive")
-    .bases("Node")
-    .build("value")
-    .field("value", def("DirectiveLiteral"));
-
-  def("DirectiveLiteral")
-    .bases("Node", "Expression")
-    .build("value")
-    .field("value", String, defaults["use strict"]);
-
-  def("BlockStatement")
-    .bases("Statement")
-    .build("body")
-    .field("body", [def("Statement")])
-    .field("directives", [def("Directive")], defaults.emptyArray);
-
-  def("Program")
-    .bases("Node")
-    .build("body")
-    .field("body", [def("Statement")])
-    .field("directives", [def("Directive")], defaults.emptyArray);
-
-  // Split Literal
-  def("StringLiteral")
-    .bases("Literal")
-    .build("value")
-    .field("value", String);
-
-  def("NumericLiteral")
-    .bases("Literal")
-    .build("value")
-    .field("value", Number);
-
-  def("NullLiteral")
-    .bases("Literal")
-    .build();
-
-  def("BooleanLiteral")
-    .bases("Literal")
-    .build("value")
-    .field("value", Boolean);
-
-  def("RegExpLiteral")
-    .bases("Literal")
-    .build("pattern", "flags")
-    .field("pattern", String)
-    .field("flags", String);
-
-  var ObjectExpressionProperty = or(
-    def("Property"),
-    def("ObjectMethod"),
-    def("ObjectProperty"),
-    def("SpreadProperty")
-  );
-
-  // Split Property -> ObjectProperty and ObjectMethod
-  def("ObjectExpression")
-    .bases("Expression")
-    .build("properties")
-    .field("properties", [ObjectExpressionProperty]);
-
-  // ObjectMethod hoist .value properties to own properties
-  def("ObjectMethod")
-    .bases("Node", "Function")
-    .build("kind", "key", "params", "body", "computed")
-    .field("kind", or("method", "get", "set"))
-    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-    .field("params", [def("Pattern")])
-    .field("body", def("BlockStatement"))
-    .field("computed", Boolean, defaults["false"])
-    .field("generator", Boolean, defaults["false"])
-    .field("async", Boolean, defaults["false"])
-    .field("decorators",
-           or([def("Decorator")], null),
-           defaults["null"]);
-
-  def("ObjectProperty")
-    .bases("Node")
-    .build("key", "value")
-    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-    .field("value", or(def("Expression"), def("Pattern")))
-    .field("computed", Boolean, defaults["false"]);
-
-  var ClassBodyElement = or(
-    def("MethodDefinition"),
-    def("VariableDeclarator"),
-    def("ClassPropertyDefinition"),
-    def("ClassProperty"),
-    def("ClassMethod")
-  );
-
-  // MethodDefinition -> ClassMethod
-  def("ClassBody")
-    .bases("Declaration")
-    .build("body")
-    .field("body", [ClassBodyElement]);
-
-  def("ClassMethod")
-    .bases("Declaration", "Function")
-    .build("kind", "key", "params", "body", "computed", "static")
-    .field("kind", or("get", "set", "method", "constructor"))
-    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-    .field("params", [def("Pattern")])
-    .field("body", def("BlockStatement"))
-    .field("computed", Boolean, defaults["false"])
-    .field("static", Boolean, defaults["false"])
-    .field("generator", Boolean, defaults["false"])
-    .field("async", Boolean, defaults["false"])
-    .field("decorators",
-           or([def("Decorator")], null),
-           defaults["null"]);
-
-  var ObjectPatternProperty = or(
-    def("Property"),
-    def("PropertyPattern"),
-    def("SpreadPropertyPattern"),
-    def("SpreadProperty"), // Used by Esprima
-    def("ObjectProperty"), // Babel 6
-    def("RestProperty") // Babel 6
-  );
-
-  // Split into RestProperty and SpreadProperty
-  def("ObjectPattern")
-    .bases("Pattern")
-    .build("properties")
-    .field("properties", [ObjectPatternProperty])
-    .field("decorators",
-           or([def("Decorator")], null),
-           defaults["null"]);
-
-  def("SpreadProperty")
-    .bases("Node")
-    .build("argument")
-    .field("argument", def("Expression"));
-
-  def("RestProperty")
-    .bases("Node")
-    .build("argument")
-    .field("argument", def("Expression"));
-
-  def("ForAwaitStatement")
-    .bases("Statement")
-    .build("left", "right", "body")
-    .field("left", or(
-      def("VariableDeclaration"),
-      def("Expression")))
-    .field("right", def("Expression"))
-    .field("body", def("Statement"));
-
-  // The callee node of a dynamic import(...) expression.
-  def("Import")
-    .bases("Expression")
-    .build();
 };
diff --git a/def/es6.js b/def/es6.js
index 284fa54..947ee5c 100644
--- a/def/es6.js
+++ b/def/es6.js
@@ -1,219 +1,227 @@
 module.exports = function (fork) {
-    fork.use(require("./core"));
-    var types = fork.use(require("../lib/types"));
-    var def = types.Type.def;
-    var or = types.Type.or;
-    var defaults = fork.use(require("../lib/shared")).defaults;
-
-    def("Function")
-      .field("generator", Boolean, defaults["false"])
-      .field("expression", Boolean, defaults["false"])
-      .field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
-      // TODO This could be represented as a RestElement in .params.
-      .field("rest", or(def("Identifier"), null), defaults["null"]);
-
-    // The ESTree way of representing a ...rest parameter.
-    def("RestElement")
-      .bases("Pattern")
-      .build("argument")
-      .field("argument", def("Pattern"));
-
-    def("SpreadElementPattern")
-      .bases("Pattern")
-      .build("argument")
-      .field("argument", def("Pattern"));
-
-    def("FunctionDeclaration")
-      .build("id", "params", "body", "generator", "expression");
-
-    def("FunctionExpression")
-      .build("id", "params", "body", "generator", "expression");
-
-    // The Parser API calls this ArrowExpression, but Esprima and all other
-    // actual parsers use ArrowFunctionExpression.
-    def("ArrowFunctionExpression")
-      .bases("Function", "Expression")
-      .build("params", "body", "expression")
-      // The forced null value here is compatible with the overridden
-      // definition of the "id" field in the Function interface.
-      .field("id", null, defaults["null"])
-      // Arrow function bodies are allowed to be expressions.
-      .field("body", or(def("BlockStatement"), def("Expression")))
-      // The current spec forbids arrow generators, so I have taken the
-      // liberty of enforcing that. TODO Report this.
-      .field("generator", false, defaults["false"]);
-
-    def("YieldExpression")
-      .bases("Expression")
-      .build("argument", "delegate")
-      .field("argument", or(def("Expression"), null))
-      .field("delegate", Boolean, defaults["false"]);
-
-    def("GeneratorExpression")
-      .bases("Expression")
-      .build("body", "blocks", "filter")
-      .field("body", def("Expression"))
-      .field("blocks", [def("ComprehensionBlock")])
-      .field("filter", or(def("Expression"), null));
-
-    def("ComprehensionExpression")
-      .bases("Expression")
-      .build("body", "blocks", "filter")
-      .field("body", def("Expression"))
-      .field("blocks", [def("ComprehensionBlock")])
-      .field("filter", or(def("Expression"), null));
-
-    def("ComprehensionBlock")
-      .bases("Node")
-      .build("left", "right", "each")
-      .field("left", def("Pattern"))
-      .field("right", def("Expression"))
-      .field("each", Boolean);
-
-    def("Property")
-      .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-      .field("value", or(def("Expression"), def("Pattern")))
-      .field("method", Boolean, defaults["false"])
-      .field("shorthand", Boolean, defaults["false"])
-      .field("computed", Boolean, defaults["false"]);
-
-    def("PropertyPattern")
-      .bases("Pattern")
-      .build("key", "pattern")
-      .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-      .field("pattern", def("Pattern"))
-      .field("computed", Boolean, defaults["false"]);
-
-    def("ObjectPattern")
-      .bases("Pattern")
-      .build("properties")
-      .field("properties", [or(def("PropertyPattern"), def("Property"))]);
-
-    def("ArrayPattern")
-      .bases("Pattern")
-      .build("elements")
-      .field("elements", [or(def("Pattern"), null)]);
-
-    def("MethodDefinition")
-      .bases("Declaration")
-      .build("kind", "key", "value", "static")
-      .field("kind", or("constructor", "method", "get", "set"))
-      .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-      .field("value", def("Function"))
-      .field("computed", Boolean, defaults["false"])
-      .field("static", Boolean, defaults["false"]);
-
-    def("SpreadElement")
-      .bases("Node")
-      .build("argument")
-      .field("argument", def("Expression"));
-
-    def("ArrayExpression")
-      .field("elements", [or(
-        def("Expression"),
-        def("SpreadElement"),
-        def("RestElement"),
-        null
-      )]);
-
-    def("NewExpression")
-      .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
-
-    def("CallExpression")
-      .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
-
-    // Note: this node type is *not* an AssignmentExpression with a Pattern on
-    // the left-hand side! The existing AssignmentExpression type already
-    // supports destructuring assignments. AssignmentPattern nodes may appear
-    // wherever a Pattern is allowed, and the right-hand side represents a
-    // default value to be destructured against the left-hand side, if no
-    // value is otherwise provided. For example: default parameter values.
-    def("AssignmentPattern")
-      .bases("Pattern")
-      .build("left", "right")
-      .field("left", def("Pattern"))
-      .field("right", def("Expression"));
-
-    var ClassBodyElement = or(
-      def("MethodDefinition"),
-      def("VariableDeclarator"),
-      def("ClassPropertyDefinition"),
-      def("ClassProperty")
-    );
-
+  fork.use(require("./core"));
+  var types = fork.use(require("../lib/types"));
+  var def = types.Type.def;
+  var or = types.Type.or;
+  var defaults = fork.use(require("../lib/shared")).defaults;
+
+  def("Function")
+    .field("generator", Boolean, defaults["false"])
+    .field("expression", Boolean, defaults["false"])
+    .field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
+    // TODO This could be represented as a RestElement in .params.
+    .field("rest", or(def("Identifier"), null), defaults["null"]);
+
+  // The ESTree way of representing a ...rest parameter.
+  def("RestElement")
+    .bases("Pattern")
+    .build("argument")
+    .field("argument", def("Pattern"));
+
+  def("SpreadElementPattern")
+    .bases("Pattern")
+    .build("argument")
+    .field("argument", def("Pattern"));
+
+  def("FunctionDeclaration")
+    .build("id", "params", "body", "generator", "expression");
+
+  def("FunctionExpression")
+    .build("id", "params", "body", "generator", "expression");
+
+  // The Parser API calls this ArrowExpression, but Esprima and all other
+  // actual parsers use ArrowFunctionExpression.
+  def("ArrowFunctionExpression")
+    .bases("Function", "Expression")
+    .build("params", "body", "expression")
+    // The forced null value here is compatible with the overridden
+    // definition of the "id" field in the Function interface.
+    .field("id", null, defaults["null"])
+    // Arrow function bodies are allowed to be expressions.
+    .field("body", or(def("BlockStatement"), def("Expression")))
+    // The current spec forbids arrow generators, so I have taken the
+    // liberty of enforcing that. TODO Report this.
+    .field("generator", false, defaults["false"]);
+
+  def("ForOfStatement")
+    .build("left", "right", "body")
+    .field("left", or(
+      def("VariableDeclaration"),
+      def("Pattern")))
+    .field("right", def("Expression"))
+    .field("body", def("Statement"));
+
+  def("YieldExpression")
+    .bases("Expression")
+    .build("argument", "delegate")
+    .field("argument", or(def("Expression"), null))
+    .field("delegate", Boolean, defaults["false"]);
+
+  def("GeneratorExpression")
+    .bases("Expression")
+    .build("body", "blocks", "filter")
+    .field("body", def("Expression"))
+    .field("blocks", [def("ComprehensionBlock")])
+    .field("filter", or(def("Expression"), null));
+
+  def("ComprehensionExpression")
+    .bases("Expression")
+    .build("body", "blocks", "filter")
+    .field("body", def("Expression"))
+    .field("blocks", [def("ComprehensionBlock")])
+    .field("filter", or(def("Expression"), null));
+
+  def("ComprehensionBlock")
+    .bases("Node")
+    .build("left", "right", "each")
+    .field("left", def("Pattern"))
+    .field("right", def("Expression"))
+    .field("each", Boolean);
+
+  def("Property")
+    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
+    .field("value", or(def("Expression"), def("Pattern")))
+    .field("method", Boolean, defaults["false"])
+    .field("shorthand", Boolean, defaults["false"])
+    .field("computed", Boolean, defaults["false"]);
+
+  def("PropertyPattern")
+    .bases("Pattern")
+    .build("key", "pattern")
+    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
+    .field("pattern", def("Pattern"))
+    .field("computed", Boolean, defaults["false"]);
+
+  def("ObjectPattern")
+    .bases("Pattern")
+    .build("properties")
+    .field("properties", [or(def("PropertyPattern"), def("Property"))]);
+
+  def("ArrayPattern")
+    .bases("Pattern")
+    .build("elements")
+    .field("elements", [or(def("Pattern"), null)]);
+
+  def("MethodDefinition")
+    .bases("Declaration")
+    .build("kind", "key", "value", "static")
+    .field("kind", or("constructor", "method", "get", "set"))
+    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
+    .field("value", def("Function"))
+    .field("computed", Boolean, defaults["false"])
+    .field("static", Boolean, defaults["false"]);
+
+  def("SpreadElement")
+    .bases("Node")
+    .build("argument")
+    .field("argument", def("Expression"));
+
+  def("ArrayExpression")
+    .field("elements", [or(
+      def("Expression"),
+      def("SpreadElement"),
+      def("RestElement"),
+      null
+    )]);
+
+  def("NewExpression")
+    .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
+
+  def("CallExpression")
+    .field("arguments", [or(def("Expression"), def("SpreadElement"))]);
+
+  // Note: this node type is *not* an AssignmentExpression with a Pattern on
+  // the left-hand side! The existing AssignmentExpression type already
+  // supports destructuring assignments. AssignmentPattern nodes may appear
+  // wherever a Pattern is allowed, and the right-hand side represents a
+  // default value to be destructured against the left-hand side, if no
+  // value is otherwise provided. For example: default parameter values.
+  def("AssignmentPattern")
+    .bases("Pattern")
+    .build("left", "right")
+    .field("left", def("Pattern"))
+    .field("right", def("Expression"));
+
+  var ClassBodyElement = or(
+    def("MethodDefinition"),
+    def("VariableDeclarator"),
+    def("ClassPropertyDefinition"),
     def("ClassProperty")
-      .bases("Declaration")
-      .build("key")
-      .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
-      .field("computed", Boolean, defaults["false"]);
-
-    def("ClassPropertyDefinition") // static property
-      .bases("Declaration")
-      .build("definition")
-      // Yes, Virginia, circular definitions are permitted.
-      .field("definition", ClassBodyElement);
-
-    def("ClassBody")
-      .bases("Declaration")
-      .build("body")
-      .field("body", [ClassBodyElement]);
-
-    def("ClassDeclaration")
-      .bases("Declaration")
-      .build("id", "body", "superClass")
-      .field("id", or(def("Identifier"), null))
-      .field("body", def("ClassBody"))
-      .field("superClass", or(def("Expression"), null), defaults["null"]);
-
-    def("ClassExpression")
-      .bases("Expression")
-      .build("id", "body", "superClass")
-      .field("id", or(def("Identifier"), null), defaults["null"])
-      .field("body", def("ClassBody"))
-      .field("superClass", or(def("Expression"), null), defaults["null"])
-      .field("implements", [def("ClassImplements")], defaults.emptyArray);
-
-    def("ClassImplements")
-      .bases("Node")
-      .build("id")
-      .field("id", def("Identifier"))
-      .field("superClass", or(def("Expression"), null), defaults["null"]);
-
-    // Specifier and ModuleSpecifier are abstract non-standard types
-    // introduced for definitional convenience.
-    def("Specifier").bases("Node");
-
-    // This supertype is shared/abused by both def/babel.js and
-    // def/esprima.js. In the future, it will be possible to load only one set
-    // of definitions appropriate for a given parser, but until then we must
-    // rely on default functions to reconcile the conflicting AST formats.
-    def("ModuleSpecifier")
-      .bases("Specifier")
-      // This local field is used by Babel/Acorn. It should not technically
-      // be optional in the Babel/Acorn AST format, but it must be optional
-      // in the Esprima AST format.
-      .field("local", or(def("Identifier"), null), defaults["null"])
-      // The id and name fields are used by Esprima. The id field should not
-      // technically be optional in the Esprima AST format, but it must be
-      // optional in the Babel/Acorn AST format.
-      .field("id", or(def("Identifier"), null), defaults["null"])
-      .field("name", or(def("Identifier"), null), defaults["null"]);
-
-    def("TaggedTemplateExpression")
-      .bases("Expression")
-      .build("tag", "quasi")
-      .field("tag", def("Expression"))
-      .field("quasi", def("TemplateLiteral"));
-
-    def("TemplateLiteral")
-      .bases("Expression")
-      .build("quasis", "expressions")
-      .field("quasis", [def("TemplateElement")])
-      .field("expressions", [def("Expression")]);
-
-    def("TemplateElement")
-      .bases("Node")
-      .build("value", "tail")
-      .field("value", {"cooked": String, "raw": String})
-      .field("tail", Boolean);
+  );
+
+  def("ClassProperty")
+    .bases("Declaration")
+    .build("key")
+    .field("key", or(def("Literal"), def("Identifier"), def("Expression")))
+    .field("computed", Boolean, defaults["false"]);
+
+  def("ClassPropertyDefinition") // static property
+    .bases("Declaration")
+    .build("definition")
+    // Yes, Virginia, circular definitions are permitted.
+    .field("definition", ClassBodyElement);
+
+  def("ClassBody")
+    .bases("Declaration")
+    .build("body")
+    .field("body", [ClassBodyElement]);
+
+  def("ClassDeclaration")
+    .bases("Declaration")
+    .build("id", "body", "superClass")
+    .field("id", or(def("Identifier"), null))
+    .field("body", def("ClassBody"))
+    .field("superClass", or(def("Expression"), null), defaults["null"]);
+
+  def("ClassExpression")
+    .bases("Expression")
+    .build("id", "body", "superClass")
+    .field("id", or(def("Identifier"), null), defaults["null"])
+    .field("body", def("ClassBody"))
+    .field("superClass", or(def("Expression"), null), defaults["null"])
+    .field("implements", [def("ClassImplements")], defaults.emptyArray);
+
+  def("ClassImplements")
+    .bases("Node")
+    .build("id")
+    .field("id", def("Identifier"))
+    .field("superClass", or(def("Expression"), null), defaults["null"]);
+
+  // Specifier and ModuleSpecifier are abstract non-standard types
+  // introduced for definitional convenience.
+  def("Specifier").bases("Node");
+
+  // This supertype is shared/abused by both def/babel.js and
+  // def/esprima.js. In the future, it will be possible to load only one set
+  // of definitions appropriate for a given parser, but until then we must
+  // rely on default functions to reconcile the conflicting AST formats.
+  def("ModuleSpecifier")
+    .bases("Specifier")
+    // This local field is used by Babel/Acorn. It should not technically
+    // be optional in the Babel/Acorn AST format, but it must be optional
+    // in the Esprima AST format.
+    .field("local", or(def("Identifier"), null), defaults["null"])
+    // The id and name fields are used by Esprima. The id field should not
+    // technically be optional in the Esprima AST format, but it must be
+    // optional in the Babel/Acorn AST format.
+    .field("id", or(def("Identifier"), null), defaults["null"])
+    .field("name", or(def("Identifier"), null), defaults["null"]);
+
+  def("TaggedTemplateExpression")
+    .bases("Expression")
+    .build("tag", "quasi")
+    .field("tag", def("Expression"))
+    .field("quasi", def("TemplateLiteral"));
+
+  def("TemplateLiteral")
+    .bases("Expression")
+    .build("quasis", "expressions")
+    .field("quasis", [def("TemplateElement")])
+    .field("expressions", [def("Expression")]);
+
+  def("TemplateElement")
+    .bases("Node")
+    .build("value", "tail")
+    .field("value", {"cooked": String, "raw": String})
+    .field("tail", Boolean);
 };
diff --git a/def/flow.js b/def/flow.js
index 9302ab7..d2ac07c 100644
--- a/def/flow.js
+++ b/def/flow.js
@@ -35,6 +35,14 @@ module.exports = function (fork) {
       .field("value", Number)
       .field("raw", String);
 
+    // Babylon 6 differs in AST from Flow
+    // same as NumberLiteralTypeAnnotation
+    def("NumericLiteralTypeAnnotation")
+      .bases("Type")
+      .build("value", "raw")
+      .field("value", Number)
+      .field("raw", String);
+
     def("StringTypeAnnotation")
       .bases("Type")
       .build();
@@ -181,6 +189,9 @@ module.exports = function (fork) {
     def("Identifier")
       .field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
 
+    def("ObjectPattern")
+      .field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
+
     def("TypeParameterDeclaration")
       .bases("Node")
       .build("params")
diff --git a/def/jsx.js b/def/jsx.js
index 52656ce..2494eb2 100644
--- a/def/jsx.js
+++ b/def/jsx.js
@@ -1,103 +1,109 @@
 module.exports = function (fork) {
-    fork.use(require("./es7"));
+  fork.use(require("./es7"));
 
-    var types = fork.use(require("../lib/types"));
-    var def = types.Type.def;
-    var or = types.Type.or;
-    var defaults = fork.use(require("../lib/shared")).defaults;
+  var types = fork.use(require("../lib/types"));
+  var def = types.Type.def;
+  var or = types.Type.or;
+  var defaults = fork.use(require("../lib/shared")).defaults;
 
-    def("JSXAttribute")
-      .bases("Node")
-      .build("name", "value")
-      .field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
-      .field("value", or(
-        def("Literal"), // attr="value"
-        def("JSXExpressionContainer"), // attr={value}
-        null // attr= or just attr
-      ), defaults["null"]);
+  def("JSXAttribute")
+    .bases("Node")
+    .build("name", "value")
+    .field("name", or(def("JSXIdentifier"), def("JSXNamespacedName")))
+    .field("value", or(
+      def("Literal"), // attr="value"
+      def("JSXExpressionContainer"), // attr={value}
+      null // attr= or just attr
+    ), defaults["null"]);
 
-    def("JSXIdentifier")
-      .bases("Identifier")
-      .build("name")
-      .field("name", String);
+  def("JSXIdentifier")
+    .bases("Identifier")
+    .build("name")
+    .field("name", String);
 
-    def("JSXNamespacedName")
-      .bases("Node")
-      .build("namespace", "name")
-      .field("namespace", def("JSXIdentifier"))
-      .field("name", def("JSXIdentifier"));
+  def("JSXNamespacedName")
+    .bases("Node")
+    .build("namespace", "name")
+    .field("namespace", def("JSXIdentifier"))
+    .field("name", def("JSXIdentifier"));
 
+  def("JSXMemberExpression")
+    .bases("MemberExpression")
+    .build("object", "property")
+    .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
+    .field("property", def("JSXIdentifier"))
+    .field("computed", Boolean, defaults.false);
+
+  var JSXElementName = or(
+    def("JSXIdentifier"),
+    def("JSXNamespacedName"),
     def("JSXMemberExpression")
-      .bases("MemberExpression")
-      .build("object", "property")
-      .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression")))
-      .field("property", def("JSXIdentifier"))
-      .field("computed", Boolean, defaults.false);
+  );
 
-    var JSXElementName = or(
-      def("JSXIdentifier"),
-      def("JSXNamespacedName"),
-      def("JSXMemberExpression")
-    );
+  def("JSXSpreadAttribute")
+    .bases("Node")
+    .build("argument")
+    .field("argument", def("Expression"));
 
+  var JSXAttributes = [or(
+    def("JSXAttribute"),
     def("JSXSpreadAttribute")
-      .bases("Node")
-      .build("argument")
-      .field("argument", def("Expression"));
-
-    var JSXAttributes = [or(
-      def("JSXAttribute"),
-      def("JSXSpreadAttribute")
-    )];
+  )];
 
-    def("JSXExpressionContainer")
-      .bases("Expression")
-      .build("expression")
-      .field("expression", def("Expression"));
+  def("JSXExpressionContainer")
+    .bases("Expression")
+    .build("expression")
+    .field("expression", def("Expression"));
 
-    def("JSXElement")
-      .bases("Expression")
-      .build("openingElement", "closingElement", "children")
-      .field("openingElement", def("JSXOpeningElement"))
-      .field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
-      .field("children", [or(
-        def("JSXElement"),
-        def("JSXExpressionContainer"),
-        def("JSXText"),
-        def("Literal") // TODO Esprima should return JSXText instead.
-      )], defaults.emptyArray)
-      .field("name", JSXElementName, function () {
-          // Little-known fact: the `this` object inside a default function
-          // is none other than the partially-built object itself, and any
-          // fields initialized directly from builder function arguments
-          // (like openingElement, closingElement, and children) are
-          // guaranteed to be available.
-          return this.openingElement.name;
-      }, true) // hidden from traversal
-      .field("selfClosing", Boolean, function () {
-          return this.openingElement.selfClosing;
-      }, true) // hidden from traversal
-      .field("attributes", JSXAttributes, function () {
-          return this.openingElement.attributes;
-      }, true); // hidden from traversal
+  def("JSXElement")
+    .bases("Expression")
+    .build("openingElement", "closingElement", "children")
+    .field("openingElement", def("JSXOpeningElement"))
+    .field("closingElement", or(def("JSXClosingElement"), null), defaults["null"])
+    .field("children", [or(
+      def("JSXElement"),
+      def("JSXExpressionContainer"),
+      def("JSXText"),
+      def("Literal") // TODO Esprima should return JSXText instead.
+    )], defaults.emptyArray)
+    .field("name", JSXElementName, function () {
+      // Little-known fact: the `this` object inside a default function
+      // is none other than the partially-built object itself, and any
+      // fields initialized directly from builder function arguments
+      // (like openingElement, closingElement, and children) are
+      // guaranteed to be available.
+      return this.openingElement.name;
+    }, true) // hidden from traversal
+    .field("selfClosing", Boolean, function () {
+      return this.openingElement.selfClosing;
+    }, true) // hidden from traversal
+    .field("attributes", JSXAttributes, function () {
+      return this.openingElement.attributes;
+    }, true); // hidden from traversal
 
-    def("JSXOpeningElement")
-      .bases("Node") // TODO Does this make sense? Can't really be an JSXElement.
-      .build("name", "attributes", "selfClosing")
-      .field("name", JSXElementName)
-      .field("attributes", JSXAttributes, defaults.emptyArray)
-      .field("selfClosing", Boolean, defaults["false"]);
+  def("JSXOpeningElement")
+    .bases("Node") // TODO Does this make sense? Can't really be an JSXElement.
+    .build("name", "attributes", "selfClosing")
+    .field("name", JSXElementName)
+    .field("attributes", JSXAttributes, defaults.emptyArray)
+    .field("selfClosing", Boolean, defaults["false"]);
 
-    def("JSXClosingElement")
-      .bases("Node") // TODO Same concern.
-      .build("name")
-      .field("name", JSXElementName);
+  def("JSXClosingElement")
+    .bases("Node") // TODO Same concern.
+    .build("name")
+    .field("name", JSXElementName);
 
-    def("JSXText")
-      .bases("Literal")
-      .build("value")
-      .field("value", String);
+  def("JSXText")
+    .bases("Literal")
+    .build("value")
+    .field("value", String);
 
-    def("JSXEmptyExpression").bases("Expression").build();
+  def("JSXEmptyExpression").bases("Expression").build();
 
-};
\ No newline at end of file
+  // This PR has caused many people issues, but supporting it seems like a
+  // good idea anyway: https://github.com/babel/babel/pull/4988
+  def("JSXSpreadChild")
+    .bases("Expression")
+    .build("expression")
+    .field("expression", def("Expression"));
+};
diff --git a/def/mozilla.js b/def/mozilla.js
index 7636152..0978d8d 100644
--- a/def/mozilla.js
+++ b/def/mozilla.js
@@ -15,15 +15,6 @@ module.exports = function (fork) {
         .build("left", "right", "body", "each")
         .field("each", Boolean, defaults["false"]);
 
-    def("ForOfStatement")
-        .bases("Statement")
-        .build("left", "right", "body")
-        .field("left", or(
-            def("VariableDeclaration"),
-            def("Expression")))
-        .field("right", def("Expression"))
-        .field("body", def("Statement"));
-
     def("LetStatement")
         .bases("Statement")
         .build("head", "body")
diff --git a/package.json b/package.json
index be8d496..d3d8f61 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
     "transformation",
     "syntax"
   ],
-  "version": "0.9.5",
+  "version": "0.9.10",
   "homepage": "http://github.com/benjamn/ast-types",
   "repository": {
     "type": "git",
@@ -31,11 +31,13 @@
   },
   "dependencies": {},
   "devDependencies": {
-    "babel-core": "^5.6.15",
+    "babel-types": "^6.23.0",
+    "babylon": "^6.16.1",
     "espree": "^3.1.7",
-    "esprima": "~1.2.2",
+    "esprima": "~3.1.3",
     "esprima-fb": "~14001.1.0-dev-harmony-fb",
-    "mocha": "~3.1.1"
+    "mocha": "~3.2.0",
+    "reify": "^0.5.4"
   },
   "engines": {
     "node": ">= 0.8"
diff --git a/test/run.js b/test/run.js
index f039e19..d84bb4e 100644
--- a/test/run.js
+++ b/test/run.js
@@ -15,6 +15,13 @@ var rawTypes = types.use(require("../lib/types"));
 
 var hasOwn = Object.prototype.hasOwnProperty;
 
+var reifyBabylonParse = require("reify/lib/parsers/babylon.js").parse;
+function babylonParse(source) {
+    var ast = reifyBabylonParse(source);
+    if (ast.type === "File") ast = ast.program;
+    return ast;
+}
+
 describe("basic type checking", function() {
     var fooId = b.identifier("foo");
     var ifFoo = b.ifStatement(fooId, b.blockStatement([
@@ -203,11 +210,9 @@ function validateProgram(file) {
     });
 
     it("should validate " + file + " with Babel", function(done) {
-        var parse = require("babel-core").parse;
-
         fs.readFile(fullPath, "utf8", function(err, code) {
             if (err) throw err;
-            var ast = parse(code);
+            var ast = babylonParse(code);
             n.Program.assert(ast, true);
             done();
         });
@@ -237,7 +242,7 @@ describe("esprima Syntax types", function() {
     Object.keys(require("esprima").Syntax).forEach(addTypeName);
     Object.keys(require("esprima-fb").Syntax).forEach(addTypeName);
     Object.keys(
-        require("babel-core").types.VISITOR_KEYS
+        require("babel-types").VISITOR_KEYS
     ).forEach(addTypeName);
 
     it("should all be buildable", function() {
@@ -1119,7 +1124,7 @@ describe("scope methods", function () {
     });
 
     it("getBindings should work for import statements (acorn)", function() {
-        var ast = require("babel-core").parse([
+        var ast = babylonParse([
           "import {x, y as z} from 'xy';",
           "import xyDefault from 'xy';",
           "import * as xyNamespace from 'xy';"
@@ -2166,9 +2171,11 @@ describe("RegExpLiteral nodes", function() {
 
         var regex = types.getFieldValue(regExp, "regex");
 
+        regex.flags = regex.flags.split("").sort().join("");
+
         assert.deepEqual(regex, {
             pattern: "x*",
-            flags: "img"
+            flags: "gim"
         });
 
         types.Type.fromObject({

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ast-types.git



More information about the Pkg-javascript-commits mailing list