ast-types 0.9.8 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -4
- package/README.md +1 -6
- package/def/babel6-core.js +168 -0
- package/def/babel6.js +1 -166
- package/def/es6.js +225 -216
- package/def/flow.js +5 -0
- package/def/mozilla.js +0 -9
- package/package.json +3 -3
package/.travis.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
AST Types
|
|
2
|
-
===
|
|
3
|
-
|
|
4
|
-
[](https://greenkeeper.io/)
|
|
1
|
+
# AST Types [](https://travis-ci.org/benjamn/ast-types) [](https://greenkeeper.io/)
|
|
5
2
|
|
|
6
3
|
This module provides an efficient, modular,
|
|
7
4
|
[Esprima](https://github.com/ariya/esprima)-compatible implementation of
|
|
@@ -10,8 +7,6 @@ tree](http://en.wikipedia.org/wiki/Abstract_syntax_tree) type hierarchy
|
|
|
10
7
|
pioneered by the [Mozilla Parser
|
|
11
8
|
API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API).
|
|
12
9
|
|
|
13
|
-
[](https://travis-ci.org/benjamn/ast-types)
|
|
14
|
-
|
|
15
10
|
Installation
|
|
16
11
|
---
|
|
17
12
|
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
module.exports = function (fork) {
|
|
2
|
+
fork.use(require("./babel"));
|
|
3
|
+
|
|
4
|
+
// var types = fork.types;
|
|
5
|
+
var types = fork.use(require("../lib/types"));
|
|
6
|
+
// var defaults = fork.shared.defaults;
|
|
7
|
+
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
8
|
+
var def = types.Type.def;
|
|
9
|
+
var or = types.Type.or;
|
|
10
|
+
|
|
11
|
+
def("Directive")
|
|
12
|
+
.bases("Node")
|
|
13
|
+
.build("value")
|
|
14
|
+
.field("value", def("DirectiveLiteral"));
|
|
15
|
+
|
|
16
|
+
def("DirectiveLiteral")
|
|
17
|
+
.bases("Node", "Expression")
|
|
18
|
+
.build("value")
|
|
19
|
+
.field("value", String, defaults["use strict"]);
|
|
20
|
+
|
|
21
|
+
def("BlockStatement")
|
|
22
|
+
.bases("Statement")
|
|
23
|
+
.build("body")
|
|
24
|
+
.field("body", [def("Statement")])
|
|
25
|
+
.field("directives", [def("Directive")], defaults.emptyArray);
|
|
26
|
+
|
|
27
|
+
def("Program")
|
|
28
|
+
.bases("Node")
|
|
29
|
+
.build("body")
|
|
30
|
+
.field("body", [def("Statement")])
|
|
31
|
+
.field("directives", [def("Directive")], defaults.emptyArray);
|
|
32
|
+
|
|
33
|
+
// Split Literal
|
|
34
|
+
def("StringLiteral")
|
|
35
|
+
.bases("Literal")
|
|
36
|
+
.build("value")
|
|
37
|
+
.field("value", String);
|
|
38
|
+
|
|
39
|
+
def("NumericLiteral")
|
|
40
|
+
.bases("Literal")
|
|
41
|
+
.build("value")
|
|
42
|
+
.field("value", Number);
|
|
43
|
+
|
|
44
|
+
def("NullLiteral")
|
|
45
|
+
.bases("Literal")
|
|
46
|
+
.build()
|
|
47
|
+
.field("value", null, defaults["null"]);
|
|
48
|
+
|
|
49
|
+
def("BooleanLiteral")
|
|
50
|
+
.bases("Literal")
|
|
51
|
+
.build("value")
|
|
52
|
+
.field("value", Boolean);
|
|
53
|
+
|
|
54
|
+
def("RegExpLiteral")
|
|
55
|
+
.bases("Literal")
|
|
56
|
+
.build("pattern", "flags")
|
|
57
|
+
.field("pattern", String)
|
|
58
|
+
.field("flags", String)
|
|
59
|
+
.field("value", RegExp, function () {
|
|
60
|
+
return new RegExp(this.pattern, this.flags);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var ObjectExpressionProperty = or(
|
|
64
|
+
def("Property"),
|
|
65
|
+
def("ObjectMethod"),
|
|
66
|
+
def("ObjectProperty"),
|
|
67
|
+
def("SpreadProperty")
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Split Property -> ObjectProperty and ObjectMethod
|
|
71
|
+
def("ObjectExpression")
|
|
72
|
+
.bases("Expression")
|
|
73
|
+
.build("properties")
|
|
74
|
+
.field("properties", [ObjectExpressionProperty]);
|
|
75
|
+
|
|
76
|
+
// ObjectMethod hoist .value properties to own properties
|
|
77
|
+
def("ObjectMethod")
|
|
78
|
+
.bases("Node", "Function")
|
|
79
|
+
.build("kind", "key", "params", "body", "computed")
|
|
80
|
+
.field("kind", or("method", "get", "set"))
|
|
81
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
82
|
+
.field("params", [def("Pattern")])
|
|
83
|
+
.field("body", def("BlockStatement"))
|
|
84
|
+
.field("computed", Boolean, defaults["false"])
|
|
85
|
+
.field("generator", Boolean, defaults["false"])
|
|
86
|
+
.field("async", Boolean, defaults["false"])
|
|
87
|
+
.field("decorators",
|
|
88
|
+
or([def("Decorator")], null),
|
|
89
|
+
defaults["null"]);
|
|
90
|
+
|
|
91
|
+
def("ObjectProperty")
|
|
92
|
+
.bases("Node")
|
|
93
|
+
.build("key", "value")
|
|
94
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
95
|
+
.field("value", or(def("Expression"), def("Pattern")))
|
|
96
|
+
.field("computed", Boolean, defaults["false"]);
|
|
97
|
+
|
|
98
|
+
var ClassBodyElement = or(
|
|
99
|
+
def("MethodDefinition"),
|
|
100
|
+
def("VariableDeclarator"),
|
|
101
|
+
def("ClassPropertyDefinition"),
|
|
102
|
+
def("ClassProperty"),
|
|
103
|
+
def("ClassMethod")
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// MethodDefinition -> ClassMethod
|
|
107
|
+
def("ClassBody")
|
|
108
|
+
.bases("Declaration")
|
|
109
|
+
.build("body")
|
|
110
|
+
.field("body", [ClassBodyElement]);
|
|
111
|
+
|
|
112
|
+
def("ClassMethod")
|
|
113
|
+
.bases("Declaration", "Function")
|
|
114
|
+
.build("kind", "key", "params", "body", "computed", "static")
|
|
115
|
+
.field("kind", or("get", "set", "method", "constructor"))
|
|
116
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
117
|
+
.field("params", [def("Pattern")])
|
|
118
|
+
.field("body", def("BlockStatement"))
|
|
119
|
+
.field("computed", Boolean, defaults["false"])
|
|
120
|
+
.field("static", Boolean, defaults["false"])
|
|
121
|
+
.field("generator", Boolean, defaults["false"])
|
|
122
|
+
.field("async", Boolean, defaults["false"])
|
|
123
|
+
.field("decorators",
|
|
124
|
+
or([def("Decorator")], null),
|
|
125
|
+
defaults["null"]);
|
|
126
|
+
|
|
127
|
+
var ObjectPatternProperty = or(
|
|
128
|
+
def("Property"),
|
|
129
|
+
def("PropertyPattern"),
|
|
130
|
+
def("SpreadPropertyPattern"),
|
|
131
|
+
def("SpreadProperty"), // Used by Esprima
|
|
132
|
+
def("ObjectProperty"), // Babel 6
|
|
133
|
+
def("RestProperty") // Babel 6
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// Split into RestProperty and SpreadProperty
|
|
137
|
+
def("ObjectPattern")
|
|
138
|
+
.bases("Pattern")
|
|
139
|
+
.build("properties")
|
|
140
|
+
.field("properties", [ObjectPatternProperty])
|
|
141
|
+
.field("decorators",
|
|
142
|
+
or([def("Decorator")], null),
|
|
143
|
+
defaults["null"]);
|
|
144
|
+
|
|
145
|
+
def("SpreadProperty")
|
|
146
|
+
.bases("Node")
|
|
147
|
+
.build("argument")
|
|
148
|
+
.field("argument", def("Expression"));
|
|
149
|
+
|
|
150
|
+
def("RestProperty")
|
|
151
|
+
.bases("Node")
|
|
152
|
+
.build("argument")
|
|
153
|
+
.field("argument", def("Expression"));
|
|
154
|
+
|
|
155
|
+
def("ForAwaitStatement")
|
|
156
|
+
.bases("Statement")
|
|
157
|
+
.build("left", "right", "body")
|
|
158
|
+
.field("left", or(
|
|
159
|
+
def("VariableDeclaration"),
|
|
160
|
+
def("Expression")))
|
|
161
|
+
.field("right", def("Expression"))
|
|
162
|
+
.field("body", def("Statement"));
|
|
163
|
+
|
|
164
|
+
// The callee node of a dynamic import(...) expression.
|
|
165
|
+
def("Import")
|
|
166
|
+
.bases("Expression")
|
|
167
|
+
.build();
|
|
168
|
+
};
|
package/def/babel6.js
CHANGED
|
@@ -1,169 +1,4 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
|
-
fork.use(require("./
|
|
2
|
+
fork.use(require("./babel6-core"));
|
|
3
3
|
fork.use(require("./flow"));
|
|
4
|
-
|
|
5
|
-
// var types = fork.types;
|
|
6
|
-
var types = fork.use(require("../lib/types"));
|
|
7
|
-
// var defaults = fork.shared.defaults;
|
|
8
|
-
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
9
|
-
var def = types.Type.def;
|
|
10
|
-
var or = types.Type.or;
|
|
11
|
-
|
|
12
|
-
def("Directive")
|
|
13
|
-
.bases("Node")
|
|
14
|
-
.build("value")
|
|
15
|
-
.field("value", def("DirectiveLiteral"));
|
|
16
|
-
|
|
17
|
-
def("DirectiveLiteral")
|
|
18
|
-
.bases("Node", "Expression")
|
|
19
|
-
.build("value")
|
|
20
|
-
.field("value", String, defaults["use strict"]);
|
|
21
|
-
|
|
22
|
-
def("BlockStatement")
|
|
23
|
-
.bases("Statement")
|
|
24
|
-
.build("body")
|
|
25
|
-
.field("body", [def("Statement")])
|
|
26
|
-
.field("directives", [def("Directive")], defaults.emptyArray);
|
|
27
|
-
|
|
28
|
-
def("Program")
|
|
29
|
-
.bases("Node")
|
|
30
|
-
.build("body")
|
|
31
|
-
.field("body", [def("Statement")])
|
|
32
|
-
.field("directives", [def("Directive")], defaults.emptyArray);
|
|
33
|
-
|
|
34
|
-
// Split Literal
|
|
35
|
-
def("StringLiteral")
|
|
36
|
-
.bases("Literal")
|
|
37
|
-
.build("value")
|
|
38
|
-
.field("value", String);
|
|
39
|
-
|
|
40
|
-
def("NumericLiteral")
|
|
41
|
-
.bases("Literal")
|
|
42
|
-
.build("value")
|
|
43
|
-
.field("value", Number);
|
|
44
|
-
|
|
45
|
-
def("NullLiteral")
|
|
46
|
-
.bases("Literal")
|
|
47
|
-
.build()
|
|
48
|
-
.field("value", null, defaults["null"]);
|
|
49
|
-
|
|
50
|
-
def("BooleanLiteral")
|
|
51
|
-
.bases("Literal")
|
|
52
|
-
.build("value")
|
|
53
|
-
.field("value", Boolean);
|
|
54
|
-
|
|
55
|
-
def("RegExpLiteral")
|
|
56
|
-
.bases("Literal")
|
|
57
|
-
.build("pattern", "flags")
|
|
58
|
-
.field("pattern", String)
|
|
59
|
-
.field("flags", String)
|
|
60
|
-
.field("value", RegExp, function () {
|
|
61
|
-
return new RegExp(this.pattern, this.flags);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
var ObjectExpressionProperty = or(
|
|
65
|
-
def("Property"),
|
|
66
|
-
def("ObjectMethod"),
|
|
67
|
-
def("ObjectProperty"),
|
|
68
|
-
def("SpreadProperty")
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// Split Property -> ObjectProperty and ObjectMethod
|
|
72
|
-
def("ObjectExpression")
|
|
73
|
-
.bases("Expression")
|
|
74
|
-
.build("properties")
|
|
75
|
-
.field("properties", [ObjectExpressionProperty]);
|
|
76
|
-
|
|
77
|
-
// ObjectMethod hoist .value properties to own properties
|
|
78
|
-
def("ObjectMethod")
|
|
79
|
-
.bases("Node", "Function")
|
|
80
|
-
.build("kind", "key", "params", "body", "computed")
|
|
81
|
-
.field("kind", or("method", "get", "set"))
|
|
82
|
-
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
83
|
-
.field("params", [def("Pattern")])
|
|
84
|
-
.field("body", def("BlockStatement"))
|
|
85
|
-
.field("computed", Boolean, defaults["false"])
|
|
86
|
-
.field("generator", Boolean, defaults["false"])
|
|
87
|
-
.field("async", Boolean, defaults["false"])
|
|
88
|
-
.field("decorators",
|
|
89
|
-
or([def("Decorator")], null),
|
|
90
|
-
defaults["null"]);
|
|
91
|
-
|
|
92
|
-
def("ObjectProperty")
|
|
93
|
-
.bases("Node")
|
|
94
|
-
.build("key", "value")
|
|
95
|
-
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
96
|
-
.field("value", or(def("Expression"), def("Pattern")))
|
|
97
|
-
.field("computed", Boolean, defaults["false"]);
|
|
98
|
-
|
|
99
|
-
var ClassBodyElement = or(
|
|
100
|
-
def("MethodDefinition"),
|
|
101
|
-
def("VariableDeclarator"),
|
|
102
|
-
def("ClassPropertyDefinition"),
|
|
103
|
-
def("ClassProperty"),
|
|
104
|
-
def("ClassMethod")
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// MethodDefinition -> ClassMethod
|
|
108
|
-
def("ClassBody")
|
|
109
|
-
.bases("Declaration")
|
|
110
|
-
.build("body")
|
|
111
|
-
.field("body", [ClassBodyElement]);
|
|
112
|
-
|
|
113
|
-
def("ClassMethod")
|
|
114
|
-
.bases("Declaration", "Function")
|
|
115
|
-
.build("kind", "key", "params", "body", "computed", "static")
|
|
116
|
-
.field("kind", or("get", "set", "method", "constructor"))
|
|
117
|
-
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
118
|
-
.field("params", [def("Pattern")])
|
|
119
|
-
.field("body", def("BlockStatement"))
|
|
120
|
-
.field("computed", Boolean, defaults["false"])
|
|
121
|
-
.field("static", Boolean, defaults["false"])
|
|
122
|
-
.field("generator", Boolean, defaults["false"])
|
|
123
|
-
.field("async", Boolean, defaults["false"])
|
|
124
|
-
.field("decorators",
|
|
125
|
-
or([def("Decorator")], null),
|
|
126
|
-
defaults["null"]);
|
|
127
|
-
|
|
128
|
-
var ObjectPatternProperty = or(
|
|
129
|
-
def("Property"),
|
|
130
|
-
def("PropertyPattern"),
|
|
131
|
-
def("SpreadPropertyPattern"),
|
|
132
|
-
def("SpreadProperty"), // Used by Esprima
|
|
133
|
-
def("ObjectProperty"), // Babel 6
|
|
134
|
-
def("RestProperty") // Babel 6
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
// Split into RestProperty and SpreadProperty
|
|
138
|
-
def("ObjectPattern")
|
|
139
|
-
.bases("Pattern")
|
|
140
|
-
.build("properties")
|
|
141
|
-
.field("properties", [ObjectPatternProperty])
|
|
142
|
-
.field("decorators",
|
|
143
|
-
or([def("Decorator")], null),
|
|
144
|
-
defaults["null"]);
|
|
145
|
-
|
|
146
|
-
def("SpreadProperty")
|
|
147
|
-
.bases("Node")
|
|
148
|
-
.build("argument")
|
|
149
|
-
.field("argument", def("Expression"));
|
|
150
|
-
|
|
151
|
-
def("RestProperty")
|
|
152
|
-
.bases("Node")
|
|
153
|
-
.build("argument")
|
|
154
|
-
.field("argument", def("Expression"));
|
|
155
|
-
|
|
156
|
-
def("ForAwaitStatement")
|
|
157
|
-
.bases("Statement")
|
|
158
|
-
.build("left", "right", "body")
|
|
159
|
-
.field("left", or(
|
|
160
|
-
def("VariableDeclaration"),
|
|
161
|
-
def("Expression")))
|
|
162
|
-
.field("right", def("Expression"))
|
|
163
|
-
.field("body", def("Statement"));
|
|
164
|
-
|
|
165
|
-
// The callee node of a dynamic import(...) expression.
|
|
166
|
-
def("Import")
|
|
167
|
-
.bases("Expression")
|
|
168
|
-
.build();
|
|
169
4
|
};
|
package/def/es6.js
CHANGED
|
@@ -1,219 +1,228 @@
|
|
|
1
1
|
module.exports = function (fork) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def("
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def("
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def("
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def("
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def("
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
)
|
|
143
|
-
|
|
2
|
+
fork.use(require("./core"));
|
|
3
|
+
var types = fork.use(require("../lib/types"));
|
|
4
|
+
var def = types.Type.def;
|
|
5
|
+
var or = types.Type.or;
|
|
6
|
+
var defaults = fork.use(require("../lib/shared")).defaults;
|
|
7
|
+
|
|
8
|
+
def("Function")
|
|
9
|
+
.field("generator", Boolean, defaults["false"])
|
|
10
|
+
.field("expression", Boolean, defaults["false"])
|
|
11
|
+
.field("defaults", [or(def("Expression"), null)], defaults.emptyArray)
|
|
12
|
+
// TODO This could be represented as a RestElement in .params.
|
|
13
|
+
.field("rest", or(def("Identifier"), null), defaults["null"]);
|
|
14
|
+
|
|
15
|
+
// The ESTree way of representing a ...rest parameter.
|
|
16
|
+
def("RestElement")
|
|
17
|
+
.bases("Pattern")
|
|
18
|
+
.build("argument")
|
|
19
|
+
.field("argument", def("Pattern"));
|
|
20
|
+
|
|
21
|
+
def("SpreadElementPattern")
|
|
22
|
+
.bases("Pattern")
|
|
23
|
+
.build("argument")
|
|
24
|
+
.field("argument", def("Pattern"));
|
|
25
|
+
|
|
26
|
+
def("FunctionDeclaration")
|
|
27
|
+
.build("id", "params", "body", "generator", "expression");
|
|
28
|
+
|
|
29
|
+
def("FunctionExpression")
|
|
30
|
+
.build("id", "params", "body", "generator", "expression");
|
|
31
|
+
|
|
32
|
+
// The Parser API calls this ArrowExpression, but Esprima and all other
|
|
33
|
+
// actual parsers use ArrowFunctionExpression.
|
|
34
|
+
def("ArrowFunctionExpression")
|
|
35
|
+
.bases("Function", "Expression")
|
|
36
|
+
.build("params", "body", "expression")
|
|
37
|
+
// The forced null value here is compatible with the overridden
|
|
38
|
+
// definition of the "id" field in the Function interface.
|
|
39
|
+
.field("id", null, defaults["null"])
|
|
40
|
+
// Arrow function bodies are allowed to be expressions.
|
|
41
|
+
.field("body", or(def("BlockStatement"), def("Expression")))
|
|
42
|
+
// The current spec forbids arrow generators, so I have taken the
|
|
43
|
+
// liberty of enforcing that. TODO Report this.
|
|
44
|
+
.field("generator", false, defaults["false"]);
|
|
45
|
+
|
|
46
|
+
def("ForOfStatement")
|
|
47
|
+
.bases("Statement")
|
|
48
|
+
.build("left", "right", "body")
|
|
49
|
+
.field("left", or(
|
|
50
|
+
def("VariableDeclaration"),
|
|
51
|
+
def("Pattern")))
|
|
52
|
+
.field("right", def("Expression"))
|
|
53
|
+
.field("body", def("Statement"));
|
|
54
|
+
|
|
55
|
+
def("YieldExpression")
|
|
56
|
+
.bases("Expression")
|
|
57
|
+
.build("argument", "delegate")
|
|
58
|
+
.field("argument", or(def("Expression"), null))
|
|
59
|
+
.field("delegate", Boolean, defaults["false"]);
|
|
60
|
+
|
|
61
|
+
def("GeneratorExpression")
|
|
62
|
+
.bases("Expression")
|
|
63
|
+
.build("body", "blocks", "filter")
|
|
64
|
+
.field("body", def("Expression"))
|
|
65
|
+
.field("blocks", [def("ComprehensionBlock")])
|
|
66
|
+
.field("filter", or(def("Expression"), null));
|
|
67
|
+
|
|
68
|
+
def("ComprehensionExpression")
|
|
69
|
+
.bases("Expression")
|
|
70
|
+
.build("body", "blocks", "filter")
|
|
71
|
+
.field("body", def("Expression"))
|
|
72
|
+
.field("blocks", [def("ComprehensionBlock")])
|
|
73
|
+
.field("filter", or(def("Expression"), null));
|
|
74
|
+
|
|
75
|
+
def("ComprehensionBlock")
|
|
76
|
+
.bases("Node")
|
|
77
|
+
.build("left", "right", "each")
|
|
78
|
+
.field("left", def("Pattern"))
|
|
79
|
+
.field("right", def("Expression"))
|
|
80
|
+
.field("each", Boolean);
|
|
81
|
+
|
|
82
|
+
def("Property")
|
|
83
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
84
|
+
.field("value", or(def("Expression"), def("Pattern")))
|
|
85
|
+
.field("method", Boolean, defaults["false"])
|
|
86
|
+
.field("shorthand", Boolean, defaults["false"])
|
|
87
|
+
.field("computed", Boolean, defaults["false"]);
|
|
88
|
+
|
|
89
|
+
def("PropertyPattern")
|
|
90
|
+
.bases("Pattern")
|
|
91
|
+
.build("key", "pattern")
|
|
92
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
93
|
+
.field("pattern", def("Pattern"))
|
|
94
|
+
.field("computed", Boolean, defaults["false"]);
|
|
95
|
+
|
|
96
|
+
def("ObjectPattern")
|
|
97
|
+
.bases("Pattern")
|
|
98
|
+
.build("properties")
|
|
99
|
+
.field("properties", [or(def("PropertyPattern"), def("Property"))]);
|
|
100
|
+
|
|
101
|
+
def("ArrayPattern")
|
|
102
|
+
.bases("Pattern")
|
|
103
|
+
.build("elements")
|
|
104
|
+
.field("elements", [or(def("Pattern"), null)]);
|
|
105
|
+
|
|
106
|
+
def("MethodDefinition")
|
|
107
|
+
.bases("Declaration")
|
|
108
|
+
.build("kind", "key", "value", "static")
|
|
109
|
+
.field("kind", or("constructor", "method", "get", "set"))
|
|
110
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
111
|
+
.field("value", def("Function"))
|
|
112
|
+
.field("computed", Boolean, defaults["false"])
|
|
113
|
+
.field("static", Boolean, defaults["false"]);
|
|
114
|
+
|
|
115
|
+
def("SpreadElement")
|
|
116
|
+
.bases("Node")
|
|
117
|
+
.build("argument")
|
|
118
|
+
.field("argument", def("Expression"));
|
|
119
|
+
|
|
120
|
+
def("ArrayExpression")
|
|
121
|
+
.field("elements", [or(
|
|
122
|
+
def("Expression"),
|
|
123
|
+
def("SpreadElement"),
|
|
124
|
+
def("RestElement"),
|
|
125
|
+
null
|
|
126
|
+
)]);
|
|
127
|
+
|
|
128
|
+
def("NewExpression")
|
|
129
|
+
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
|
|
130
|
+
|
|
131
|
+
def("CallExpression")
|
|
132
|
+
.field("arguments", [or(def("Expression"), def("SpreadElement"))]);
|
|
133
|
+
|
|
134
|
+
// Note: this node type is *not* an AssignmentExpression with a Pattern on
|
|
135
|
+
// the left-hand side! The existing AssignmentExpression type already
|
|
136
|
+
// supports destructuring assignments. AssignmentPattern nodes may appear
|
|
137
|
+
// wherever a Pattern is allowed, and the right-hand side represents a
|
|
138
|
+
// default value to be destructured against the left-hand side, if no
|
|
139
|
+
// value is otherwise provided. For example: default parameter values.
|
|
140
|
+
def("AssignmentPattern")
|
|
141
|
+
.bases("Pattern")
|
|
142
|
+
.build("left", "right")
|
|
143
|
+
.field("left", def("Pattern"))
|
|
144
|
+
.field("right", def("Expression"));
|
|
145
|
+
|
|
146
|
+
var ClassBodyElement = or(
|
|
147
|
+
def("MethodDefinition"),
|
|
148
|
+
def("VariableDeclarator"),
|
|
149
|
+
def("ClassPropertyDefinition"),
|
|
144
150
|
def("ClassProperty")
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def("
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
def("
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def("
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def("
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def("
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def("TemplateElement")
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
def("ClassProperty")
|
|
154
|
+
.bases("Declaration")
|
|
155
|
+
.build("key")
|
|
156
|
+
.field("key", or(def("Literal"), def("Identifier"), def("Expression")))
|
|
157
|
+
.field("computed", Boolean, defaults["false"]);
|
|
158
|
+
|
|
159
|
+
def("ClassPropertyDefinition") // static property
|
|
160
|
+
.bases("Declaration")
|
|
161
|
+
.build("definition")
|
|
162
|
+
// Yes, Virginia, circular definitions are permitted.
|
|
163
|
+
.field("definition", ClassBodyElement);
|
|
164
|
+
|
|
165
|
+
def("ClassBody")
|
|
166
|
+
.bases("Declaration")
|
|
167
|
+
.build("body")
|
|
168
|
+
.field("body", [ClassBodyElement]);
|
|
169
|
+
|
|
170
|
+
def("ClassDeclaration")
|
|
171
|
+
.bases("Declaration")
|
|
172
|
+
.build("id", "body", "superClass")
|
|
173
|
+
.field("id", or(def("Identifier"), null))
|
|
174
|
+
.field("body", def("ClassBody"))
|
|
175
|
+
.field("superClass", or(def("Expression"), null), defaults["null"]);
|
|
176
|
+
|
|
177
|
+
def("ClassExpression")
|
|
178
|
+
.bases("Expression")
|
|
179
|
+
.build("id", "body", "superClass")
|
|
180
|
+
.field("id", or(def("Identifier"), null), defaults["null"])
|
|
181
|
+
.field("body", def("ClassBody"))
|
|
182
|
+
.field("superClass", or(def("Expression"), null), defaults["null"])
|
|
183
|
+
.field("implements", [def("ClassImplements")], defaults.emptyArray);
|
|
184
|
+
|
|
185
|
+
def("ClassImplements")
|
|
186
|
+
.bases("Node")
|
|
187
|
+
.build("id")
|
|
188
|
+
.field("id", def("Identifier"))
|
|
189
|
+
.field("superClass", or(def("Expression"), null), defaults["null"]);
|
|
190
|
+
|
|
191
|
+
// Specifier and ModuleSpecifier are abstract non-standard types
|
|
192
|
+
// introduced for definitional convenience.
|
|
193
|
+
def("Specifier").bases("Node");
|
|
194
|
+
|
|
195
|
+
// This supertype is shared/abused by both def/babel.js and
|
|
196
|
+
// def/esprima.js. In the future, it will be possible to load only one set
|
|
197
|
+
// of definitions appropriate for a given parser, but until then we must
|
|
198
|
+
// rely on default functions to reconcile the conflicting AST formats.
|
|
199
|
+
def("ModuleSpecifier")
|
|
200
|
+
.bases("Specifier")
|
|
201
|
+
// This local field is used by Babel/Acorn. It should not technically
|
|
202
|
+
// be optional in the Babel/Acorn AST format, but it must be optional
|
|
203
|
+
// in the Esprima AST format.
|
|
204
|
+
.field("local", or(def("Identifier"), null), defaults["null"])
|
|
205
|
+
// The id and name fields are used by Esprima. The id field should not
|
|
206
|
+
// technically be optional in the Esprima AST format, but it must be
|
|
207
|
+
// optional in the Babel/Acorn AST format.
|
|
208
|
+
.field("id", or(def("Identifier"), null), defaults["null"])
|
|
209
|
+
.field("name", or(def("Identifier"), null), defaults["null"]);
|
|
210
|
+
|
|
211
|
+
def("TaggedTemplateExpression")
|
|
212
|
+
.bases("Expression")
|
|
213
|
+
.build("tag", "quasi")
|
|
214
|
+
.field("tag", def("Expression"))
|
|
215
|
+
.field("quasi", def("TemplateLiteral"));
|
|
216
|
+
|
|
217
|
+
def("TemplateLiteral")
|
|
218
|
+
.bases("Expression")
|
|
219
|
+
.build("quasis", "expressions")
|
|
220
|
+
.field("quasis", [def("TemplateElement")])
|
|
221
|
+
.field("expressions", [def("Expression")]);
|
|
222
|
+
|
|
223
|
+
def("TemplateElement")
|
|
224
|
+
.bases("Node")
|
|
225
|
+
.build("value", "tail")
|
|
226
|
+
.field("value", {"cooked": String, "raw": String})
|
|
227
|
+
.field("tail", Boolean);
|
|
219
228
|
};
|
package/def/flow.js
CHANGED
|
@@ -186,6 +186,11 @@ module.exports = function (fork) {
|
|
|
186
186
|
.build("argument")
|
|
187
187
|
.field("argument", def("Type"));
|
|
188
188
|
|
|
189
|
+
def("ObjectTypeSpreadProperty")
|
|
190
|
+
.bases("Node")
|
|
191
|
+
.build("argument")
|
|
192
|
+
.field("argument", def("Type"));
|
|
193
|
+
|
|
189
194
|
def("Identifier")
|
|
190
195
|
.field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]);
|
|
191
196
|
|
package/def/mozilla.js
CHANGED
|
@@ -15,15 +15,6 @@ module.exports = function (fork) {
|
|
|
15
15
|
.build("left", "right", "body", "each")
|
|
16
16
|
.field("each", Boolean, defaults["false"]);
|
|
17
17
|
|
|
18
|
-
def("ForOfStatement")
|
|
19
|
-
.bases("Statement")
|
|
20
|
-
.build("left", "right", "body")
|
|
21
|
-
.field("left", or(
|
|
22
|
-
def("VariableDeclaration"),
|
|
23
|
-
def("Expression")))
|
|
24
|
-
.field("right", def("Expression"))
|
|
25
|
-
.field("body", def("Statement"));
|
|
26
|
-
|
|
27
18
|
def("LetStatement")
|
|
28
19
|
.bases("Statement")
|
|
29
20
|
.build("head", "body")
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"transformation",
|
|
19
19
|
"syntax"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.9.
|
|
21
|
+
"version": "0.9.12",
|
|
22
22
|
"homepage": "http://github.com/benjamn/ast-types",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"espree": "^3.1.7",
|
|
37
37
|
"esprima": "~3.1.3",
|
|
38
38
|
"esprima-fb": "~14001.1.0-dev-harmony-fb",
|
|
39
|
-
"mocha": "
|
|
40
|
-
"reify": "^0.
|
|
39
|
+
"mocha": "^3.4.2",
|
|
40
|
+
"reify": "^0.11.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">= 0.8"
|