react-source 0.12.0 → 0.12.1
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.
- checksums.yaml +4 -4
- data/build/JSXTransformer.js +1855 -514
- data/build/react-with-addons.js +5 -5
- data/build/react-with-addons.min.js +2 -2
- data/build/react.js +5 -5
- data/build/react.min.js +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa1a6d2925d5de095fe0d1fcc6702e56ff059d45
|
4
|
+
data.tar.gz: 96a3891b4b204b2e38cb50a51734b1d7f1b70d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc811dcee07910f37aac51e89f026845a27cc04ceff50004a7be2d01f92c9d08623681c8e581c858315c744cbdb26ef62c799bc7e335306150544277d2916c17
|
7
|
+
data.tar.gz: 3e1b96471312ce78666c510cb7bf7138b3be53bb52771193bb2cc4caba986c8f780c9e9a8c4213ac0cd20c7c7a687b03bd976e0946c809d145f5cbee3e6803e6
|
data/build/JSXTransformer.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* JSXTransformer v0.12.
|
2
|
+
* JSXTransformer v0.12.1
|
3
3
|
*/
|
4
4
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
5
5
|
/**
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
var buffer = _dereq_('buffer');
|
19
19
|
var transform = _dereq_('jstransform').transform;
|
20
|
+
var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
|
20
21
|
var visitors = _dereq_('./fbtransform/visitors');
|
21
22
|
|
22
23
|
var headEl;
|
@@ -46,6 +47,14 @@ function transformReact(source, options) {
|
|
46
47
|
visitorList = visitors.transformVisitors.react;
|
47
48
|
}
|
48
49
|
|
50
|
+
if (options.stripTypes) {
|
51
|
+
// Stripping types needs to happen before the other transforms
|
52
|
+
// unfortunately, due to bad interactions. For example,
|
53
|
+
// es6-rest-param-visitors conflict with stripping rest param type
|
54
|
+
// annotation
|
55
|
+
source = transform(typesSyntax.visitorList, source, options).code;
|
56
|
+
}
|
57
|
+
|
49
58
|
return transform(visitorList, source, {
|
50
59
|
sourceMap: supportsAccessors && options.sourceMap
|
51
60
|
});
|
@@ -244,6 +253,9 @@ function loadScripts(scripts) {
|
|
244
253
|
if (/;harmony=true(;|$)/.test(script.type)) {
|
245
254
|
options.harmony = true
|
246
255
|
}
|
256
|
+
if (/;stripTypes=true(;|$)/.test(script.type)) {
|
257
|
+
options.stripTypes = true;
|
258
|
+
}
|
247
259
|
|
248
260
|
// script.async is always true for non-javascript script tags
|
249
261
|
var async = script.hasAttribute('async');
|
@@ -330,7 +342,7 @@ module.exports = {
|
|
330
342
|
exec: exec
|
331
343
|
};
|
332
344
|
|
333
|
-
},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21}],2:[function(_dereq_,module,exports){
|
345
|
+
},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21,"jstransform/visitors/type-syntax":33}],2:[function(_dereq_,module,exports){
|
334
346
|
/*!
|
335
347
|
* The buffer module from node.js, for the browser.
|
336
348
|
*
|
@@ -1170,7 +1182,7 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
1170
1182
|
|
1171
1183
|
var len = end - start
|
1172
1184
|
|
1173
|
-
if (len <
|
1185
|
+
if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
1174
1186
|
for (var i = 0; i < len; i++) {
|
1175
1187
|
target[i + target_start] = this[i + start]
|
1176
1188
|
}
|
@@ -1239,6 +1251,7 @@ var BP = Buffer.prototype
|
|
1239
1251
|
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
1240
1252
|
*/
|
1241
1253
|
Buffer._augment = function (arr) {
|
1254
|
+
arr.constructor = Buffer
|
1242
1255
|
arr._isBuffer = true
|
1243
1256
|
|
1244
1257
|
// save reference to original Uint8Array get/set methods before overwriting
|
@@ -1942,6 +1955,34 @@ process.chdir = function (dir) {
|
|
1942
1955
|
};
|
1943
1956
|
|
1944
1957
|
},{}],8:[function(_dereq_,module,exports){
|
1958
|
+
var Base62 = (function (my) {
|
1959
|
+
my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
|
1960
|
+
|
1961
|
+
my.encode = function(i){
|
1962
|
+
if (i === 0) {return '0'}
|
1963
|
+
var s = ''
|
1964
|
+
while (i > 0) {
|
1965
|
+
s = this.chars[i % 62] + s
|
1966
|
+
i = Math.floor(i/62)
|
1967
|
+
}
|
1968
|
+
return s
|
1969
|
+
};
|
1970
|
+
my.decode = function(a,b,c,d){
|
1971
|
+
for (
|
1972
|
+
b = c = (
|
1973
|
+
a === (/\W|_|^$/.test(a += "") || a)
|
1974
|
+
) - 1;
|
1975
|
+
d = a.charCodeAt(c++);
|
1976
|
+
)
|
1977
|
+
b = b * 62 + d - [, 48, 29, 87][d >> 5];
|
1978
|
+
return b
|
1979
|
+
};
|
1980
|
+
|
1981
|
+
return my;
|
1982
|
+
}({}));
|
1983
|
+
|
1984
|
+
module.exports = Base62
|
1985
|
+
},{}],9:[function(_dereq_,module,exports){
|
1945
1986
|
/*
|
1946
1987
|
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
1947
1988
|
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
@@ -1979,18 +2020,23 @@ process.chdir = function (dir) {
|
|
1979
2020
|
throwError: true, generateStatement: true, peek: true,
|
1980
2021
|
parseAssignmentExpression: true, parseBlock: true,
|
1981
2022
|
parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
|
2023
|
+
parseDeclareClass: true, parseDeclareFunction: true,
|
2024
|
+
parseDeclareModule: true, parseDeclareVariable: true,
|
1982
2025
|
parseForStatement: true,
|
1983
2026
|
parseFunctionDeclaration: true, parseFunctionExpression: true,
|
1984
2027
|
parseFunctionSourceElements: true, parseVariableIdentifier: true,
|
1985
|
-
parseImportSpecifier: true,
|
2028
|
+
parseImportSpecifier: true, parseInterface: true,
|
1986
2029
|
parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
|
1987
2030
|
parseSpreadOrAssignmentExpression: true,
|
1988
|
-
parseStatement: true, parseSourceElement: true,
|
2031
|
+
parseStatement: true, parseSourceElement: true, parseConciseBody: true,
|
1989
2032
|
advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
|
1990
2033
|
scanXJSStringLiteral: true, scanXJSIdentifier: true,
|
1991
2034
|
parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
|
1992
|
-
|
1993
|
-
|
2035
|
+
parseFunctionTypeParam: true,
|
2036
|
+
parsePrimaryType: true,
|
2037
|
+
parseTypeAlias: true,
|
2038
|
+
parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
|
2039
|
+
parseYieldExpression: true, parseAwaitExpression: true
|
1994
2040
|
*/
|
1995
2041
|
|
1996
2042
|
(function (root, factory) {
|
@@ -2069,24 +2115,32 @@ parseYieldExpression: true
|
|
2069
2115
|
'<=', '<', '>', '!=', '!=='];
|
2070
2116
|
|
2071
2117
|
Syntax = {
|
2118
|
+
AnyTypeAnnotation: 'AnyTypeAnnotation',
|
2072
2119
|
ArrayExpression: 'ArrayExpression',
|
2073
2120
|
ArrayPattern: 'ArrayPattern',
|
2121
|
+
ArrayTypeAnnotation: 'ArrayTypeAnnotation',
|
2074
2122
|
ArrowFunctionExpression: 'ArrowFunctionExpression',
|
2075
2123
|
AssignmentExpression: 'AssignmentExpression',
|
2076
2124
|
BinaryExpression: 'BinaryExpression',
|
2077
2125
|
BlockStatement: 'BlockStatement',
|
2126
|
+
BooleanTypeAnnotation: 'BooleanTypeAnnotation',
|
2078
2127
|
BreakStatement: 'BreakStatement',
|
2079
2128
|
CallExpression: 'CallExpression',
|
2080
2129
|
CatchClause: 'CatchClause',
|
2081
2130
|
ClassBody: 'ClassBody',
|
2082
2131
|
ClassDeclaration: 'ClassDeclaration',
|
2083
2132
|
ClassExpression: 'ClassExpression',
|
2133
|
+
ClassImplements: 'ClassImplements',
|
2084
2134
|
ClassProperty: 'ClassProperty',
|
2085
2135
|
ComprehensionBlock: 'ComprehensionBlock',
|
2086
2136
|
ComprehensionExpression: 'ComprehensionExpression',
|
2087
2137
|
ConditionalExpression: 'ConditionalExpression',
|
2088
2138
|
ContinueStatement: 'ContinueStatement',
|
2089
2139
|
DebuggerStatement: 'DebuggerStatement',
|
2140
|
+
DeclareClass: 'DeclareClass',
|
2141
|
+
DeclareFunction: 'DeclareFunction',
|
2142
|
+
DeclareModule: 'DeclareModule',
|
2143
|
+
DeclareVariable: 'DeclareVariable',
|
2090
2144
|
DoWhileStatement: 'DoWhileStatement',
|
2091
2145
|
EmptyStatement: 'EmptyStatement',
|
2092
2146
|
ExportDeclaration: 'ExportDeclaration',
|
@@ -2098,29 +2152,42 @@ parseYieldExpression: true
|
|
2098
2152
|
ForStatement: 'ForStatement',
|
2099
2153
|
FunctionDeclaration: 'FunctionDeclaration',
|
2100
2154
|
FunctionExpression: 'FunctionExpression',
|
2155
|
+
FunctionTypeAnnotation: 'FunctionTypeAnnotation',
|
2156
|
+
FunctionTypeParam: 'FunctionTypeParam',
|
2157
|
+
GenericTypeAnnotation: 'GenericTypeAnnotation',
|
2101
2158
|
Identifier: 'Identifier',
|
2102
2159
|
IfStatement: 'IfStatement',
|
2103
2160
|
ImportDeclaration: 'ImportDeclaration',
|
2161
|
+
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
2162
|
+
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
2104
2163
|
ImportSpecifier: 'ImportSpecifier',
|
2164
|
+
InterfaceDeclaration: 'InterfaceDeclaration',
|
2165
|
+
InterfaceExtends: 'InterfaceExtends',
|
2166
|
+
IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
|
2105
2167
|
LabeledStatement: 'LabeledStatement',
|
2106
2168
|
Literal: 'Literal',
|
2107
2169
|
LogicalExpression: 'LogicalExpression',
|
2108
2170
|
MemberExpression: 'MemberExpression',
|
2109
2171
|
MethodDefinition: 'MethodDefinition',
|
2110
|
-
|
2172
|
+
ModuleSpecifier: 'ModuleSpecifier',
|
2111
2173
|
NewExpression: 'NewExpression',
|
2174
|
+
NullableTypeAnnotation: 'NullableTypeAnnotation',
|
2175
|
+
NumberTypeAnnotation: 'NumberTypeAnnotation',
|
2112
2176
|
ObjectExpression: 'ObjectExpression',
|
2113
2177
|
ObjectPattern: 'ObjectPattern',
|
2114
2178
|
ObjectTypeAnnotation: 'ObjectTypeAnnotation',
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2179
|
+
ObjectTypeCallProperty: 'ObjectTypeCallProperty',
|
2180
|
+
ObjectTypeIndexer: 'ObjectTypeIndexer',
|
2181
|
+
ObjectTypeProperty: 'ObjectTypeProperty',
|
2118
2182
|
Program: 'Program',
|
2119
2183
|
Property: 'Property',
|
2184
|
+
QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
|
2120
2185
|
ReturnStatement: 'ReturnStatement',
|
2121
2186
|
SequenceExpression: 'SequenceExpression',
|
2122
2187
|
SpreadElement: 'SpreadElement',
|
2123
2188
|
SpreadProperty: 'SpreadProperty',
|
2189
|
+
StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
|
2190
|
+
StringTypeAnnotation: 'StringTypeAnnotation',
|
2124
2191
|
SwitchCase: 'SwitchCase',
|
2125
2192
|
SwitchStatement: 'SwitchStatement',
|
2126
2193
|
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
@@ -2128,10 +2195,15 @@ parseYieldExpression: true
|
|
2128
2195
|
TemplateLiteral: 'TemplateLiteral',
|
2129
2196
|
ThisExpression: 'ThisExpression',
|
2130
2197
|
ThrowStatement: 'ThrowStatement',
|
2198
|
+
TupleTypeAnnotation: 'TupleTypeAnnotation',
|
2131
2199
|
TryStatement: 'TryStatement',
|
2132
|
-
|
2200
|
+
TypeAlias: 'TypeAlias',
|
2133
2201
|
TypeAnnotation: 'TypeAnnotation',
|
2202
|
+
TypeofTypeAnnotation: 'TypeofTypeAnnotation',
|
2203
|
+
TypeParameterDeclaration: 'TypeParameterDeclaration',
|
2204
|
+
TypeParameterInstantiation: 'TypeParameterInstantiation',
|
2134
2205
|
UnaryExpression: 'UnaryExpression',
|
2206
|
+
UnionTypeAnnotation: 'UnionTypeAnnotation',
|
2135
2207
|
UpdateExpression: 'UpdateExpression',
|
2136
2208
|
VariableDeclaration: 'VariableDeclaration',
|
2137
2209
|
VariableDeclarator: 'VariableDeclarator',
|
@@ -2149,7 +2221,8 @@ parseYieldExpression: true
|
|
2149
2221
|
XJSAttribute: 'XJSAttribute',
|
2150
2222
|
XJSSpreadAttribute: 'XJSSpreadAttribute',
|
2151
2223
|
XJSText: 'XJSText',
|
2152
|
-
YieldExpression: 'YieldExpression'
|
2224
|
+
YieldExpression: 'YieldExpression',
|
2225
|
+
AwaitExpression: 'AwaitExpression'
|
2153
2226
|
};
|
2154
2227
|
|
2155
2228
|
PropertyKind = {
|
@@ -2186,7 +2259,6 @@ parseYieldExpression: true
|
|
2186
2259
|
IllegalBreak: 'Illegal break statement',
|
2187
2260
|
IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
|
2188
2261
|
IllegalReturn: 'Illegal return statement',
|
2189
|
-
IllegalYield: 'Illegal yield expression',
|
2190
2262
|
IllegalSpread: 'Illegal spread element',
|
2191
2263
|
StrictModeWith: 'Strict mode code may not include a with statement',
|
2192
2264
|
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
|
@@ -2209,23 +2281,29 @@ parseYieldExpression: true
|
|
2209
2281
|
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
|
2210
2282
|
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
|
2211
2283
|
StrictReservedWord: 'Use of future reserved word in strict mode',
|
2212
|
-
|
2213
|
-
|
2284
|
+
MissingFromClause: 'Missing from clause',
|
2285
|
+
NoAsAfterImportNamespace: 'Missing as after import *',
|
2214
2286
|
InvalidModuleSpecifier: 'Invalid module specifier',
|
2215
|
-
NestedModule: 'Module declaration can not be nested',
|
2216
2287
|
NoUnintializedConst: 'Const must be initialized',
|
2217
2288
|
ComprehensionRequiresBlock: 'Comprehension must have at least one block',
|
2218
2289
|
ComprehensionError: 'Comprehension Error',
|
2219
2290
|
EachNotAllowed: 'Each is not supported',
|
2220
2291
|
InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
|
2221
2292
|
ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
|
2222
|
-
AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag'
|
2293
|
+
AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
|
2294
|
+
ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
|
2295
|
+
'you are trying to write a function type, but you ended up ' +
|
2296
|
+
'writing a grouped type followed by an =>, which is a syntax ' +
|
2297
|
+
'error. Remember, function type parameters are named so function ' +
|
2298
|
+
'types look like (name1: type1, name2: type2) => returnType. You ' +
|
2299
|
+
'probably wrote (type1) => returnType'
|
2223
2300
|
};
|
2224
2301
|
|
2225
2302
|
// See also tools/generate-unicode-regex.py.
|
2226
2303
|
Regex = {
|
2227
2304
|
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
|
2228
|
-
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]')
|
2305
|
+
NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
|
2306
|
+
LeadingZeros: new RegExp('^0+(?!$)')
|
2229
2307
|
};
|
2230
2308
|
|
2231
2309
|
// Ensure the condition is true, otherwise throw an error.
|
@@ -2744,7 +2822,9 @@ parseYieldExpression: true
|
|
2744
2822
|
|
2745
2823
|
// Other 2-character punctuators: ++ -- << >> && ||
|
2746
2824
|
|
2747
|
-
|
2825
|
+
// Don't match these tokens if we're in a type, since they never can
|
2826
|
+
// occur and can mess up types like Map<string, Array<string>>
|
2827
|
+
if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
|
2748
2828
|
index += 2;
|
2749
2829
|
return {
|
2750
2830
|
type: Token.Punctuator,
|
@@ -3220,7 +3300,7 @@ parseYieldExpression: true
|
|
3220
3300
|
}
|
3221
3301
|
|
3222
3302
|
function scanRegExp() {
|
3223
|
-
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false;
|
3303
|
+
var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
|
3224
3304
|
|
3225
3305
|
lookahead = null;
|
3226
3306
|
skipComment();
|
@@ -3296,19 +3376,43 @@ parseYieldExpression: true
|
|
3296
3376
|
}
|
3297
3377
|
}
|
3298
3378
|
|
3379
|
+
tmp = pattern;
|
3380
|
+
if (flags.indexOf('u') >= 0) {
|
3381
|
+
// Replace each astral symbol and every Unicode code point
|
3382
|
+
// escape sequence that represents such a symbol with a single
|
3383
|
+
// ASCII symbol to avoid throwing on regular expressions that
|
3384
|
+
// are only valid in combination with the `/u` flag.
|
3385
|
+
tmp = tmp
|
3386
|
+
.replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
|
3387
|
+
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
|
3388
|
+
}
|
3389
|
+
|
3390
|
+
// First, detect invalid regular expressions.
|
3299
3391
|
try {
|
3300
|
-
value = new RegExp(
|
3392
|
+
value = new RegExp(tmp);
|
3301
3393
|
} catch (e) {
|
3302
3394
|
throwError({}, Messages.InvalidRegExp);
|
3303
3395
|
}
|
3304
3396
|
|
3305
|
-
|
3397
|
+
// Return a regular expression object for this pattern-flag pair, or
|
3398
|
+
// `null` in case the current environment doesn't support the flags it
|
3399
|
+
// uses.
|
3400
|
+
try {
|
3401
|
+
value = new RegExp(pattern, flags);
|
3402
|
+
} catch (exception) {
|
3403
|
+
value = null;
|
3404
|
+
}
|
3306
3405
|
|
3406
|
+
peek();
|
3307
3407
|
|
3308
3408
|
if (extra.tokenize) {
|
3309
3409
|
return {
|
3310
3410
|
type: Token.RegularExpression,
|
3311
3411
|
value: value,
|
3412
|
+
regex: {
|
3413
|
+
pattern: pattern,
|
3414
|
+
flags: flags
|
3415
|
+
},
|
3312
3416
|
lineNumber: lineNumber,
|
3313
3417
|
lineStart: lineStart,
|
3314
3418
|
range: [start, index]
|
@@ -3317,6 +3421,10 @@ parseYieldExpression: true
|
|
3317
3421
|
return {
|
3318
3422
|
literal: str,
|
3319
3423
|
value: value,
|
3424
|
+
regex: {
|
3425
|
+
pattern: pattern,
|
3426
|
+
flags: flags
|
3427
|
+
},
|
3320
3428
|
range: [start, index]
|
3321
3429
|
};
|
3322
3430
|
}
|
@@ -3511,6 +3619,13 @@ parseYieldExpression: true
|
|
3511
3619
|
return result;
|
3512
3620
|
}
|
3513
3621
|
|
3622
|
+
function rewind(token) {
|
3623
|
+
index = token.range[0];
|
3624
|
+
lineNumber = token.lineNumber;
|
3625
|
+
lineStart = token.lineStart;
|
3626
|
+
lookahead = token;
|
3627
|
+
}
|
3628
|
+
|
3514
3629
|
function markerCreate() {
|
3515
3630
|
if (!extra.loc && !extra.range) {
|
3516
3631
|
return undefined;
|
@@ -3738,8 +3853,8 @@ parseYieldExpression: true
|
|
3738
3853
|
},
|
3739
3854
|
|
3740
3855
|
createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
|
3741
|
-
returnType,
|
3742
|
-
|
3856
|
+
isAsync, returnType, typeParameters) {
|
3857
|
+
var funDecl = {
|
3743
3858
|
type: Syntax.FunctionDeclaration,
|
3744
3859
|
id: id,
|
3745
3860
|
params: params,
|
@@ -3749,13 +3864,19 @@ parseYieldExpression: true
|
|
3749
3864
|
generator: generator,
|
3750
3865
|
expression: expression,
|
3751
3866
|
returnType: returnType,
|
3752
|
-
|
3867
|
+
typeParameters: typeParameters
|
3753
3868
|
};
|
3869
|
+
|
3870
|
+
if (isAsync) {
|
3871
|
+
funDecl.async = true;
|
3872
|
+
}
|
3873
|
+
|
3874
|
+
return funDecl;
|
3754
3875
|
},
|
3755
3876
|
|
3756
3877
|
createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
|
3757
|
-
returnType,
|
3758
|
-
|
3878
|
+
isAsync, returnType, typeParameters) {
|
3879
|
+
var funExpr = {
|
3759
3880
|
type: Syntax.FunctionExpression,
|
3760
3881
|
id: id,
|
3761
3882
|
params: params,
|
@@ -3765,8 +3886,14 @@ parseYieldExpression: true
|
|
3765
3886
|
generator: generator,
|
3766
3887
|
expression: expression,
|
3767
3888
|
returnType: returnType,
|
3768
|
-
|
3889
|
+
typeParameters: typeParameters
|
3769
3890
|
};
|
3891
|
+
|
3892
|
+
if (isAsync) {
|
3893
|
+
funExpr.async = true;
|
3894
|
+
}
|
3895
|
+
|
3896
|
+
return funExpr;
|
3770
3897
|
},
|
3771
3898
|
|
3772
3899
|
createIdentifier: function (name) {
|
@@ -3778,25 +3905,110 @@ parseYieldExpression: true
|
|
3778
3905
|
// are added later (like 'loc' and 'range'). This just helps
|
3779
3906
|
// keep the shape of Identifier nodes consistent with everything
|
3780
3907
|
// else.
|
3781
|
-
typeAnnotation: undefined
|
3908
|
+
typeAnnotation: undefined,
|
3909
|
+
optional: undefined
|
3782
3910
|
};
|
3783
3911
|
},
|
3784
3912
|
|
3785
|
-
createTypeAnnotation: function (
|
3913
|
+
createTypeAnnotation: function (typeAnnotation) {
|
3786
3914
|
return {
|
3787
3915
|
type: Syntax.TypeAnnotation,
|
3788
|
-
|
3789
|
-
|
3916
|
+
typeAnnotation: typeAnnotation
|
3917
|
+
};
|
3918
|
+
},
|
3919
|
+
|
3920
|
+
createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
|
3921
|
+
return {
|
3922
|
+
type: Syntax.FunctionTypeAnnotation,
|
3790
3923
|
params: params,
|
3791
3924
|
returnType: returnType,
|
3792
|
-
|
3925
|
+
rest: rest,
|
3926
|
+
typeParameters: typeParameters
|
3927
|
+
};
|
3928
|
+
},
|
3929
|
+
|
3930
|
+
createFunctionTypeParam: function (name, typeAnnotation, optional) {
|
3931
|
+
return {
|
3932
|
+
type: Syntax.FunctionTypeParam,
|
3933
|
+
name: name,
|
3934
|
+
typeAnnotation: typeAnnotation,
|
3935
|
+
optional: optional
|
3793
3936
|
};
|
3794
3937
|
},
|
3795
3938
|
|
3796
|
-
|
3939
|
+
createNullableTypeAnnotation: function (typeAnnotation) {
|
3797
3940
|
return {
|
3798
|
-
type: Syntax.
|
3799
|
-
|
3941
|
+
type: Syntax.NullableTypeAnnotation,
|
3942
|
+
typeAnnotation: typeAnnotation
|
3943
|
+
};
|
3944
|
+
},
|
3945
|
+
|
3946
|
+
createArrayTypeAnnotation: function (elementType) {
|
3947
|
+
return {
|
3948
|
+
type: Syntax.ArrayTypeAnnotation,
|
3949
|
+
elementType: elementType
|
3950
|
+
};
|
3951
|
+
},
|
3952
|
+
|
3953
|
+
createGenericTypeAnnotation: function (id, typeParameters) {
|
3954
|
+
return {
|
3955
|
+
type: Syntax.GenericTypeAnnotation,
|
3956
|
+
id: id,
|
3957
|
+
typeParameters: typeParameters
|
3958
|
+
};
|
3959
|
+
},
|
3960
|
+
|
3961
|
+
createQualifiedTypeIdentifier: function (qualification, id) {
|
3962
|
+
return {
|
3963
|
+
type: Syntax.QualifiedTypeIdentifier,
|
3964
|
+
qualification: qualification,
|
3965
|
+
id: id
|
3966
|
+
};
|
3967
|
+
},
|
3968
|
+
|
3969
|
+
createTypeParameterDeclaration: function (params) {
|
3970
|
+
return {
|
3971
|
+
type: Syntax.TypeParameterDeclaration,
|
3972
|
+
params: params
|
3973
|
+
};
|
3974
|
+
},
|
3975
|
+
|
3976
|
+
createTypeParameterInstantiation: function (params) {
|
3977
|
+
return {
|
3978
|
+
type: Syntax.TypeParameterInstantiation,
|
3979
|
+
params: params
|
3980
|
+
};
|
3981
|
+
},
|
3982
|
+
|
3983
|
+
createAnyTypeAnnotation: function () {
|
3984
|
+
return {
|
3985
|
+
type: Syntax.AnyTypeAnnotation
|
3986
|
+
};
|
3987
|
+
},
|
3988
|
+
|
3989
|
+
createBooleanTypeAnnotation: function () {
|
3990
|
+
return {
|
3991
|
+
type: Syntax.BooleanTypeAnnotation
|
3992
|
+
};
|
3993
|
+
},
|
3994
|
+
|
3995
|
+
createNumberTypeAnnotation: function () {
|
3996
|
+
return {
|
3997
|
+
type: Syntax.NumberTypeAnnotation
|
3998
|
+
};
|
3999
|
+
},
|
4000
|
+
|
4001
|
+
createStringTypeAnnotation: function () {
|
4002
|
+
return {
|
4003
|
+
type: Syntax.StringTypeAnnotation
|
4004
|
+
};
|
4005
|
+
},
|
4006
|
+
|
4007
|
+
createStringLiteralTypeAnnotation: function (token) {
|
4008
|
+
return {
|
4009
|
+
type: Syntax.StringLiteralTypeAnnotation,
|
4010
|
+
value: token.value,
|
4011
|
+
raw: source.slice(token.range[0], token.range[1])
|
3800
4012
|
};
|
3801
4013
|
},
|
3802
4014
|
|
@@ -3806,26 +4018,117 @@ parseYieldExpression: true
|
|
3806
4018
|
};
|
3807
4019
|
},
|
3808
4020
|
|
3809
|
-
|
4021
|
+
createTypeofTypeAnnotation: function (argument) {
|
4022
|
+
return {
|
4023
|
+
type: Syntax.TypeofTypeAnnotation,
|
4024
|
+
argument: argument
|
4025
|
+
};
|
4026
|
+
},
|
4027
|
+
|
4028
|
+
createTupleTypeAnnotation: function (types) {
|
4029
|
+
return {
|
4030
|
+
type: Syntax.TupleTypeAnnotation,
|
4031
|
+
types: types
|
4032
|
+
};
|
4033
|
+
},
|
4034
|
+
|
4035
|
+
createObjectTypeAnnotation: function (properties, indexers, callProperties) {
|
3810
4036
|
return {
|
3811
4037
|
type: Syntax.ObjectTypeAnnotation,
|
3812
4038
|
properties: properties,
|
3813
|
-
|
4039
|
+
indexers: indexers,
|
4040
|
+
callProperties: callProperties
|
4041
|
+
};
|
4042
|
+
},
|
4043
|
+
|
4044
|
+
createObjectTypeIndexer: function (id, key, value, isStatic) {
|
4045
|
+
return {
|
4046
|
+
type: Syntax.ObjectTypeIndexer,
|
4047
|
+
id: id,
|
4048
|
+
key: key,
|
4049
|
+
value: value,
|
4050
|
+
"static": isStatic
|
4051
|
+
};
|
4052
|
+
},
|
4053
|
+
|
4054
|
+
createObjectTypeCallProperty: function (value, isStatic) {
|
4055
|
+
return {
|
4056
|
+
type: Syntax.ObjectTypeCallProperty,
|
4057
|
+
value: value,
|
4058
|
+
"static": isStatic
|
3814
4059
|
};
|
3815
4060
|
},
|
3816
4061
|
|
3817
|
-
|
4062
|
+
createObjectTypeProperty: function (key, value, optional, isStatic) {
|
3818
4063
|
return {
|
3819
|
-
type: Syntax.
|
3820
|
-
|
3821
|
-
|
4064
|
+
type: Syntax.ObjectTypeProperty,
|
4065
|
+
key: key,
|
4066
|
+
value: value,
|
4067
|
+
optional: optional,
|
4068
|
+
"static": isStatic
|
4069
|
+
};
|
4070
|
+
},
|
4071
|
+
|
4072
|
+
createUnionTypeAnnotation: function (types) {
|
4073
|
+
return {
|
4074
|
+
type: Syntax.UnionTypeAnnotation,
|
4075
|
+
types: types
|
4076
|
+
};
|
4077
|
+
},
|
4078
|
+
|
4079
|
+
createIntersectionTypeAnnotation: function (types) {
|
4080
|
+
return {
|
4081
|
+
type: Syntax.IntersectionTypeAnnotation,
|
4082
|
+
types: types
|
4083
|
+
};
|
4084
|
+
},
|
4085
|
+
|
4086
|
+
createTypeAlias: function (id, typeParameters, right) {
|
4087
|
+
return {
|
4088
|
+
type: Syntax.TypeAlias,
|
4089
|
+
id: id,
|
4090
|
+
typeParameters: typeParameters,
|
4091
|
+
right: right
|
4092
|
+
};
|
4093
|
+
},
|
4094
|
+
|
4095
|
+
createInterface: function (id, typeParameters, body, extended) {
|
4096
|
+
return {
|
4097
|
+
type: Syntax.InterfaceDeclaration,
|
4098
|
+
id: id,
|
4099
|
+
typeParameters: typeParameters,
|
4100
|
+
body: body,
|
4101
|
+
"extends": extended
|
4102
|
+
};
|
4103
|
+
},
|
4104
|
+
|
4105
|
+
createInterfaceExtends: function (id, typeParameters) {
|
4106
|
+
return {
|
4107
|
+
type: Syntax.InterfaceExtends,
|
4108
|
+
id: id,
|
4109
|
+
typeParameters: typeParameters
|
4110
|
+
};
|
4111
|
+
},
|
4112
|
+
|
4113
|
+
createDeclareFunction: function (id) {
|
4114
|
+
return {
|
4115
|
+
type: Syntax.DeclareFunction,
|
4116
|
+
id: id
|
4117
|
+
};
|
4118
|
+
},
|
4119
|
+
|
4120
|
+
createDeclareVariable: function (id) {
|
4121
|
+
return {
|
4122
|
+
type: Syntax.DeclareVariable,
|
4123
|
+
id: id
|
3822
4124
|
};
|
3823
4125
|
},
|
3824
4126
|
|
3825
|
-
|
4127
|
+
createDeclareModule: function (id, body) {
|
3826
4128
|
return {
|
3827
|
-
type: Syntax.
|
3828
|
-
id:
|
4129
|
+
type: Syntax.DeclareModule,
|
4130
|
+
id: id,
|
4131
|
+
body: body
|
3829
4132
|
};
|
3830
4133
|
},
|
3831
4134
|
|
@@ -3923,11 +4226,15 @@ parseYieldExpression: true
|
|
3923
4226
|
},
|
3924
4227
|
|
3925
4228
|
createLiteral: function (token) {
|
3926
|
-
|
4229
|
+
var object = {
|
3927
4230
|
type: Syntax.Literal,
|
3928
4231
|
value: token.value,
|
3929
4232
|
raw: source.slice(token.range[0], token.range[1])
|
3930
4233
|
};
|
4234
|
+
if (token.regex) {
|
4235
|
+
object.regex = token.regex;
|
4236
|
+
}
|
4237
|
+
return object;
|
3931
4238
|
},
|
3932
4239
|
|
3933
4240
|
createMemberExpression: function (accessor, object, property) {
|
@@ -4122,8 +4429,8 @@ parseYieldExpression: true
|
|
4122
4429
|
};
|
4123
4430
|
},
|
4124
4431
|
|
4125
|
-
createArrowFunctionExpression: function (params, defaults, body, rest, expression) {
|
4126
|
-
|
4432
|
+
createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
|
4433
|
+
var arrowExpr = {
|
4127
4434
|
type: Syntax.ArrowFunctionExpression,
|
4128
4435
|
id: null,
|
4129
4436
|
params: params,
|
@@ -4133,6 +4440,12 @@ parseYieldExpression: true
|
|
4133
4440
|
generator: false,
|
4134
4441
|
expression: expression
|
4135
4442
|
};
|
4443
|
+
|
4444
|
+
if (isAsync) {
|
4445
|
+
arrowExpr.async = true;
|
4446
|
+
}
|
4447
|
+
|
4448
|
+
return arrowExpr;
|
4136
4449
|
},
|
4137
4450
|
|
4138
4451
|
createMethodDefinition: function (propertyType, kind, key, value) {
|
@@ -4145,10 +4458,13 @@ parseYieldExpression: true
|
|
4145
4458
|
};
|
4146
4459
|
},
|
4147
4460
|
|
4148
|
-
createClassProperty: function (
|
4461
|
+
createClassProperty: function (key, typeAnnotation, computed, isStatic) {
|
4149
4462
|
return {
|
4150
4463
|
type: Syntax.ClassProperty,
|
4151
|
-
|
4464
|
+
key: key,
|
4465
|
+
typeAnnotation: typeAnnotation,
|
4466
|
+
computed: computed,
|
4467
|
+
"static": isStatic
|
4152
4468
|
};
|
4153
4469
|
},
|
4154
4470
|
|
@@ -4159,24 +4475,43 @@ parseYieldExpression: true
|
|
4159
4475
|
};
|
4160
4476
|
},
|
4161
4477
|
|
4162
|
-
|
4478
|
+
createClassImplements: function (id, typeParameters) {
|
4479
|
+
return {
|
4480
|
+
type: Syntax.ClassImplements,
|
4481
|
+
id: id,
|
4482
|
+
typeParameters: typeParameters
|
4483
|
+
};
|
4484
|
+
},
|
4485
|
+
|
4486
|
+
createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
|
4163
4487
|
return {
|
4164
4488
|
type: Syntax.ClassExpression,
|
4165
4489
|
id: id,
|
4166
4490
|
superClass: superClass,
|
4167
4491
|
body: body,
|
4168
|
-
|
4492
|
+
typeParameters: typeParameters,
|
4493
|
+
superTypeParameters: superTypeParameters,
|
4494
|
+
"implements": implemented
|
4169
4495
|
};
|
4170
4496
|
},
|
4171
4497
|
|
4172
|
-
createClassDeclaration: function (id, superClass, body,
|
4498
|
+
createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
|
4173
4499
|
return {
|
4174
4500
|
type: Syntax.ClassDeclaration,
|
4175
4501
|
id: id,
|
4176
4502
|
superClass: superClass,
|
4177
4503
|
body: body,
|
4178
|
-
|
4179
|
-
|
4504
|
+
typeParameters: typeParameters,
|
4505
|
+
superTypeParameters: superTypeParameters,
|
4506
|
+
"implements": implemented
|
4507
|
+
};
|
4508
|
+
},
|
4509
|
+
|
4510
|
+
createModuleSpecifier: function (token) {
|
4511
|
+
return {
|
4512
|
+
type: Syntax.ModuleSpecifier,
|
4513
|
+
value: token.value,
|
4514
|
+
raw: source.slice(token.range[0], token.range[1])
|
4180
4515
|
};
|
4181
4516
|
},
|
4182
4517
|
|
@@ -4194,9 +4529,24 @@ parseYieldExpression: true
|
|
4194
4529
|
};
|
4195
4530
|
},
|
4196
4531
|
|
4197
|
-
|
4532
|
+
createImportDefaultSpecifier: function (id) {
|
4533
|
+
return {
|
4534
|
+
type: Syntax.ImportDefaultSpecifier,
|
4535
|
+
id: id
|
4536
|
+
};
|
4537
|
+
},
|
4538
|
+
|
4539
|
+
createImportNamespaceSpecifier: function (id) {
|
4540
|
+
return {
|
4541
|
+
type: Syntax.ImportNamespaceSpecifier,
|
4542
|
+
id: id
|
4543
|
+
};
|
4544
|
+
},
|
4545
|
+
|
4546
|
+
createExportDeclaration: function (isDefault, declaration, specifiers, source) {
|
4198
4547
|
return {
|
4199
4548
|
type: Syntax.ExportDeclaration,
|
4549
|
+
'default': !!isDefault,
|
4200
4550
|
declaration: declaration,
|
4201
4551
|
specifiers: specifiers,
|
4202
4552
|
source: source
|
@@ -4211,11 +4561,10 @@ parseYieldExpression: true
|
|
4211
4561
|
};
|
4212
4562
|
},
|
4213
4563
|
|
4214
|
-
createImportDeclaration: function (specifiers,
|
4564
|
+
createImportDeclaration: function (specifiers, source) {
|
4215
4565
|
return {
|
4216
4566
|
type: Syntax.ImportDeclaration,
|
4217
4567
|
specifiers: specifiers,
|
4218
|
-
kind: kind,
|
4219
4568
|
source: source
|
4220
4569
|
};
|
4221
4570
|
},
|
@@ -4228,12 +4577,10 @@ parseYieldExpression: true
|
|
4228
4577
|
};
|
4229
4578
|
},
|
4230
4579
|
|
4231
|
-
|
4580
|
+
createAwaitExpression: function (argument) {
|
4232
4581
|
return {
|
4233
|
-
type: Syntax.
|
4234
|
-
|
4235
|
-
source: source,
|
4236
|
-
body: body
|
4582
|
+
type: Syntax.AwaitExpression,
|
4583
|
+
argument: argument
|
4237
4584
|
};
|
4238
4585
|
},
|
4239
4586
|
|
@@ -4357,13 +4704,21 @@ parseYieldExpression: true
|
|
4357
4704
|
// Expect the next token to match the specified keyword.
|
4358
4705
|
// If not, an exception will be thrown.
|
4359
4706
|
|
4360
|
-
function expectKeyword(keyword) {
|
4707
|
+
function expectKeyword(keyword, contextual) {
|
4361
4708
|
var token = lex();
|
4362
|
-
if (token.type !== Token.
|
4709
|
+
if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
|
4710
|
+
token.value !== keyword) {
|
4363
4711
|
throwUnexpected(token);
|
4364
4712
|
}
|
4365
4713
|
}
|
4366
4714
|
|
4715
|
+
// Expect the next token to match the specified contextual keyword.
|
4716
|
+
// If not, an exception will be thrown.
|
4717
|
+
|
4718
|
+
function expectContextualKeyword(keyword) {
|
4719
|
+
return expectKeyword(keyword, true);
|
4720
|
+
}
|
4721
|
+
|
4367
4722
|
// Return true if the next token matches the specified punctuator.
|
4368
4723
|
|
4369
4724
|
function match(value) {
|
@@ -4372,15 +4727,15 @@ parseYieldExpression: true
|
|
4372
4727
|
|
4373
4728
|
// Return true if the next token matches the specified keyword
|
4374
4729
|
|
4375
|
-
function matchKeyword(keyword) {
|
4376
|
-
|
4730
|
+
function matchKeyword(keyword, contextual) {
|
4731
|
+
var expectedType = contextual ? Token.Identifier : Token.Keyword;
|
4732
|
+
return lookahead.type === expectedType && lookahead.value === keyword;
|
4377
4733
|
}
|
4378
4734
|
|
4379
|
-
|
4380
4735
|
// Return true if the next token matches the specified contextual keyword
|
4381
4736
|
|
4382
4737
|
function matchContextualKeyword(keyword) {
|
4383
|
-
return
|
4738
|
+
return matchKeyword(keyword, true);
|
4384
4739
|
}
|
4385
4740
|
|
4386
4741
|
// Return true if the next token is an assignment operator
|
@@ -4406,6 +4761,30 @@ parseYieldExpression: true
|
|
4406
4761
|
op === '|=';
|
4407
4762
|
}
|
4408
4763
|
|
4764
|
+
// Note that 'yield' is treated as a keyword in strict mode, but a
|
4765
|
+
// contextual keyword (identifier) in non-strict mode, so we need to
|
4766
|
+
// use matchKeyword('yield', false) and matchKeyword('yield', true)
|
4767
|
+
// (i.e. matchContextualKeyword) appropriately.
|
4768
|
+
function matchYield() {
|
4769
|
+
return state.yieldAllowed && matchKeyword('yield', !strict);
|
4770
|
+
}
|
4771
|
+
|
4772
|
+
function matchAsync() {
|
4773
|
+
var backtrackToken = lookahead, matches = false;
|
4774
|
+
|
4775
|
+
if (matchContextualKeyword('async')) {
|
4776
|
+
lex(); // Make sure peekLineTerminator() starts after 'async'.
|
4777
|
+
matches = !peekLineTerminator();
|
4778
|
+
rewind(backtrackToken); // Revert the lex().
|
4779
|
+
}
|
4780
|
+
|
4781
|
+
return matches;
|
4782
|
+
}
|
4783
|
+
|
4784
|
+
function matchAwait() {
|
4785
|
+
return state.awaitAllowed && matchContextualKeyword('await');
|
4786
|
+
}
|
4787
|
+
|
4409
4788
|
function consumeSemicolon() {
|
4410
4789
|
var line, oldIndex = index, oldLineNumber = lineNumber,
|
4411
4790
|
oldLineStart = lineStart, oldLookahead = lookahead;
|
@@ -4513,12 +4892,14 @@ parseYieldExpression: true
|
|
4513
4892
|
// 11.1.5 Object Initialiser
|
4514
4893
|
|
4515
4894
|
function parsePropertyFunction(options) {
|
4516
|
-
var previousStrict, previousYieldAllowed,
|
4517
|
-
marker = markerCreate();
|
4895
|
+
var previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
4896
|
+
params, defaults, body, marker = markerCreate();
|
4518
4897
|
|
4519
4898
|
previousStrict = strict;
|
4520
4899
|
previousYieldAllowed = state.yieldAllowed;
|
4521
4900
|
state.yieldAllowed = options.generator;
|
4901
|
+
previousAwaitAllowed = state.awaitAllowed;
|
4902
|
+
state.awaitAllowed = options.async;
|
4522
4903
|
params = options.params || [];
|
4523
4904
|
defaults = options.defaults || [];
|
4524
4905
|
|
@@ -4528,6 +4909,7 @@ parseYieldExpression: true
|
|
4528
4909
|
}
|
4529
4910
|
strict = previousStrict;
|
4530
4911
|
state.yieldAllowed = previousYieldAllowed;
|
4912
|
+
state.awaitAllowed = previousAwaitAllowed;
|
4531
4913
|
|
4532
4914
|
return markerApply(marker, delegate.createFunctionExpression(
|
4533
4915
|
null,
|
@@ -4537,8 +4919,9 @@ parseYieldExpression: true
|
|
4537
4919
|
options.rest || null,
|
4538
4920
|
options.generator,
|
4539
4921
|
body.type !== Syntax.BlockStatement,
|
4922
|
+
options.async,
|
4540
4923
|
options.returnType,
|
4541
|
-
options.
|
4924
|
+
options.typeParameters
|
4542
4925
|
));
|
4543
4926
|
}
|
4544
4927
|
|
@@ -4555,14 +4938,14 @@ parseYieldExpression: true
|
|
4555
4938
|
throwErrorTolerant(tmp.stricted, tmp.message);
|
4556
4939
|
}
|
4557
4940
|
|
4558
|
-
|
4559
4941
|
method = parsePropertyFunction({
|
4560
4942
|
params: tmp.params,
|
4561
4943
|
defaults: tmp.defaults,
|
4562
4944
|
rest: tmp.rest,
|
4563
4945
|
generator: options.generator,
|
4946
|
+
async: options.async,
|
4564
4947
|
returnType: tmp.returnType,
|
4565
|
-
|
4948
|
+
typeParameters: options.typeParameters
|
4566
4949
|
});
|
4567
4950
|
|
4568
4951
|
strict = previousStrict;
|
@@ -4602,46 +4985,138 @@ parseYieldExpression: true
|
|
4602
4985
|
|
4603
4986
|
function parseObjectProperty() {
|
4604
4987
|
var token, key, id, value, param, expr, computed,
|
4605
|
-
marker = markerCreate();
|
4988
|
+
marker = markerCreate(), returnType;
|
4606
4989
|
|
4607
4990
|
token = lookahead;
|
4608
4991
|
computed = (token.value === '[');
|
4609
4992
|
|
4610
|
-
if (token.type === Token.Identifier || computed) {
|
4611
|
-
|
4993
|
+
if (token.type === Token.Identifier || computed || matchAsync()) {
|
4612
4994
|
id = parseObjectPropertyKey();
|
4613
4995
|
|
4996
|
+
if (match(':')) {
|
4997
|
+
lex();
|
4998
|
+
|
4999
|
+
return markerApply(
|
5000
|
+
marker,
|
5001
|
+
delegate.createProperty(
|
5002
|
+
'init',
|
5003
|
+
id,
|
5004
|
+
parseAssignmentExpression(),
|
5005
|
+
false,
|
5006
|
+
false,
|
5007
|
+
computed
|
5008
|
+
)
|
5009
|
+
);
|
5010
|
+
}
|
5011
|
+
|
5012
|
+
if (match('(')) {
|
5013
|
+
return markerApply(
|
5014
|
+
marker,
|
5015
|
+
delegate.createProperty(
|
5016
|
+
'init',
|
5017
|
+
id,
|
5018
|
+
parsePropertyMethodFunction({
|
5019
|
+
generator: false,
|
5020
|
+
async: false
|
5021
|
+
}),
|
5022
|
+
true,
|
5023
|
+
false,
|
5024
|
+
computed
|
5025
|
+
)
|
5026
|
+
);
|
5027
|
+
}
|
5028
|
+
|
4614
5029
|
// Property Assignment: Getter and Setter.
|
4615
5030
|
|
4616
|
-
if (token.value === 'get'
|
5031
|
+
if (token.value === 'get') {
|
4617
5032
|
computed = (lookahead.value === '[');
|
4618
5033
|
key = parseObjectPropertyKey();
|
5034
|
+
|
4619
5035
|
expect('(');
|
4620
5036
|
expect(')');
|
4621
|
-
|
5037
|
+
if (match(':')) {
|
5038
|
+
returnType = parseTypeAnnotation();
|
5039
|
+
}
|
5040
|
+
|
5041
|
+
return markerApply(
|
5042
|
+
marker,
|
5043
|
+
delegate.createProperty(
|
5044
|
+
'get',
|
5045
|
+
key,
|
5046
|
+
parsePropertyFunction({
|
5047
|
+
generator: false,
|
5048
|
+
async: false,
|
5049
|
+
returnType: returnType
|
5050
|
+
}),
|
5051
|
+
false,
|
5052
|
+
false,
|
5053
|
+
computed
|
5054
|
+
)
|
5055
|
+
);
|
4622
5056
|
}
|
4623
|
-
|
5057
|
+
|
5058
|
+
if (token.value === 'set') {
|
4624
5059
|
computed = (lookahead.value === '[');
|
4625
5060
|
key = parseObjectPropertyKey();
|
5061
|
+
|
4626
5062
|
expect('(');
|
4627
5063
|
token = lookahead;
|
4628
5064
|
param = [ parseTypeAnnotatableIdentifier() ];
|
4629
5065
|
expect(')');
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4633
|
-
|
4634
|
-
return markerApply(
|
5066
|
+
if (match(':')) {
|
5067
|
+
returnType = parseTypeAnnotation();
|
5068
|
+
}
|
5069
|
+
|
5070
|
+
return markerApply(
|
5071
|
+
marker,
|
5072
|
+
delegate.createProperty(
|
5073
|
+
'set',
|
5074
|
+
key,
|
5075
|
+
parsePropertyFunction({
|
5076
|
+
params: param,
|
5077
|
+
generator: false,
|
5078
|
+
async: false,
|
5079
|
+
name: token,
|
5080
|
+
returnType: returnType
|
5081
|
+
}),
|
5082
|
+
false,
|
5083
|
+
false,
|
5084
|
+
computed
|
5085
|
+
)
|
5086
|
+
);
|
4635
5087
|
}
|
4636
|
-
|
4637
|
-
|
5088
|
+
|
5089
|
+
if (token.value === 'async') {
|
5090
|
+
computed = (lookahead.value === '[');
|
5091
|
+
key = parseObjectPropertyKey();
|
5092
|
+
|
5093
|
+
return markerApply(
|
5094
|
+
marker,
|
5095
|
+
delegate.createProperty(
|
5096
|
+
'init',
|
5097
|
+
key,
|
5098
|
+
parsePropertyMethodFunction({
|
5099
|
+
generator: false,
|
5100
|
+
async: true
|
5101
|
+
}),
|
5102
|
+
true,
|
5103
|
+
false,
|
5104
|
+
computed
|
5105
|
+
)
|
5106
|
+
);
|
4638
5107
|
}
|
5108
|
+
|
4639
5109
|
if (computed) {
|
4640
5110
|
// Computed properties can only be used with full notation.
|
4641
5111
|
throwUnexpected(lookahead);
|
4642
5112
|
}
|
4643
|
-
|
5113
|
+
|
5114
|
+
return markerApply(
|
5115
|
+
marker,
|
5116
|
+
delegate.createProperty('init', id, id, false, true, false)
|
5117
|
+
);
|
4644
5118
|
}
|
5119
|
+
|
4645
5120
|
if (token.type === Token.EOF || token.type === Token.Punctuator) {
|
4646
5121
|
if (!match('*')) {
|
4647
5122
|
throwUnexpected(token);
|
@@ -4768,6 +5243,18 @@ parseYieldExpression: true
|
|
4768
5243
|
return expr;
|
4769
5244
|
}
|
4770
5245
|
|
5246
|
+
function matchAsyncFuncExprOrDecl() {
|
5247
|
+
var token;
|
5248
|
+
|
5249
|
+
if (matchAsync()) {
|
5250
|
+
token = lookahead2();
|
5251
|
+
if (token.type === Token.Keyword && token.value === 'function') {
|
5252
|
+
return true;
|
5253
|
+
}
|
5254
|
+
}
|
5255
|
+
|
5256
|
+
return false;
|
5257
|
+
}
|
4771
5258
|
|
4772
5259
|
// 11.1 Primary Expressions
|
4773
5260
|
|
@@ -5344,13 +5831,15 @@ parseYieldExpression: true
|
|
5344
5831
|
}
|
5345
5832
|
|
5346
5833
|
function parseArrowFunctionExpression(options, marker) {
|
5347
|
-
var previousStrict, previousYieldAllowed, body;
|
5834
|
+
var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
|
5348
5835
|
|
5349
5836
|
expect('=>');
|
5350
5837
|
|
5351
5838
|
previousStrict = strict;
|
5352
5839
|
previousYieldAllowed = state.yieldAllowed;
|
5353
5840
|
state.yieldAllowed = false;
|
5841
|
+
previousAwaitAllowed = state.awaitAllowed;
|
5842
|
+
state.awaitAllowed = !!options.async;
|
5354
5843
|
body = parseConciseBody();
|
5355
5844
|
|
5356
5845
|
if (strict && options.firstRestricted) {
|
@@ -5362,30 +5851,47 @@ parseYieldExpression: true
|
|
5362
5851
|
|
5363
5852
|
strict = previousStrict;
|
5364
5853
|
state.yieldAllowed = previousYieldAllowed;
|
5854
|
+
state.awaitAllowed = previousAwaitAllowed;
|
5365
5855
|
|
5366
5856
|
return markerApply(marker, delegate.createArrowFunctionExpression(
|
5367
5857
|
options.params,
|
5368
5858
|
options.defaults,
|
5369
5859
|
body,
|
5370
5860
|
options.rest,
|
5371
|
-
body.type !== Syntax.BlockStatement
|
5861
|
+
body.type !== Syntax.BlockStatement,
|
5862
|
+
!!options.async
|
5372
5863
|
));
|
5373
5864
|
}
|
5374
5865
|
|
5375
5866
|
function parseAssignmentExpression() {
|
5376
|
-
var marker, expr, token, params, oldParenthesizedCount
|
5867
|
+
var marker, expr, token, params, oldParenthesizedCount,
|
5868
|
+
backtrackToken = lookahead, possiblyAsync = false;
|
5377
5869
|
|
5378
|
-
|
5379
|
-
// contextual keyword (identifier) in non-strict mode, so we need
|
5380
|
-
// to use matchKeyword and matchContextualKeyword appropriately.
|
5381
|
-
if ((state.yieldAllowed && matchContextualKeyword('yield')) || (strict && matchKeyword('yield'))) {
|
5870
|
+
if (matchYield()) {
|
5382
5871
|
return parseYieldExpression();
|
5383
5872
|
}
|
5384
5873
|
|
5874
|
+
if (matchAwait()) {
|
5875
|
+
return parseAwaitExpression();
|
5876
|
+
}
|
5877
|
+
|
5385
5878
|
oldParenthesizedCount = state.parenthesizedCount;
|
5386
5879
|
|
5387
5880
|
marker = markerCreate();
|
5388
5881
|
|
5882
|
+
if (matchAsyncFuncExprOrDecl()) {
|
5883
|
+
return parseFunctionExpression();
|
5884
|
+
}
|
5885
|
+
|
5886
|
+
if (matchAsync()) {
|
5887
|
+
// We can't be completely sure that this 'async' token is
|
5888
|
+
// actually a contextual keyword modifying a function
|
5889
|
+
// expression, so we might have to un-lex() it later by
|
5890
|
+
// calling rewind(backtrackToken).
|
5891
|
+
possiblyAsync = true;
|
5892
|
+
lex();
|
5893
|
+
}
|
5894
|
+
|
5389
5895
|
if (match('(')) {
|
5390
5896
|
token = lookahead2();
|
5391
5897
|
if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
|
@@ -5393,11 +5899,21 @@ parseYieldExpression: true
|
|
5393
5899
|
if (!match('=>')) {
|
5394
5900
|
throwUnexpected(lex());
|
5395
5901
|
}
|
5902
|
+
params.async = possiblyAsync;
|
5396
5903
|
return parseArrowFunctionExpression(params, marker);
|
5397
5904
|
}
|
5398
5905
|
}
|
5399
5906
|
|
5400
5907
|
token = lookahead;
|
5908
|
+
|
5909
|
+
// If the 'async' keyword is not followed by a '(' character or an
|
5910
|
+
// identifier, then it can't be an arrow function modifier, and we
|
5911
|
+
// should interpret it as a normal identifer.
|
5912
|
+
if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
|
5913
|
+
possiblyAsync = false;
|
5914
|
+
rewind(backtrackToken);
|
5915
|
+
}
|
5916
|
+
|
5401
5917
|
expr = parseConditionalExpression();
|
5402
5918
|
|
5403
5919
|
if (match('=>') &&
|
@@ -5409,10 +5925,20 @@ parseYieldExpression: true
|
|
5409
5925
|
params = reinterpretAsCoverFormalsList(expr.expressions);
|
5410
5926
|
}
|
5411
5927
|
if (params) {
|
5928
|
+
params.async = possiblyAsync;
|
5412
5929
|
return parseArrowFunctionExpression(params, marker);
|
5413
5930
|
}
|
5414
5931
|
}
|
5415
5932
|
|
5933
|
+
// If we haven't returned by now, then the 'async' keyword was not
|
5934
|
+
// a function modifier, and we should rewind and interpret it as a
|
5935
|
+
// normal identifier.
|
5936
|
+
if (possiblyAsync) {
|
5937
|
+
possiblyAsync = false;
|
5938
|
+
rewind(backtrackToken);
|
5939
|
+
expr = parseConditionalExpression();
|
5940
|
+
}
|
5941
|
+
|
5416
5942
|
if (matchAssign()) {
|
5417
5943
|
// 11.13.1
|
5418
5944
|
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
|
@@ -5518,118 +6044,446 @@ parseYieldExpression: true
|
|
5518
6044
|
|
5519
6045
|
// 12.2 Variable Statement
|
5520
6046
|
|
5521
|
-
function
|
5522
|
-
var
|
5523
|
-
|
6047
|
+
function parseTypeParameterDeclaration() {
|
6048
|
+
var marker = markerCreate(), paramTypes = [];
|
6049
|
+
|
6050
|
+
expect('<');
|
6051
|
+
while (!match('>')) {
|
6052
|
+
paramTypes.push(parseVariableIdentifier());
|
6053
|
+
if (!match('>')) {
|
6054
|
+
expect(',');
|
6055
|
+
}
|
6056
|
+
}
|
6057
|
+
expect('>');
|
6058
|
+
|
6059
|
+
return markerApply(marker, delegate.createTypeParameterDeclaration(
|
6060
|
+
paramTypes
|
6061
|
+
));
|
6062
|
+
}
|
6063
|
+
|
6064
|
+
function parseTypeParameterInstantiation() {
|
6065
|
+
var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
|
6066
|
+
|
6067
|
+
state.inType = true;
|
6068
|
+
|
6069
|
+
expect('<');
|
6070
|
+
while (!match('>')) {
|
6071
|
+
paramTypes.push(parseType());
|
6072
|
+
if (!match('>')) {
|
6073
|
+
expect(',');
|
6074
|
+
}
|
6075
|
+
}
|
6076
|
+
expect('>');
|
6077
|
+
|
6078
|
+
state.inType = oldInType;
|
6079
|
+
|
6080
|
+
return markerApply(marker, delegate.createTypeParameterInstantiation(
|
6081
|
+
paramTypes
|
6082
|
+
));
|
6083
|
+
}
|
6084
|
+
|
6085
|
+
function parseObjectTypeIndexer(marker, isStatic) {
|
6086
|
+
var id, key, value;
|
6087
|
+
|
6088
|
+
expect('[');
|
6089
|
+
id = parseObjectPropertyKey();
|
6090
|
+
expect(':');
|
6091
|
+
key = parseType();
|
6092
|
+
expect(']');
|
6093
|
+
expect(':');
|
6094
|
+
value = parseType();
|
6095
|
+
|
6096
|
+
return markerApply(marker, delegate.createObjectTypeIndexer(
|
6097
|
+
id,
|
6098
|
+
key,
|
6099
|
+
value,
|
6100
|
+
isStatic
|
6101
|
+
));
|
6102
|
+
}
|
6103
|
+
|
6104
|
+
function parseObjectTypeMethodish(marker) {
|
6105
|
+
var params = [], rest = null, returnType, typeParameters = null;
|
6106
|
+
if (match('<')) {
|
6107
|
+
typeParameters = parseTypeParameterDeclaration();
|
6108
|
+
}
|
6109
|
+
|
6110
|
+
expect('(');
|
6111
|
+
while (lookahead.type === Token.Identifier) {
|
6112
|
+
params.push(parseFunctionTypeParam());
|
6113
|
+
if (!match(')')) {
|
6114
|
+
expect(',');
|
6115
|
+
}
|
6116
|
+
}
|
6117
|
+
|
6118
|
+
if (match('...')) {
|
6119
|
+
lex();
|
6120
|
+
rest = parseFunctionTypeParam();
|
6121
|
+
}
|
6122
|
+
expect(')');
|
6123
|
+
expect(':');
|
6124
|
+
returnType = parseType();
|
6125
|
+
|
6126
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
6127
|
+
params,
|
6128
|
+
returnType,
|
6129
|
+
rest,
|
6130
|
+
typeParameters
|
6131
|
+
));
|
6132
|
+
}
|
6133
|
+
|
6134
|
+
function parseObjectTypeMethod(marker, isStatic, key) {
|
6135
|
+
var optional = false, value;
|
6136
|
+
value = parseObjectTypeMethodish(marker);
|
6137
|
+
|
6138
|
+
return markerApply(marker, delegate.createObjectTypeProperty(
|
6139
|
+
key,
|
6140
|
+
value,
|
6141
|
+
optional,
|
6142
|
+
isStatic
|
6143
|
+
));
|
6144
|
+
}
|
6145
|
+
|
6146
|
+
function parseObjectTypeCallProperty(marker, isStatic) {
|
6147
|
+
var valueMarker = markerCreate();
|
6148
|
+
return markerApply(marker, delegate.createObjectTypeCallProperty(
|
6149
|
+
parseObjectTypeMethodish(valueMarker),
|
6150
|
+
isStatic
|
6151
|
+
));
|
6152
|
+
}
|
6153
|
+
|
6154
|
+
function parseObjectType(allowStatic) {
|
6155
|
+
var callProperties = [], indexers = [], marker, optional = false,
|
6156
|
+
properties = [], property, propertyKey, propertyTypeAnnotation,
|
6157
|
+
token, isStatic;
|
5524
6158
|
|
5525
6159
|
expect('{');
|
5526
6160
|
|
5527
6161
|
while (!match('}')) {
|
5528
6162
|
marker = markerCreate();
|
5529
|
-
|
5530
|
-
|
5531
|
-
|
5532
|
-
|
5533
|
-
'init',
|
5534
|
-
propertyKey,
|
5535
|
-
propertyTypeAnnotation,
|
5536
|
-
isMethod,
|
5537
|
-
false
|
5538
|
-
)));
|
6163
|
+
if (allowStatic && matchContextualKeyword('static')) {
|
6164
|
+
token = lex();
|
6165
|
+
isStatic = true;
|
6166
|
+
}
|
5539
6167
|
|
5540
|
-
if (
|
5541
|
-
|
5542
|
-
|
6168
|
+
if (match('[')) {
|
6169
|
+
indexers.push(parseObjectTypeIndexer(marker, isStatic));
|
6170
|
+
} else if (match('(') || match('<')) {
|
6171
|
+
callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
|
6172
|
+
} else {
|
6173
|
+
if (isStatic && match(':')) {
|
6174
|
+
propertyKey = markerApply(marker, delegate.createIdentifier(token));
|
6175
|
+
throwErrorTolerant(token, Messages.StrictReservedWord);
|
5543
6176
|
} else {
|
5544
|
-
|
6177
|
+
propertyKey = parseObjectPropertyKey();
|
6178
|
+
}
|
6179
|
+
if (match('<') || match('(')) {
|
6180
|
+
// This is a method property
|
6181
|
+
properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
|
6182
|
+
} else {
|
6183
|
+
if (match('?')) {
|
6184
|
+
lex();
|
6185
|
+
optional = true;
|
6186
|
+
}
|
6187
|
+
expect(':');
|
6188
|
+
propertyTypeAnnotation = parseType();
|
6189
|
+
properties.push(markerApply(marker, delegate.createObjectTypeProperty(
|
6190
|
+
propertyKey,
|
6191
|
+
propertyTypeAnnotation,
|
6192
|
+
optional,
|
6193
|
+
isStatic
|
6194
|
+
)));
|
5545
6195
|
}
|
5546
6196
|
}
|
6197
|
+
|
6198
|
+
if (match(';')) {
|
6199
|
+
lex();
|
6200
|
+
} else if (!match('}')) {
|
6201
|
+
throwUnexpected(lookahead);
|
6202
|
+
}
|
5547
6203
|
}
|
5548
6204
|
|
5549
6205
|
expect('}');
|
5550
6206
|
|
5551
|
-
return delegate.createObjectTypeAnnotation(
|
6207
|
+
return delegate.createObjectTypeAnnotation(
|
6208
|
+
properties,
|
6209
|
+
indexers,
|
6210
|
+
callProperties
|
6211
|
+
);
|
6212
|
+
}
|
6213
|
+
|
6214
|
+
function parseGenericType() {
|
6215
|
+
var marker = markerCreate(), returnType = null,
|
6216
|
+
typeParameters = null, typeIdentifier,
|
6217
|
+
typeIdentifierMarker = markerCreate;
|
6218
|
+
|
6219
|
+
typeIdentifier = parseVariableIdentifier();
|
6220
|
+
|
6221
|
+
while (match('.')) {
|
6222
|
+
expect('.');
|
6223
|
+
typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
|
6224
|
+
typeIdentifier,
|
6225
|
+
parseVariableIdentifier()
|
6226
|
+
));
|
6227
|
+
}
|
6228
|
+
|
6229
|
+
if (match('<')) {
|
6230
|
+
typeParameters = parseTypeParameterInstantiation();
|
6231
|
+
}
|
6232
|
+
|
6233
|
+
return markerApply(marker, delegate.createGenericTypeAnnotation(
|
6234
|
+
typeIdentifier,
|
6235
|
+
typeParameters
|
6236
|
+
));
|
5552
6237
|
}
|
5553
6238
|
|
5554
|
-
function
|
6239
|
+
function parseVoidType() {
|
5555
6240
|
var marker = markerCreate();
|
5556
6241
|
expectKeyword('void');
|
5557
6242
|
return markerApply(marker, delegate.createVoidTypeAnnotation());
|
5558
6243
|
}
|
5559
6244
|
|
5560
|
-
function
|
5561
|
-
var marker = markerCreate()
|
6245
|
+
function parseTypeofType() {
|
6246
|
+
var argument, marker = markerCreate();
|
6247
|
+
expectKeyword('typeof');
|
6248
|
+
argument = parsePrimaryType();
|
6249
|
+
return markerApply(marker, delegate.createTypeofTypeAnnotation(
|
6250
|
+
argument
|
6251
|
+
));
|
6252
|
+
}
|
6253
|
+
|
6254
|
+
function parseTupleType() {
|
6255
|
+
var marker = markerCreate(), types = [];
|
6256
|
+
expect('[');
|
6257
|
+
// We allow trailing commas
|
6258
|
+
while (index < length && !match(']')) {
|
6259
|
+
types.push(parseType());
|
6260
|
+
if (match(']')) {
|
6261
|
+
break;
|
6262
|
+
}
|
6263
|
+
expect(',');
|
6264
|
+
}
|
6265
|
+
expect(']');
|
6266
|
+
return markerApply(marker, delegate.createTupleTypeAnnotation(
|
6267
|
+
types
|
6268
|
+
));
|
6269
|
+
}
|
5562
6270
|
|
5563
|
-
|
5564
|
-
|
5565
|
-
|
5566
|
-
|
6271
|
+
function parseFunctionTypeParam() {
|
6272
|
+
var marker = markerCreate(), name, optional = false, typeAnnotation;
|
6273
|
+
name = parseVariableIdentifier();
|
6274
|
+
if (match('?')) {
|
6275
|
+
lex();
|
6276
|
+
optional = true;
|
6277
|
+
}
|
6278
|
+
expect(':');
|
6279
|
+
typeAnnotation = parseType();
|
6280
|
+
return markerApply(marker, delegate.createFunctionTypeParam(
|
6281
|
+
name,
|
6282
|
+
typeAnnotation,
|
6283
|
+
optional
|
6284
|
+
));
|
6285
|
+
}
|
6286
|
+
|
6287
|
+
function parseFunctionTypeParams() {
|
6288
|
+
var ret = { params: [], rest: null };
|
6289
|
+
while (lookahead.type === Token.Identifier) {
|
6290
|
+
ret.params.push(parseFunctionTypeParam());
|
6291
|
+
if (!match(')')) {
|
5567
6292
|
expect(',');
|
5568
6293
|
}
|
5569
6294
|
}
|
5570
|
-
expect('>');
|
5571
6295
|
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
6296
|
+
if (match('...')) {
|
6297
|
+
lex();
|
6298
|
+
ret.rest = parseFunctionTypeParam();
|
6299
|
+
}
|
6300
|
+
return ret;
|
5575
6301
|
}
|
5576
6302
|
|
5577
|
-
|
6303
|
+
// The parsing of types roughly parallels the parsing of expressions, and
|
6304
|
+
// primary types are kind of like primary expressions...they're the
|
6305
|
+
// primitives with which other types are constructed.
|
6306
|
+
function parsePrimaryType() {
|
5578
6307
|
var typeIdentifier = null, params = null, returnType = null,
|
5579
|
-
|
5580
|
-
|
6308
|
+
marker = markerCreate(), rest = null, tmp,
|
6309
|
+
typeParameters, token, type, isGroupedType = false;
|
5581
6310
|
|
5582
|
-
|
5583
|
-
|
6311
|
+
switch (lookahead.type) {
|
6312
|
+
case Token.Identifier:
|
6313
|
+
switch (lookahead.value) {
|
6314
|
+
case 'any':
|
6315
|
+
lex();
|
6316
|
+
return markerApply(marker, delegate.createAnyTypeAnnotation());
|
6317
|
+
case 'bool': // fallthrough
|
6318
|
+
case 'boolean':
|
6319
|
+
lex();
|
6320
|
+
return markerApply(marker, delegate.createBooleanTypeAnnotation());
|
6321
|
+
case 'number':
|
6322
|
+
lex();
|
6323
|
+
return markerApply(marker, delegate.createNumberTypeAnnotation());
|
6324
|
+
case 'string':
|
6325
|
+
lex();
|
6326
|
+
return markerApply(marker, delegate.createStringTypeAnnotation());
|
6327
|
+
}
|
6328
|
+
return markerApply(marker, parseGenericType());
|
6329
|
+
case Token.Punctuator:
|
6330
|
+
switch (lookahead.value) {
|
6331
|
+
case '{':
|
6332
|
+
return markerApply(marker, parseObjectType());
|
6333
|
+
case '[':
|
6334
|
+
return parseTupleType();
|
6335
|
+
case '<':
|
6336
|
+
typeParameters = parseTypeParameterDeclaration();
|
6337
|
+
expect('(');
|
6338
|
+
tmp = parseFunctionTypeParams();
|
6339
|
+
params = tmp.params;
|
6340
|
+
rest = tmp.rest;
|
6341
|
+
expect(')');
|
6342
|
+
|
6343
|
+
expect('=>');
|
6344
|
+
|
6345
|
+
returnType = parseType();
|
6346
|
+
|
6347
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
6348
|
+
params,
|
6349
|
+
returnType,
|
6350
|
+
rest,
|
6351
|
+
typeParameters
|
6352
|
+
));
|
6353
|
+
case '(':
|
6354
|
+
lex();
|
6355
|
+
// Check to see if this is actually a grouped type
|
6356
|
+
if (!match(')') && !match('...')) {
|
6357
|
+
if (lookahead.type === Token.Identifier) {
|
6358
|
+
token = lookahead2();
|
6359
|
+
isGroupedType = token.value !== '?' && token.value !== ':';
|
6360
|
+
} else {
|
6361
|
+
isGroupedType = true;
|
6362
|
+
}
|
6363
|
+
}
|
6364
|
+
|
6365
|
+
if (isGroupedType) {
|
6366
|
+
type = parseType();
|
6367
|
+
expect(')');
|
6368
|
+
|
6369
|
+
// If we see a => next then someone was probably confused about
|
6370
|
+
// function types, so we can provide a better error message
|
6371
|
+
if (match('=>')) {
|
6372
|
+
throwError({}, Messages.ConfusedAboutFunctionType);
|
6373
|
+
}
|
6374
|
+
|
6375
|
+
return type;
|
6376
|
+
}
|
6377
|
+
|
6378
|
+
tmp = parseFunctionTypeParams();
|
6379
|
+
params = tmp.params;
|
6380
|
+
rest = tmp.rest;
|
6381
|
+
|
6382
|
+
expect(')');
|
6383
|
+
|
6384
|
+
expect('=>');
|
6385
|
+
|
6386
|
+
returnType = parseType();
|
6387
|
+
|
6388
|
+
return markerApply(marker, delegate.createFunctionTypeAnnotation(
|
6389
|
+
params,
|
6390
|
+
returnType,
|
6391
|
+
rest,
|
6392
|
+
null /* typeParameters */
|
6393
|
+
));
|
6394
|
+
}
|
6395
|
+
break;
|
6396
|
+
case Token.Keyword:
|
6397
|
+
switch (lookahead.value) {
|
6398
|
+
case 'void':
|
6399
|
+
return markerApply(marker, parseVoidType());
|
6400
|
+
case 'typeof':
|
6401
|
+
return markerApply(marker, parseTypeofType());
|
6402
|
+
}
|
6403
|
+
break;
|
6404
|
+
case Token.StringLiteral:
|
6405
|
+
token = lex();
|
6406
|
+
if (token.octal) {
|
6407
|
+
throwError(token, Messages.StrictOctalLiteral);
|
6408
|
+
}
|
6409
|
+
return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
|
6410
|
+
token
|
6411
|
+
));
|
5584
6412
|
}
|
5585
6413
|
|
6414
|
+
throwUnexpected(lookahead);
|
6415
|
+
}
|
6416
|
+
|
6417
|
+
function parsePostfixType() {
|
6418
|
+
var marker = markerCreate(), t = parsePrimaryType();
|
6419
|
+
if (match('[')) {
|
6420
|
+
expect('[');
|
6421
|
+
expect(']');
|
6422
|
+
return markerApply(marker, delegate.createArrayTypeAnnotation(t));
|
6423
|
+
}
|
6424
|
+
return t;
|
6425
|
+
}
|
6426
|
+
|
6427
|
+
function parsePrefixType() {
|
6428
|
+
var marker = markerCreate();
|
5586
6429
|
if (match('?')) {
|
5587
6430
|
lex();
|
5588
|
-
|
6431
|
+
return markerApply(marker, delegate.createNullableTypeAnnotation(
|
6432
|
+
parsePrefixType()
|
6433
|
+
));
|
5589
6434
|
}
|
6435
|
+
return parsePostfixType();
|
6436
|
+
}
|
5590
6437
|
|
5591
|
-
|
5592
|
-
|
6438
|
+
|
6439
|
+
function parseIntersectionType() {
|
6440
|
+
var marker = markerCreate(), type, types;
|
6441
|
+
type = parsePrefixType();
|
6442
|
+
types = [type];
|
6443
|
+
while (match('&')) {
|
6444
|
+
lex();
|
6445
|
+
types.push(parsePrefixType());
|
5593
6446
|
}
|
5594
6447
|
|
5595
|
-
|
5596
|
-
|
5597
|
-
|
5598
|
-
|
5599
|
-
|
5600
|
-
|
6448
|
+
return types.length === 1 ?
|
6449
|
+
type :
|
6450
|
+
markerApply(marker, delegate.createIntersectionTypeAnnotation(
|
6451
|
+
types
|
6452
|
+
));
|
6453
|
+
}
|
6454
|
+
|
6455
|
+
function parseUnionType() {
|
6456
|
+
var marker = markerCreate(), type, types;
|
6457
|
+
type = parseIntersectionType();
|
6458
|
+
types = [type];
|
6459
|
+
while (match('|')) {
|
5601
6460
|
lex();
|
5602
|
-
|
5603
|
-
|
5604
|
-
|
5605
|
-
|
5606
|
-
|
6461
|
+
types.push(parseIntersectionType());
|
6462
|
+
}
|
6463
|
+
return types.length === 1 ?
|
6464
|
+
type :
|
6465
|
+
markerApply(marker, delegate.createUnionTypeAnnotation(
|
6466
|
+
types
|
5607
6467
|
));
|
5608
|
-
|
5609
|
-
expect(',');
|
5610
|
-
}
|
5611
|
-
}
|
5612
|
-
expect(')');
|
6468
|
+
}
|
5613
6469
|
|
5614
|
-
|
5615
|
-
|
6470
|
+
function parseType() {
|
6471
|
+
var oldInType = state.inType, type;
|
6472
|
+
state.inType = true;
|
5616
6473
|
|
5617
|
-
|
5618
|
-
} else {
|
5619
|
-
if (!matchKeyword('void')) {
|
5620
|
-
throwUnexpected(lookahead);
|
5621
|
-
} else {
|
5622
|
-
return markerApply(marker, parseVoidTypeAnnotation());
|
5623
|
-
}
|
5624
|
-
}
|
6474
|
+
type = parseUnionType();
|
5625
6475
|
|
5626
|
-
|
5627
|
-
|
5628
|
-
|
5629
|
-
|
5630
|
-
|
5631
|
-
|
5632
|
-
|
6476
|
+
state.inType = oldInType;
|
6477
|
+
return type;
|
6478
|
+
}
|
6479
|
+
|
6480
|
+
function parseTypeAnnotation() {
|
6481
|
+
var marker = markerCreate(), type;
|
6482
|
+
|
6483
|
+
expect(':');
|
6484
|
+
type = parseType();
|
6485
|
+
|
6486
|
+
return markerApply(marker, delegate.createTypeAnnotation(type));
|
5633
6487
|
}
|
5634
6488
|
|
5635
6489
|
function parseVariableIdentifier() {
|
@@ -5654,14 +6508,13 @@ parseYieldExpression: true
|
|
5654
6508
|
}
|
5655
6509
|
|
5656
6510
|
if (requireTypeAnnotation || match(':')) {
|
5657
|
-
ident =
|
5658
|
-
|
5659
|
-
parseTypeAnnotation()
|
5660
|
-
));
|
6511
|
+
ident.typeAnnotation = parseTypeAnnotation();
|
6512
|
+
ident = markerApply(marker, ident);
|
5661
6513
|
}
|
5662
6514
|
|
5663
6515
|
if (isOptionalParam) {
|
5664
|
-
ident =
|
6516
|
+
ident.optional = true;
|
6517
|
+
ident = markerApply(marker, ident);
|
5665
6518
|
}
|
5666
6519
|
|
5667
6520
|
return ident;
|
@@ -5670,13 +6523,22 @@ parseYieldExpression: true
|
|
5670
6523
|
function parseVariableDeclaration(kind) {
|
5671
6524
|
var id,
|
5672
6525
|
marker = markerCreate(),
|
5673
|
-
init = null
|
6526
|
+
init = null,
|
6527
|
+
typeAnnotationMarker = markerCreate();
|
5674
6528
|
if (match('{')) {
|
5675
6529
|
id = parseObjectInitialiser();
|
5676
6530
|
reinterpretAsAssignmentBindingPattern(id);
|
6531
|
+
if (match(':')) {
|
6532
|
+
id.typeAnnotation = parseTypeAnnotation();
|
6533
|
+
markerApply(typeAnnotationMarker, id);
|
6534
|
+
}
|
5677
6535
|
} else if (match('[')) {
|
5678
6536
|
id = parseArrayInitialiser();
|
5679
6537
|
reinterpretAsAssignmentBindingPattern(id);
|
6538
|
+
if (match(':')) {
|
6539
|
+
id.typeAnnotation = parseTypeAnnotation();
|
6540
|
+
markerApply(typeAnnotationMarker, id);
|
6541
|
+
}
|
5680
6542
|
} else {
|
5681
6543
|
id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
|
5682
6544
|
// 12.2.1
|
@@ -5741,41 +6603,18 @@ parseYieldExpression: true
|
|
5741
6603
|
return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
|
5742
6604
|
}
|
5743
6605
|
|
5744
|
-
//
|
5745
|
-
|
5746
|
-
function parseModuleDeclaration() {
|
5747
|
-
var id, src, body, marker = markerCreate();
|
5748
|
-
|
5749
|
-
lex(); // 'module'
|
5750
|
-
|
5751
|
-
if (peekLineTerminator()) {
|
5752
|
-
throwError({}, Messages.NewlineAfterModule);
|
5753
|
-
}
|
5754
|
-
|
5755
|
-
switch (lookahead.type) {
|
6606
|
+
// people.mozilla.org/~jorendorff/es6-draft.html
|
5756
6607
|
|
5757
|
-
|
5758
|
-
|
5759
|
-
|
5760
|
-
src = null;
|
5761
|
-
break;
|
6608
|
+
function parseModuleSpecifier() {
|
6609
|
+
var marker = markerCreate(),
|
6610
|
+
specifier;
|
5762
6611
|
|
5763
|
-
|
5764
|
-
|
5765
|
-
body = null;
|
5766
|
-
if (!matchContextualKeyword('from')) {
|
5767
|
-
throwUnexpected(lex());
|
5768
|
-
}
|
5769
|
-
lex();
|
5770
|
-
src = parsePrimaryExpression();
|
5771
|
-
if (src.type !== Syntax.Literal) {
|
5772
|
-
throwError({}, Messages.InvalidModuleSpecifier);
|
5773
|
-
}
|
5774
|
-
break;
|
6612
|
+
if (lookahead.type !== Token.StringLiteral) {
|
6613
|
+
throwError({}, Messages.InvalidModuleSpecifier);
|
5775
6614
|
}
|
5776
|
-
|
5777
|
-
|
5778
|
-
return markerApply(marker,
|
6615
|
+
specifier = delegate.createModuleSpecifier(lookahead);
|
6616
|
+
lex();
|
6617
|
+
return markerApply(marker, specifier);
|
5779
6618
|
}
|
5780
6619
|
|
5781
6620
|
function parseExportBatchSpecifier() {
|
@@ -5785,9 +6624,14 @@ parseYieldExpression: true
|
|
5785
6624
|
}
|
5786
6625
|
|
5787
6626
|
function parseExportSpecifier() {
|
5788
|
-
var id, name = null, marker = markerCreate();
|
5789
|
-
|
5790
|
-
|
6627
|
+
var id, name = null, marker = markerCreate(), from;
|
6628
|
+
if (matchKeyword('default')) {
|
6629
|
+
lex();
|
6630
|
+
id = markerApply(marker, delegate.createIdentifier('default'));
|
6631
|
+
// export {default} from "something";
|
6632
|
+
} else {
|
6633
|
+
id = parseVariableIdentifier();
|
6634
|
+
}
|
5791
6635
|
if (matchContextualKeyword('as')) {
|
5792
6636
|
lex();
|
5793
6637
|
name = parseNonComputedProperty();
|
@@ -5797,104 +6641,207 @@ parseYieldExpression: true
|
|
5797
6641
|
}
|
5798
6642
|
|
5799
6643
|
function parseExportDeclaration() {
|
5800
|
-
var
|
6644
|
+
var backtrackToken, id, previousAllowKeyword, declaration = null,
|
6645
|
+
isExportFromIdentifier,
|
6646
|
+
src = null, specifiers = [],
|
5801
6647
|
marker = markerCreate();
|
5802
6648
|
|
5803
6649
|
expectKeyword('export');
|
5804
6650
|
|
6651
|
+
if (matchKeyword('default')) {
|
6652
|
+
// covers:
|
6653
|
+
// export default ...
|
6654
|
+
lex();
|
6655
|
+
if (matchKeyword('function') || matchKeyword('class')) {
|
6656
|
+
backtrackToken = lookahead;
|
6657
|
+
lex();
|
6658
|
+
if (isIdentifierName(lookahead)) {
|
6659
|
+
// covers:
|
6660
|
+
// export default function foo () {}
|
6661
|
+
// export default class foo {}
|
6662
|
+
id = parseNonComputedProperty();
|
6663
|
+
rewind(backtrackToken);
|
6664
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
|
6665
|
+
}
|
6666
|
+
// covers:
|
6667
|
+
// export default function () {}
|
6668
|
+
// export default class {}
|
6669
|
+
rewind(backtrackToken);
|
6670
|
+
switch (lookahead.value) {
|
6671
|
+
case 'class':
|
6672
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
|
6673
|
+
case 'function':
|
6674
|
+
return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
|
6675
|
+
}
|
6676
|
+
}
|
6677
|
+
|
6678
|
+
if (matchContextualKeyword('from')) {
|
6679
|
+
throwError({}, Messages.UnexpectedToken, lookahead.value);
|
6680
|
+
}
|
6681
|
+
|
6682
|
+
// covers:
|
6683
|
+
// export default {};
|
6684
|
+
// export default [];
|
6685
|
+
if (match('{')) {
|
6686
|
+
declaration = parseObjectInitialiser();
|
6687
|
+
} else if (match('[')) {
|
6688
|
+
declaration = parseArrayInitialiser();
|
6689
|
+
} else {
|
6690
|
+
declaration = parseAssignmentExpression();
|
6691
|
+
}
|
6692
|
+
consumeSemicolon();
|
6693
|
+
return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
|
6694
|
+
}
|
6695
|
+
|
6696
|
+
// non-default export
|
5805
6697
|
if (lookahead.type === Token.Keyword) {
|
6698
|
+
// covers:
|
6699
|
+
// export var f = 1;
|
5806
6700
|
switch (lookahead.value) {
|
5807
6701
|
case 'let':
|
5808
6702
|
case 'const':
|
5809
6703
|
case 'var':
|
5810
6704
|
case 'class':
|
5811
6705
|
case 'function':
|
5812
|
-
return markerApply(marker, delegate.createExportDeclaration(parseSourceElement(),
|
6706
|
+
return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
|
5813
6707
|
}
|
5814
6708
|
}
|
5815
6709
|
|
5816
|
-
if (
|
5817
|
-
|
5818
|
-
|
5819
|
-
|
5820
|
-
|
5821
|
-
|
6710
|
+
if (match('*')) {
|
6711
|
+
// covers:
|
6712
|
+
// export * from "foo";
|
6713
|
+
specifiers.push(parseExportBatchSpecifier());
|
6714
|
+
|
6715
|
+
if (!matchContextualKeyword('from')) {
|
6716
|
+
throwError({}, lookahead.value ?
|
6717
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
6718
|
+
}
|
6719
|
+
lex();
|
6720
|
+
src = parseModuleSpecifier();
|
6721
|
+
consumeSemicolon();
|
6722
|
+
|
6723
|
+
return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
|
5822
6724
|
}
|
5823
6725
|
|
5824
|
-
|
5825
|
-
|
6726
|
+
expect('{');
|
6727
|
+
do {
|
6728
|
+
isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
|
6729
|
+
specifiers.push(parseExportSpecifier());
|
6730
|
+
} while (match(',') && lex());
|
6731
|
+
expect('}');
|
5826
6732
|
|
5827
|
-
if (
|
5828
|
-
|
6733
|
+
if (matchContextualKeyword('from')) {
|
6734
|
+
// covering:
|
6735
|
+
// export {default} from "foo";
|
6736
|
+
// export {foo} from "foo";
|
6737
|
+
lex();
|
6738
|
+
src = parseModuleSpecifier();
|
6739
|
+
consumeSemicolon();
|
6740
|
+
} else if (isExportFromIdentifier) {
|
6741
|
+
// covering:
|
6742
|
+
// export {default}; // missing fromClause
|
6743
|
+
throwError({}, lookahead.value ?
|
6744
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
5829
6745
|
} else {
|
5830
|
-
|
5831
|
-
|
5832
|
-
|
5833
|
-
} while (match(',') && lex());
|
5834
|
-
expect('}');
|
6746
|
+
// cover
|
6747
|
+
// export {foo};
|
6748
|
+
consumeSemicolon();
|
5835
6749
|
}
|
6750
|
+
return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
|
6751
|
+
}
|
5836
6752
|
|
5837
|
-
|
6753
|
+
|
6754
|
+
function parseImportSpecifier() {
|
6755
|
+
// import {<foo as bar>} ...;
|
6756
|
+
var id, name = null, marker = markerCreate();
|
6757
|
+
|
6758
|
+
id = parseNonComputedProperty();
|
6759
|
+
if (matchContextualKeyword('as')) {
|
5838
6760
|
lex();
|
5839
|
-
|
5840
|
-
if (src.type !== Syntax.Literal) {
|
5841
|
-
throwError({}, Messages.InvalidModuleSpecifier);
|
5842
|
-
}
|
6761
|
+
name = parseVariableIdentifier();
|
5843
6762
|
}
|
5844
6763
|
|
5845
|
-
|
6764
|
+
return markerApply(marker, delegate.createImportSpecifier(id, name));
|
6765
|
+
}
|
5846
6766
|
|
5847
|
-
|
6767
|
+
function parseNamedImports() {
|
6768
|
+
var specifiers = [];
|
6769
|
+
// {foo, bar as bas}
|
6770
|
+
expect('{');
|
6771
|
+
do {
|
6772
|
+
specifiers.push(parseImportSpecifier());
|
6773
|
+
} while (match(',') && lex());
|
6774
|
+
expect('}');
|
6775
|
+
return specifiers;
|
6776
|
+
}
|
6777
|
+
|
6778
|
+
function parseImportDefaultSpecifier() {
|
6779
|
+
// import <foo> ...;
|
6780
|
+
var id, marker = markerCreate();
|
6781
|
+
|
6782
|
+
id = parseNonComputedProperty();
|
6783
|
+
|
6784
|
+
return markerApply(marker, delegate.createImportDefaultSpecifier(id));
|
6785
|
+
}
|
6786
|
+
|
6787
|
+
function parseImportNamespaceSpecifier() {
|
6788
|
+
// import <* as foo> ...;
|
6789
|
+
var id, marker = markerCreate();
|
6790
|
+
|
6791
|
+
expect('*');
|
6792
|
+
if (!matchContextualKeyword('as')) {
|
6793
|
+
throwError({}, Messages.NoAsAfterImportNamespace);
|
6794
|
+
}
|
6795
|
+
lex();
|
6796
|
+
id = parseNonComputedProperty();
|
6797
|
+
|
6798
|
+
return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
|
5848
6799
|
}
|
5849
6800
|
|
5850
6801
|
function parseImportDeclaration() {
|
5851
|
-
var specifiers,
|
6802
|
+
var specifiers, src, marker = markerCreate();
|
5852
6803
|
|
5853
6804
|
expectKeyword('import');
|
5854
6805
|
specifiers = [];
|
5855
6806
|
|
5856
|
-
if (
|
5857
|
-
|
5858
|
-
|
6807
|
+
if (lookahead.type === Token.StringLiteral) {
|
6808
|
+
// covers:
|
6809
|
+
// import "foo";
|
6810
|
+
src = parseModuleSpecifier();
|
6811
|
+
consumeSemicolon();
|
6812
|
+
return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
|
6813
|
+
}
|
5859
6814
|
|
5860
|
-
|
5861
|
-
|
6815
|
+
if (!matchKeyword('default') && isIdentifierName(lookahead)) {
|
6816
|
+
// covers:
|
6817
|
+
// import foo
|
6818
|
+
// import foo, ...
|
6819
|
+
specifiers.push(parseImportDefaultSpecifier());
|
6820
|
+
if (match(',')) {
|
6821
|
+
lex();
|
5862
6822
|
}
|
5863
|
-
|
6823
|
+
}
|
6824
|
+
if (match('*')) {
|
6825
|
+
// covers:
|
6826
|
+
// import foo, * as foo
|
6827
|
+
// import * as foo
|
6828
|
+
specifiers.push(parseImportNamespaceSpecifier());
|
5864
6829
|
} else if (match('{')) {
|
5865
|
-
|
5866
|
-
|
5867
|
-
|
5868
|
-
|
5869
|
-
} while (match(',') && lex());
|
5870
|
-
expect('}');
|
5871
|
-
|
5872
|
-
if (!matchContextualKeyword('from')) {
|
5873
|
-
throwError({}, Messages.NoFromAfterImport);
|
5874
|
-
}
|
5875
|
-
lex();
|
6830
|
+
// covers:
|
6831
|
+
// import foo, {bar}
|
6832
|
+
// import {bar}
|
6833
|
+
specifiers = specifiers.concat(parseNamedImports());
|
5876
6834
|
}
|
5877
6835
|
|
5878
|
-
|
5879
|
-
|
5880
|
-
|
6836
|
+
if (!matchContextualKeyword('from')) {
|
6837
|
+
throwError({}, lookahead.value ?
|
6838
|
+
Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
5881
6839
|
}
|
5882
|
-
|
6840
|
+
lex();
|
6841
|
+
src = parseModuleSpecifier();
|
5883
6842
|
consumeSemicolon();
|
5884
6843
|
|
5885
|
-
return markerApply(marker, delegate.createImportDeclaration(specifiers,
|
5886
|
-
}
|
5887
|
-
|
5888
|
-
function parseImportSpecifier() {
|
5889
|
-
var id, name = null, marker = markerCreate();
|
5890
|
-
|
5891
|
-
id = parseNonComputedProperty();
|
5892
|
-
if (matchContextualKeyword('as')) {
|
5893
|
-
lex();
|
5894
|
-
name = parseVariableIdentifier();
|
5895
|
-
}
|
5896
|
-
|
5897
|
-
return markerApply(marker, delegate.createImportSpecifier(id, name));
|
6844
|
+
return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
|
5898
6845
|
}
|
5899
6846
|
|
5900
6847
|
// 12.3 Empty Statement
|
@@ -6447,6 +7394,10 @@ parseYieldExpression: true
|
|
6447
7394
|
}
|
6448
7395
|
}
|
6449
7396
|
|
7397
|
+
if (matchAsyncFuncExprOrDecl()) {
|
7398
|
+
return parseFunctionDeclaration();
|
7399
|
+
}
|
7400
|
+
|
6450
7401
|
marker = markerCreate();
|
6451
7402
|
expr = parseExpression();
|
6452
7403
|
|
@@ -6572,7 +7523,7 @@ parseYieldExpression: true
|
|
6572
7523
|
}
|
6573
7524
|
|
6574
7525
|
function parseParam(options) {
|
6575
|
-
var token, rest, param, def;
|
7526
|
+
var marker, token, rest, param, def;
|
6576
7527
|
|
6577
7528
|
token = lookahead;
|
6578
7529
|
if (token.value === '...') {
|
@@ -6581,19 +7532,31 @@ parseYieldExpression: true
|
|
6581
7532
|
}
|
6582
7533
|
|
6583
7534
|
if (match('[')) {
|
7535
|
+
marker = markerCreate();
|
6584
7536
|
param = parseArrayInitialiser();
|
6585
7537
|
reinterpretAsDestructuredParameter(options, param);
|
7538
|
+
if (match(':')) {
|
7539
|
+
param.typeAnnotation = parseTypeAnnotation();
|
7540
|
+
markerApply(marker, param);
|
7541
|
+
}
|
6586
7542
|
} else if (match('{')) {
|
7543
|
+
marker = markerCreate();
|
6587
7544
|
if (rest) {
|
6588
7545
|
throwError({}, Messages.ObjectPatternAsRestParameter);
|
6589
7546
|
}
|
6590
7547
|
param = parseObjectInitialiser();
|
6591
7548
|
reinterpretAsDestructuredParameter(options, param);
|
7549
|
+
if (match(':')) {
|
7550
|
+
param.typeAnnotation = parseTypeAnnotation();
|
7551
|
+
markerApply(marker, param);
|
7552
|
+
}
|
6592
7553
|
} else {
|
6593
|
-
// Typing rest params is awkward, so punting on that for now
|
6594
7554
|
param =
|
6595
7555
|
rest
|
6596
|
-
?
|
7556
|
+
? parseTypeAnnotatableIdentifier(
|
7557
|
+
false, /* requireTypeAnnotation */
|
7558
|
+
false /* canBeOptionalParam */
|
7559
|
+
)
|
6597
7560
|
: parseTypeAnnotatableIdentifier(
|
6598
7561
|
false, /* requireTypeAnnotation */
|
6599
7562
|
true /* canBeOptionalParam */
|
@@ -6661,8 +7624,15 @@ parseYieldExpression: true
|
|
6661
7624
|
}
|
6662
7625
|
|
6663
7626
|
function parseFunctionDeclaration() {
|
6664
|
-
var id, body, token, tmp, firstRestricted, message,
|
6665
|
-
|
7627
|
+
var id, body, token, tmp, firstRestricted, message, generator, isAsync,
|
7628
|
+
previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
7629
|
+
marker = markerCreate(), typeParameters;
|
7630
|
+
|
7631
|
+
isAsync = false;
|
7632
|
+
if (matchAsync()) {
|
7633
|
+
lex();
|
7634
|
+
isAsync = true;
|
7635
|
+
}
|
6666
7636
|
|
6667
7637
|
expectKeyword('function');
|
6668
7638
|
|
@@ -6677,7 +7647,7 @@ parseYieldExpression: true
|
|
6677
7647
|
id = parseVariableIdentifier();
|
6678
7648
|
|
6679
7649
|
if (match('<')) {
|
6680
|
-
|
7650
|
+
typeParameters = parseTypeParameterDeclaration();
|
6681
7651
|
}
|
6682
7652
|
|
6683
7653
|
if (strict) {
|
@@ -6703,6 +7673,8 @@ parseYieldExpression: true
|
|
6703
7673
|
previousStrict = strict;
|
6704
7674
|
previousYieldAllowed = state.yieldAllowed;
|
6705
7675
|
state.yieldAllowed = generator;
|
7676
|
+
previousAwaitAllowed = state.awaitAllowed;
|
7677
|
+
state.awaitAllowed = isAsync;
|
6706
7678
|
|
6707
7679
|
body = parseFunctionSourceElements();
|
6708
7680
|
|
@@ -6714,14 +7686,35 @@ parseYieldExpression: true
|
|
6714
7686
|
}
|
6715
7687
|
strict = previousStrict;
|
6716
7688
|
state.yieldAllowed = previousYieldAllowed;
|
7689
|
+
state.awaitAllowed = previousAwaitAllowed;
|
6717
7690
|
|
6718
|
-
return markerApply(
|
6719
|
-
|
7691
|
+
return markerApply(
|
7692
|
+
marker,
|
7693
|
+
delegate.createFunctionDeclaration(
|
7694
|
+
id,
|
7695
|
+
tmp.params,
|
7696
|
+
tmp.defaults,
|
7697
|
+
body,
|
7698
|
+
tmp.rest,
|
7699
|
+
generator,
|
7700
|
+
false,
|
7701
|
+
isAsync,
|
7702
|
+
tmp.returnType,
|
7703
|
+
typeParameters
|
7704
|
+
)
|
7705
|
+
);
|
6720
7706
|
}
|
6721
7707
|
|
6722
7708
|
function parseFunctionExpression() {
|
6723
|
-
var token, id = null, firstRestricted, message, tmp, body,
|
6724
|
-
|
7709
|
+
var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
|
7710
|
+
previousStrict, previousYieldAllowed, previousAwaitAllowed,
|
7711
|
+
marker = markerCreate(), typeParameters;
|
7712
|
+
|
7713
|
+
isAsync = false;
|
7714
|
+
if (matchAsync()) {
|
7715
|
+
lex();
|
7716
|
+
isAsync = true;
|
7717
|
+
}
|
6725
7718
|
|
6726
7719
|
expectKeyword('function');
|
6727
7720
|
|
@@ -6753,7 +7746,7 @@ parseYieldExpression: true
|
|
6753
7746
|
}
|
6754
7747
|
|
6755
7748
|
if (match('<')) {
|
6756
|
-
|
7749
|
+
typeParameters = parseTypeParameterDeclaration();
|
6757
7750
|
}
|
6758
7751
|
}
|
6759
7752
|
|
@@ -6766,6 +7759,8 @@ parseYieldExpression: true
|
|
6766
7759
|
previousStrict = strict;
|
6767
7760
|
previousYieldAllowed = state.yieldAllowed;
|
6768
7761
|
state.yieldAllowed = generator;
|
7762
|
+
previousAwaitAllowed = state.awaitAllowed;
|
7763
|
+
state.awaitAllowed = isAsync;
|
6769
7764
|
|
6770
7765
|
body = parseFunctionSourceElements();
|
6771
7766
|
|
@@ -6777,20 +7772,29 @@ parseYieldExpression: true
|
|
6777
7772
|
}
|
6778
7773
|
strict = previousStrict;
|
6779
7774
|
state.yieldAllowed = previousYieldAllowed;
|
7775
|
+
state.awaitAllowed = previousAwaitAllowed;
|
6780
7776
|
|
6781
|
-
return markerApply(
|
6782
|
-
|
7777
|
+
return markerApply(
|
7778
|
+
marker,
|
7779
|
+
delegate.createFunctionExpression(
|
7780
|
+
id,
|
7781
|
+
tmp.params,
|
7782
|
+
tmp.defaults,
|
7783
|
+
body,
|
7784
|
+
tmp.rest,
|
7785
|
+
generator,
|
7786
|
+
false,
|
7787
|
+
isAsync,
|
7788
|
+
tmp.returnType,
|
7789
|
+
typeParameters
|
7790
|
+
)
|
7791
|
+
);
|
6783
7792
|
}
|
6784
7793
|
|
6785
7794
|
function parseYieldExpression() {
|
6786
|
-
var
|
6787
|
-
|
6788
|
-
yieldToken = lex();
|
6789
|
-
assert(yieldToken.value === 'yield', 'Called parseYieldExpression with non-yield lookahead.');
|
7795
|
+
var delegateFlag, expr, marker = markerCreate();
|
6790
7796
|
|
6791
|
-
|
6792
|
-
throwErrorTolerant({}, Messages.IllegalYield);
|
6793
|
-
}
|
7797
|
+
expectKeyword('yield', !strict);
|
6794
7798
|
|
6795
7799
|
delegateFlag = false;
|
6796
7800
|
if (match('*')) {
|
@@ -6803,35 +7807,34 @@ parseYieldExpression: true
|
|
6803
7807
|
return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
|
6804
7808
|
}
|
6805
7809
|
|
7810
|
+
function parseAwaitExpression() {
|
7811
|
+
var expr, marker = markerCreate();
|
7812
|
+
expectContextualKeyword('await');
|
7813
|
+
expr = parseAssignmentExpression();
|
7814
|
+
return markerApply(marker, delegate.createAwaitExpression(expr));
|
7815
|
+
}
|
7816
|
+
|
6806
7817
|
// 14 Classes
|
6807
7818
|
|
6808
|
-
function parseMethodDefinition(existingPropNames) {
|
6809
|
-
var token,
|
6810
|
-
|
6811
|
-
|
7819
|
+
function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
|
7820
|
+
var token, param, propType, isValidDuplicateProp = false,
|
7821
|
+
isAsync, typeParameters, tokenValue, returnType,
|
7822
|
+
annotationMarker;
|
6812
7823
|
|
6813
|
-
|
6814
|
-
propType = ClassPropertyType["static"];
|
6815
|
-
lex();
|
6816
|
-
} else {
|
6817
|
-
propType = ClassPropertyType.prototype;
|
6818
|
-
}
|
7824
|
+
propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
|
6819
7825
|
|
6820
|
-
if (
|
6821
|
-
|
6822
|
-
return markerApply(marker, delegate.createMethodDefinition(
|
7826
|
+
if (generator) {
|
7827
|
+
return delegate.createMethodDefinition(
|
6823
7828
|
propType,
|
6824
7829
|
'',
|
6825
|
-
|
7830
|
+
key,
|
6826
7831
|
parsePropertyMethodFunction({ generator: true })
|
6827
|
-
)
|
7832
|
+
);
|
6828
7833
|
}
|
6829
7834
|
|
6830
|
-
|
6831
|
-
//parametricTypeMarker = markerCreate();
|
6832
|
-
key = parseObjectPropertyKey();
|
7835
|
+
tokenValue = key.type === 'Identifier' && key.name;
|
6833
7836
|
|
6834
|
-
if (
|
7837
|
+
if (tokenValue === 'get' && !match('(')) {
|
6835
7838
|
key = parseObjectPropertyKey();
|
6836
7839
|
|
6837
7840
|
// It is a syntax error if any other properties have a name
|
@@ -6854,14 +7857,17 @@ parseYieldExpression: true
|
|
6854
7857
|
|
6855
7858
|
expect('(');
|
6856
7859
|
expect(')');
|
6857
|
-
|
7860
|
+
if (match(':')) {
|
7861
|
+
returnType = parseTypeAnnotation();
|
7862
|
+
}
|
7863
|
+
return delegate.createMethodDefinition(
|
6858
7864
|
propType,
|
6859
7865
|
'get',
|
6860
7866
|
key,
|
6861
|
-
parsePropertyFunction({ generator: false })
|
6862
|
-
)
|
7867
|
+
parsePropertyFunction({ generator: false, returnType: returnType })
|
7868
|
+
);
|
6863
7869
|
}
|
6864
|
-
if (
|
7870
|
+
if (tokenValue === 'set' && !match('(')) {
|
6865
7871
|
key = parseObjectPropertyKey();
|
6866
7872
|
|
6867
7873
|
// It is a syntax error if any other properties have a name
|
@@ -6886,16 +7892,29 @@ parseYieldExpression: true
|
|
6886
7892
|
token = lookahead;
|
6887
7893
|
param = [ parseTypeAnnotatableIdentifier() ];
|
6888
7894
|
expect(')');
|
6889
|
-
|
7895
|
+
if (match(':')) {
|
7896
|
+
returnType = parseTypeAnnotation();
|
7897
|
+
}
|
7898
|
+
return delegate.createMethodDefinition(
|
6890
7899
|
propType,
|
6891
7900
|
'set',
|
6892
7901
|
key,
|
6893
|
-
parsePropertyFunction({
|
6894
|
-
|
7902
|
+
parsePropertyFunction({
|
7903
|
+
params: param,
|
7904
|
+
generator: false,
|
7905
|
+
name: token,
|
7906
|
+
returnType: returnType
|
7907
|
+
})
|
7908
|
+
);
|
6895
7909
|
}
|
6896
7910
|
|
6897
7911
|
if (match('<')) {
|
6898
|
-
|
7912
|
+
typeParameters = parseTypeParameterDeclaration();
|
7913
|
+
}
|
7914
|
+
|
7915
|
+
isAsync = tokenValue === 'async' && !match('(');
|
7916
|
+
if (isAsync) {
|
7917
|
+
key = parseObjectPropertyKey();
|
6899
7918
|
}
|
6900
7919
|
|
6901
7920
|
// It is a syntax error if any other properties have the same name as a
|
@@ -6907,42 +7926,64 @@ parseYieldExpression: true
|
|
6907
7926
|
}
|
6908
7927
|
existingPropNames[propType][key.name].data = true;
|
6909
7928
|
|
6910
|
-
return
|
7929
|
+
return delegate.createMethodDefinition(
|
6911
7930
|
propType,
|
6912
7931
|
'',
|
6913
7932
|
key,
|
6914
7933
|
parsePropertyMethodFunction({
|
6915
7934
|
generator: false,
|
6916
|
-
|
7935
|
+
async: isAsync,
|
7936
|
+
typeParameters: typeParameters
|
6917
7937
|
})
|
6918
|
-
)
|
7938
|
+
);
|
6919
7939
|
}
|
6920
7940
|
|
6921
|
-
function parseClassProperty(existingPropNames) {
|
6922
|
-
var
|
7941
|
+
function parseClassProperty(existingPropNames, key, computed, isStatic) {
|
7942
|
+
var typeAnnotation;
|
6923
7943
|
|
6924
|
-
|
7944
|
+
typeAnnotation = parseTypeAnnotation();
|
6925
7945
|
expect(';');
|
6926
7946
|
|
6927
|
-
return
|
6928
|
-
|
6929
|
-
|
7947
|
+
return delegate.createClassProperty(
|
7948
|
+
key,
|
7949
|
+
typeAnnotation,
|
7950
|
+
computed,
|
7951
|
+
isStatic
|
7952
|
+
);
|
6930
7953
|
}
|
6931
7954
|
|
6932
7955
|
function parseClassElement(existingProps) {
|
7956
|
+
var computed, generator = false, key, marker = markerCreate(),
|
7957
|
+
isStatic = false;
|
6933
7958
|
if (match(';')) {
|
6934
7959
|
lex();
|
6935
7960
|
return;
|
6936
7961
|
}
|
6937
7962
|
|
6938
|
-
|
6939
|
-
|
6940
|
-
|
6941
|
-
return parseClassProperty(existingProps);
|
6942
|
-
}
|
7963
|
+
if (lookahead.value === 'static') {
|
7964
|
+
lex();
|
7965
|
+
isStatic = true;
|
6943
7966
|
}
|
6944
7967
|
|
6945
|
-
|
7968
|
+
if (match('*')) {
|
7969
|
+
lex();
|
7970
|
+
generator = true;
|
7971
|
+
}
|
7972
|
+
|
7973
|
+
computed = (lookahead.value === '[');
|
7974
|
+
key = parseObjectPropertyKey();
|
7975
|
+
|
7976
|
+
if (!generator && lookahead.value === ':') {
|
7977
|
+
return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
|
7978
|
+
}
|
7979
|
+
|
7980
|
+
return markerApply(marker, parseMethodDefinition(
|
7981
|
+
existingProps,
|
7982
|
+
key,
|
7983
|
+
isStatic,
|
7984
|
+
generator,
|
7985
|
+
computed
|
7986
|
+
));
|
6946
7987
|
}
|
6947
7988
|
|
6948
7989
|
function parseClassBody() {
|
@@ -6969,66 +8010,109 @@ parseYieldExpression: true
|
|
6969
8010
|
return markerApply(marker, delegate.createClassBody(classElements));
|
6970
8011
|
}
|
6971
8012
|
|
8013
|
+
function parseClassImplements() {
|
8014
|
+
var id, implemented = [], marker, typeParameters;
|
8015
|
+
expectContextualKeyword('implements');
|
8016
|
+
while (index < length) {
|
8017
|
+
marker = markerCreate();
|
8018
|
+
id = parseVariableIdentifier();
|
8019
|
+
if (match('<')) {
|
8020
|
+
typeParameters = parseTypeParameterInstantiation();
|
8021
|
+
} else {
|
8022
|
+
typeParameters = null;
|
8023
|
+
}
|
8024
|
+
implemented.push(markerApply(marker, delegate.createClassImplements(
|
8025
|
+
id,
|
8026
|
+
typeParameters
|
8027
|
+
)));
|
8028
|
+
if (!match(',')) {
|
8029
|
+
break;
|
8030
|
+
}
|
8031
|
+
expect(',');
|
8032
|
+
}
|
8033
|
+
return implemented;
|
8034
|
+
}
|
8035
|
+
|
6972
8036
|
function parseClassExpression() {
|
6973
|
-
var id, previousYieldAllowed, superClass = null,
|
6974
|
-
|
8037
|
+
var id, implemented, previousYieldAllowed, superClass = null,
|
8038
|
+
superTypeParameters, marker = markerCreate(), typeParameters;
|
6975
8039
|
|
6976
8040
|
expectKeyword('class');
|
6977
8041
|
|
6978
|
-
if (!matchKeyword('extends') && !match('{')) {
|
8042
|
+
if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
|
6979
8043
|
id = parseVariableIdentifier();
|
6980
8044
|
}
|
6981
8045
|
|
6982
8046
|
if (match('<')) {
|
6983
|
-
|
8047
|
+
typeParameters = parseTypeParameterDeclaration();
|
6984
8048
|
}
|
6985
8049
|
|
6986
8050
|
if (matchKeyword('extends')) {
|
6987
8051
|
expectKeyword('extends');
|
6988
8052
|
previousYieldAllowed = state.yieldAllowed;
|
6989
8053
|
state.yieldAllowed = false;
|
6990
|
-
superClass =
|
8054
|
+
superClass = parseLeftHandSideExpressionAllowCall();
|
8055
|
+
if (match('<')) {
|
8056
|
+
superTypeParameters = parseTypeParameterInstantiation();
|
8057
|
+
}
|
6991
8058
|
state.yieldAllowed = previousYieldAllowed;
|
6992
8059
|
}
|
6993
8060
|
|
6994
|
-
|
8061
|
+
if (matchContextualKeyword('implements')) {
|
8062
|
+
implemented = parseClassImplements();
|
8063
|
+
}
|
8064
|
+
|
8065
|
+
return markerApply(marker, delegate.createClassExpression(
|
8066
|
+
id,
|
8067
|
+
superClass,
|
8068
|
+
parseClassBody(),
|
8069
|
+
typeParameters,
|
8070
|
+
superTypeParameters,
|
8071
|
+
implemented
|
8072
|
+
));
|
6995
8073
|
}
|
6996
8074
|
|
6997
8075
|
function parseClassDeclaration() {
|
6998
|
-
var id, previousYieldAllowed, superClass = null,
|
6999
|
-
|
8076
|
+
var id, implemented, previousYieldAllowed, superClass = null,
|
8077
|
+
superTypeParameters, marker = markerCreate(), typeParameters;
|
7000
8078
|
|
7001
8079
|
expectKeyword('class');
|
7002
8080
|
|
7003
8081
|
id = parseVariableIdentifier();
|
7004
8082
|
|
7005
8083
|
if (match('<')) {
|
7006
|
-
|
8084
|
+
typeParameters = parseTypeParameterDeclaration();
|
7007
8085
|
}
|
7008
8086
|
|
7009
8087
|
if (matchKeyword('extends')) {
|
7010
8088
|
expectKeyword('extends');
|
7011
8089
|
previousYieldAllowed = state.yieldAllowed;
|
7012
8090
|
state.yieldAllowed = false;
|
7013
|
-
superClass =
|
8091
|
+
superClass = parseLeftHandSideExpressionAllowCall();
|
8092
|
+
if (match('<')) {
|
8093
|
+
superTypeParameters = parseTypeParameterInstantiation();
|
8094
|
+
}
|
7014
8095
|
state.yieldAllowed = previousYieldAllowed;
|
7015
8096
|
}
|
7016
8097
|
|
7017
|
-
|
8098
|
+
if (matchContextualKeyword('implements')) {
|
8099
|
+
implemented = parseClassImplements();
|
8100
|
+
}
|
8101
|
+
|
8102
|
+
return markerApply(marker, delegate.createClassDeclaration(
|
8103
|
+
id,
|
8104
|
+
superClass,
|
8105
|
+
parseClassBody(),
|
8106
|
+
typeParameters,
|
8107
|
+
superTypeParameters,
|
8108
|
+
implemented
|
8109
|
+
));
|
7018
8110
|
}
|
7019
8111
|
|
7020
8112
|
// 15 Program
|
7021
8113
|
|
7022
|
-
function matchModuleDeclaration() {
|
7023
|
-
var id;
|
7024
|
-
if (matchContextualKeyword('module')) {
|
7025
|
-
id = lookahead2();
|
7026
|
-
return id.type === Token.StringLiteral || id.type === Token.Identifier;
|
7027
|
-
}
|
7028
|
-
return false;
|
7029
|
-
}
|
7030
|
-
|
7031
8114
|
function parseSourceElement() {
|
8115
|
+
var token;
|
7032
8116
|
if (lookahead.type === Token.Keyword) {
|
7033
8117
|
switch (lookahead.value) {
|
7034
8118
|
case 'const':
|
@@ -7036,17 +8120,36 @@ parseYieldExpression: true
|
|
7036
8120
|
return parseConstLetDeclaration(lookahead.value);
|
7037
8121
|
case 'function':
|
7038
8122
|
return parseFunctionDeclaration();
|
7039
|
-
case 'export':
|
7040
|
-
return parseExportDeclaration();
|
7041
|
-
case 'import':
|
7042
|
-
return parseImportDeclaration();
|
7043
8123
|
default:
|
7044
8124
|
return parseStatement();
|
7045
8125
|
}
|
7046
8126
|
}
|
7047
8127
|
|
7048
|
-
if (
|
7049
|
-
|
8128
|
+
if (matchContextualKeyword('type')
|
8129
|
+
&& lookahead2().type === Token.Identifier) {
|
8130
|
+
return parseTypeAlias();
|
8131
|
+
}
|
8132
|
+
|
8133
|
+
if (matchContextualKeyword('interface')
|
8134
|
+
&& lookahead2().type === Token.Identifier) {
|
8135
|
+
return parseInterface();
|
8136
|
+
}
|
8137
|
+
|
8138
|
+
if (matchContextualKeyword('declare')) {
|
8139
|
+
token = lookahead2();
|
8140
|
+
if (token.type === Token.Keyword) {
|
8141
|
+
switch (token.value) {
|
8142
|
+
case 'class':
|
8143
|
+
return parseDeclareClass();
|
8144
|
+
case 'function':
|
8145
|
+
return parseDeclareFunction();
|
8146
|
+
case 'var':
|
8147
|
+
return parseDeclareVariable();
|
8148
|
+
}
|
8149
|
+
} else if (token.type === Token.Identifier
|
8150
|
+
&& token.value === 'module') {
|
8151
|
+
return parseDeclareModule();
|
8152
|
+
}
|
7050
8153
|
}
|
7051
8154
|
|
7052
8155
|
if (lookahead.type !== Token.EOF) {
|
@@ -7064,10 +8167,6 @@ parseYieldExpression: true
|
|
7064
8167
|
}
|
7065
8168
|
}
|
7066
8169
|
|
7067
|
-
if (matchModuleDeclaration()) {
|
7068
|
-
return parseModuleDeclaration();
|
7069
|
-
}
|
7070
|
-
|
7071
8170
|
return parseSourceElement();
|
7072
8171
|
}
|
7073
8172
|
|
@@ -7109,40 +8208,6 @@ parseYieldExpression: true
|
|
7109
8208
|
return sourceElements;
|
7110
8209
|
}
|
7111
8210
|
|
7112
|
-
function parseModuleElement() {
|
7113
|
-
return parseSourceElement();
|
7114
|
-
}
|
7115
|
-
|
7116
|
-
function parseModuleElements() {
|
7117
|
-
var list = [],
|
7118
|
-
statement;
|
7119
|
-
|
7120
|
-
while (index < length) {
|
7121
|
-
if (match('}')) {
|
7122
|
-
break;
|
7123
|
-
}
|
7124
|
-
statement = parseModuleElement();
|
7125
|
-
if (typeof statement === 'undefined') {
|
7126
|
-
break;
|
7127
|
-
}
|
7128
|
-
list.push(statement);
|
7129
|
-
}
|
7130
|
-
|
7131
|
-
return list;
|
7132
|
-
}
|
7133
|
-
|
7134
|
-
function parseModuleBlock() {
|
7135
|
-
var block, marker = markerCreate();
|
7136
|
-
|
7137
|
-
expect('{');
|
7138
|
-
|
7139
|
-
block = parseModuleElements();
|
7140
|
-
|
7141
|
-
expect('}');
|
7142
|
-
|
7143
|
-
return markerApply(marker, delegate.createBlockStatement(block));
|
7144
|
-
}
|
7145
|
-
|
7146
8211
|
function parseProgram() {
|
7147
8212
|
var body, marker = markerCreate();
|
7148
8213
|
strict = false;
|
@@ -7613,7 +8678,7 @@ parseYieldExpression: true
|
|
7613
8678
|
}
|
7614
8679
|
|
7615
8680
|
function scanXJSEntity() {
|
7616
|
-
var ch, str = '', count = 0,
|
8681
|
+
var ch, str = '', start = index, count = 0, code;
|
7617
8682
|
ch = source[index];
|
7618
8683
|
assert(ch === '&', 'Entity must start with an ampersand');
|
7619
8684
|
index++;
|
@@ -7625,14 +8690,28 @@ parseYieldExpression: true
|
|
7625
8690
|
str += ch;
|
7626
8691
|
}
|
7627
8692
|
|
7628
|
-
|
7629
|
-
|
7630
|
-
|
7631
|
-
|
7632
|
-
|
7633
|
-
|
8693
|
+
// Well-formed entity (ending was found).
|
8694
|
+
if (ch === ';') {
|
8695
|
+
// Numeric entity.
|
8696
|
+
if (str[0] === '#') {
|
8697
|
+
if (str[1] === 'x') {
|
8698
|
+
code = +('0' + str.substr(1));
|
8699
|
+
} else {
|
8700
|
+
// Removing leading zeros in order to avoid treating as octal in old browsers.
|
8701
|
+
code = +str.substr(1).replace(Regex.LeadingZeros, '');
|
8702
|
+
}
|
8703
|
+
|
8704
|
+
if (!isNaN(code)) {
|
8705
|
+
return String.fromCharCode(code);
|
8706
|
+
}
|
8707
|
+
} else if (XHTMLEntities[str]) {
|
8708
|
+
return XHTMLEntities[str];
|
8709
|
+
}
|
7634
8710
|
}
|
7635
|
-
|
8711
|
+
|
8712
|
+
// Treat non-entity sequences as regular text.
|
8713
|
+
index = start + 1;
|
8714
|
+
return '&';
|
7636
8715
|
}
|
7637
8716
|
|
7638
8717
|
function scanXJSText(stopChars) {
|
@@ -7959,8 +9038,181 @@ parseYieldExpression: true
|
|
7959
9038
|
return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
|
7960
9039
|
}
|
7961
9040
|
|
9041
|
+
function parseTypeAlias() {
|
9042
|
+
var id, marker = markerCreate(), typeParameters = null, right;
|
9043
|
+
expectContextualKeyword('type');
|
9044
|
+
id = parseVariableIdentifier();
|
9045
|
+
if (match('<')) {
|
9046
|
+
typeParameters = parseTypeParameterDeclaration();
|
9047
|
+
}
|
9048
|
+
expect('=');
|
9049
|
+
right = parseType();
|
9050
|
+
consumeSemicolon();
|
9051
|
+
return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
|
9052
|
+
}
|
9053
|
+
|
9054
|
+
function parseInterfaceExtends() {
|
9055
|
+
var marker = markerCreate(), id, typeParameters = null;
|
9056
|
+
|
9057
|
+
id = parseVariableIdentifier();
|
9058
|
+
if (match('<')) {
|
9059
|
+
typeParameters = parseTypeParameterInstantiation();
|
9060
|
+
}
|
9061
|
+
|
9062
|
+
return markerApply(marker, delegate.createInterfaceExtends(
|
9063
|
+
id,
|
9064
|
+
typeParameters
|
9065
|
+
));
|
9066
|
+
}
|
9067
|
+
|
9068
|
+
function parseInterfaceish(marker, allowStatic) {
|
9069
|
+
var body, bodyMarker, extended = [], id,
|
9070
|
+
typeParameters = null;
|
9071
|
+
|
9072
|
+
id = parseVariableIdentifier();
|
9073
|
+
if (match('<')) {
|
9074
|
+
typeParameters = parseTypeParameterDeclaration();
|
9075
|
+
}
|
9076
|
+
|
9077
|
+
if (matchKeyword('extends')) {
|
9078
|
+
expectKeyword('extends');
|
9079
|
+
|
9080
|
+
while (index < length) {
|
9081
|
+
extended.push(parseInterfaceExtends());
|
9082
|
+
if (!match(',')) {
|
9083
|
+
break;
|
9084
|
+
}
|
9085
|
+
expect(',');
|
9086
|
+
}
|
9087
|
+
}
|
9088
|
+
|
9089
|
+
bodyMarker = markerCreate();
|
9090
|
+
body = markerApply(bodyMarker, parseObjectType(allowStatic));
|
9091
|
+
|
9092
|
+
return markerApply(marker, delegate.createInterface(
|
9093
|
+
id,
|
9094
|
+
typeParameters,
|
9095
|
+
body,
|
9096
|
+
extended
|
9097
|
+
));
|
9098
|
+
}
|
9099
|
+
|
9100
|
+
function parseInterface() {
|
9101
|
+
var body, bodyMarker, extended = [], id, marker = markerCreate(),
|
9102
|
+
typeParameters = null;
|
9103
|
+
|
9104
|
+
expectContextualKeyword('interface');
|
9105
|
+
return parseInterfaceish(marker, /* allowStatic */false);
|
9106
|
+
}
|
9107
|
+
|
9108
|
+
function parseDeclareClass() {
|
9109
|
+
var marker = markerCreate(), ret;
|
9110
|
+
expectContextualKeyword('declare');
|
9111
|
+
expectKeyword('class');
|
9112
|
+
|
9113
|
+
ret = parseInterfaceish(marker, /* allowStatic */true);
|
9114
|
+
ret.type = Syntax.DeclareClass;
|
9115
|
+
return ret;
|
9116
|
+
}
|
9117
|
+
|
9118
|
+
function parseDeclareFunction() {
|
9119
|
+
var id, idMarker,
|
9120
|
+
marker = markerCreate(), params, returnType, rest, tmp,
|
9121
|
+
typeParameters = null, value, valueMarker;
|
9122
|
+
|
9123
|
+
expectContextualKeyword('declare');
|
9124
|
+
expectKeyword('function');
|
9125
|
+
idMarker = markerCreate();
|
9126
|
+
id = parseVariableIdentifier();
|
9127
|
+
|
9128
|
+
valueMarker = markerCreate();
|
9129
|
+
if (match('<')) {
|
9130
|
+
typeParameters = parseTypeParameterDeclaration();
|
9131
|
+
}
|
9132
|
+
expect('(');
|
9133
|
+
tmp = parseFunctionTypeParams();
|
9134
|
+
params = tmp.params;
|
9135
|
+
rest = tmp.rest;
|
9136
|
+
expect(')');
|
9137
|
+
|
9138
|
+
expect(':');
|
9139
|
+
returnType = parseType();
|
9140
|
+
|
9141
|
+
value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
|
9142
|
+
params,
|
9143
|
+
returnType,
|
9144
|
+
rest,
|
9145
|
+
typeParameters
|
9146
|
+
));
|
9147
|
+
|
9148
|
+
id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
|
9149
|
+
value
|
9150
|
+
));
|
9151
|
+
markerApply(idMarker, id);
|
9152
|
+
|
9153
|
+
consumeSemicolon();
|
9154
|
+
|
9155
|
+
return markerApply(marker, delegate.createDeclareFunction(
|
9156
|
+
id
|
9157
|
+
));
|
9158
|
+
}
|
9159
|
+
|
9160
|
+
function parseDeclareVariable() {
|
9161
|
+
var id, marker = markerCreate();
|
9162
|
+
expectContextualKeyword('declare');
|
9163
|
+
expectKeyword('var');
|
9164
|
+
id = parseTypeAnnotatableIdentifier();
|
9165
|
+
|
9166
|
+
consumeSemicolon();
|
9167
|
+
|
9168
|
+
return markerApply(marker, delegate.createDeclareVariable(
|
9169
|
+
id
|
9170
|
+
));
|
9171
|
+
}
|
9172
|
+
|
9173
|
+
function parseDeclareModule() {
|
9174
|
+
var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
|
9175
|
+
expectContextualKeyword('declare');
|
9176
|
+
expectContextualKeyword('module');
|
9177
|
+
|
9178
|
+
if (lookahead.type === Token.StringLiteral) {
|
9179
|
+
if (strict && lookahead.octal) {
|
9180
|
+
throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
|
9181
|
+
}
|
9182
|
+
idMarker = markerCreate();
|
9183
|
+
id = markerApply(idMarker, delegate.createLiteral(lex()));
|
9184
|
+
} else {
|
9185
|
+
id = parseVariableIdentifier();
|
9186
|
+
}
|
9187
|
+
|
9188
|
+
bodyMarker = markerCreate();
|
9189
|
+
expect('{');
|
9190
|
+
while (index < length && !match('}')) {
|
9191
|
+
token = lookahead2();
|
9192
|
+
switch (token.value) {
|
9193
|
+
case 'class':
|
9194
|
+
body.push(parseDeclareClass());
|
9195
|
+
break;
|
9196
|
+
case 'function':
|
9197
|
+
body.push(parseDeclareFunction());
|
9198
|
+
break;
|
9199
|
+
case 'var':
|
9200
|
+
body.push(parseDeclareVariable());
|
9201
|
+
break;
|
9202
|
+
default:
|
9203
|
+
throwUnexpected(lookahead);
|
9204
|
+
}
|
9205
|
+
}
|
9206
|
+
expect('}');
|
9207
|
+
|
9208
|
+
return markerApply(marker, delegate.createDeclareModule(
|
9209
|
+
id,
|
9210
|
+
markerApply(bodyMarker, delegate.createBlockStatement(body))
|
9211
|
+
));
|
9212
|
+
}
|
9213
|
+
|
7962
9214
|
function collectToken() {
|
7963
|
-
var start, loc, token, range, value;
|
9215
|
+
var start, loc, token, range, value, entry;
|
7964
9216
|
|
7965
9217
|
if (!state.inXJSChild) {
|
7966
9218
|
skipComment();
|
@@ -7983,12 +9235,19 @@ parseYieldExpression: true
|
|
7983
9235
|
if (token.type !== Token.EOF) {
|
7984
9236
|
range = [token.range[0], token.range[1]];
|
7985
9237
|
value = source.slice(token.range[0], token.range[1]);
|
7986
|
-
|
9238
|
+
entry = {
|
7987
9239
|
type: TokenName[token.type],
|
7988
9240
|
value: value,
|
7989
9241
|
range: range,
|
7990
9242
|
loc: loc
|
7991
|
-
}
|
9243
|
+
};
|
9244
|
+
if (token.regex) {
|
9245
|
+
entry.regex = {
|
9246
|
+
pattern: token.regex.pattern,
|
9247
|
+
flags: token.regex.flags
|
9248
|
+
};
|
9249
|
+
}
|
9250
|
+
extra.tokens.push(entry);
|
7992
9251
|
}
|
7993
9252
|
|
7994
9253
|
return token;
|
@@ -8027,6 +9286,7 @@ parseYieldExpression: true
|
|
8027
9286
|
extra.tokens.push({
|
8028
9287
|
type: 'RegularExpression',
|
8029
9288
|
value: regex.literal,
|
9289
|
+
regex: regex.regex,
|
8030
9290
|
range: [pos, index],
|
8031
9291
|
loc: loc
|
8032
9292
|
});
|
@@ -8044,6 +9304,12 @@ parseYieldExpression: true
|
|
8044
9304
|
type: entry.type,
|
8045
9305
|
value: entry.value
|
8046
9306
|
};
|
9307
|
+
if (entry.regex) {
|
9308
|
+
token.regex = {
|
9309
|
+
pattern: entry.regex.pattern,
|
9310
|
+
flags: entry.regex.flags
|
9311
|
+
};
|
9312
|
+
}
|
8047
9313
|
if (extra.range) {
|
8048
9314
|
token.range = entry.range;
|
8049
9315
|
}
|
@@ -8230,8 +9496,10 @@ parseYieldExpression: true
|
|
8230
9496
|
inSwitch: false,
|
8231
9497
|
inXJSChild: false,
|
8232
9498
|
inXJSTag: false,
|
9499
|
+
inType: false,
|
8233
9500
|
lastCommentStart: -1,
|
8234
|
-
yieldAllowed: false
|
9501
|
+
yieldAllowed: false,
|
9502
|
+
awaitAllowed: false
|
8235
9503
|
};
|
8236
9504
|
|
8237
9505
|
extra = {};
|
@@ -8302,7 +9570,7 @@ parseYieldExpression: true
|
|
8302
9570
|
}
|
8303
9571
|
|
8304
9572
|
// Sync with *.json manifests.
|
8305
|
-
exports.version = '
|
9573
|
+
exports.version = '8001.1001.0-dev-harmony-fb';
|
8306
9574
|
|
8307
9575
|
exports.tokenize = tokenize;
|
8308
9576
|
|
@@ -8332,34 +9600,6 @@ parseYieldExpression: true
|
|
8332
9600
|
}));
|
8333
9601
|
/* vim: set sw=4 ts=4 et tw=80 : */
|
8334
9602
|
|
8335
|
-
},{}],9:[function(_dereq_,module,exports){
|
8336
|
-
var Base62 = (function (my) {
|
8337
|
-
my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
|
8338
|
-
|
8339
|
-
my.encode = function(i){
|
8340
|
-
if (i === 0) {return '0'}
|
8341
|
-
var s = ''
|
8342
|
-
while (i > 0) {
|
8343
|
-
s = this.chars[i % 62] + s
|
8344
|
-
i = Math.floor(i/62)
|
8345
|
-
}
|
8346
|
-
return s
|
8347
|
-
};
|
8348
|
-
my.decode = function(a,b,c,d){
|
8349
|
-
for (
|
8350
|
-
b = c = (
|
8351
|
-
a === (/\W|_|^$/.test(a += "") || a)
|
8352
|
-
) - 1;
|
8353
|
-
d = a.charCodeAt(c++);
|
8354
|
-
)
|
8355
|
-
b = b * 62 + d - [, 48, 29, 87][d >> 5];
|
8356
|
-
return b
|
8357
|
-
};
|
8358
|
-
|
8359
|
-
return my;
|
8360
|
-
}({}));
|
8361
|
-
|
8362
|
-
module.exports = Base62
|
8363
9603
|
},{}],10:[function(_dereq_,module,exports){
|
8364
9604
|
/*
|
8365
9605
|
* Copyright 2009-2011 Mozilla Foundation and contributors
|
@@ -10632,7 +11872,6 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
|
|
10632
11872
|
|
10633
11873
|
/**
|
10634
11874
|
* @param {object} node
|
10635
|
-
* @param {function} visitor
|
10636
11875
|
* @param {array} path
|
10637
11876
|
* @param {object} state
|
10638
11877
|
*/
|
@@ -10830,7 +12069,7 @@ function transform(visitors, source, options) {
|
|
10830
12069
|
exports.transform = transform;
|
10831
12070
|
exports.Syntax = Syntax;
|
10832
12071
|
|
10833
|
-
},{"./utils":22,"esprima-fb":
|
12072
|
+
},{"./utils":22,"esprima-fb":9,"source-map":10}],22:[function(_dereq_,module,exports){
|
10834
12073
|
/**
|
10835
12074
|
* Copyright 2013 Facebook, Inc.
|
10836
12075
|
*
|
@@ -11281,8 +12520,8 @@ function initScopeMetadata(boundaryNode, path, node) {
|
|
11281
12520
|
function declareIdentInLocalScope(identName, metaData, state) {
|
11282
12521
|
state.localScope.identifiers[identName] = {
|
11283
12522
|
boundaryNode: metaData.boundaryNode,
|
11284
|
-
path: metaData.
|
11285
|
-
node: metaData.
|
12523
|
+
path: metaData.bindingPath,
|
12524
|
+
node: metaData.bindingNode,
|
11286
12525
|
state: Object.create(state)
|
11287
12526
|
};
|
11288
12527
|
}
|
@@ -11299,7 +12538,6 @@ function getLexicalBindingMetadata(identName, state) {
|
|
11299
12538
|
* @param {function} analyzer
|
11300
12539
|
* @param {function} traverser
|
11301
12540
|
* @param {object} node
|
11302
|
-
* @param {function} visitor
|
11303
12541
|
* @param {array} path
|
11304
12542
|
* @param {object} state
|
11305
12543
|
*/
|
@@ -11376,16 +12614,22 @@ function enqueueNodeWithStartIndex(queue, node) {
|
|
11376
12614
|
* @param {string} type - node type to lookup.
|
11377
12615
|
*/
|
11378
12616
|
function containsChildOfType(node, type) {
|
12617
|
+
return containsChildMatching(node, function(node) {
|
12618
|
+
return node.type === type;
|
12619
|
+
});
|
12620
|
+
}
|
12621
|
+
|
12622
|
+
function containsChildMatching(node, matcher) {
|
11379
12623
|
var foundMatchingChild = false;
|
11380
12624
|
function nodeTypeAnalyzer(node) {
|
11381
|
-
if (node
|
12625
|
+
if (matcher(node) === true) {
|
11382
12626
|
foundMatchingChild = true;
|
11383
12627
|
return false;
|
11384
12628
|
}
|
11385
12629
|
}
|
11386
12630
|
function nodeTypeTraverser(child, path, state) {
|
11387
12631
|
if (!foundMatchingChild) {
|
11388
|
-
foundMatchingChild =
|
12632
|
+
foundMatchingChild = containsChildMatching(child, matcher);
|
11389
12633
|
}
|
11390
12634
|
}
|
11391
12635
|
analyzeAndTraverse(
|
@@ -11414,11 +12658,20 @@ function getBoundaryNode(path) {
|
|
11414
12658
|
);
|
11415
12659
|
}
|
11416
12660
|
|
12661
|
+
function getTempVar(tempVarIndex) {
|
12662
|
+
return '$__' + tempVarIndex;
|
12663
|
+
}
|
12664
|
+
|
12665
|
+
function getTempVarWithValue(tempVarIndex, tempVarValue) {
|
12666
|
+
return getTempVar(tempVarIndex) + '=' + tempVarValue;
|
12667
|
+
}
|
12668
|
+
|
11417
12669
|
exports.append = append;
|
11418
12670
|
exports.catchup = catchup;
|
11419
12671
|
exports.catchupWhiteOut = catchupWhiteOut;
|
11420
12672
|
exports.catchupWhiteSpace = catchupWhiteSpace;
|
11421
12673
|
exports.catchupNewlines = catchupNewlines;
|
12674
|
+
exports.containsChildMatching = containsChildMatching;
|
11422
12675
|
exports.containsChildOfType = containsChildOfType;
|
11423
12676
|
exports.createState = createState;
|
11424
12677
|
exports.declareIdentInLocalScope = declareIdentInLocalScope;
|
@@ -11436,8 +12689,10 @@ exports.updateState = updateState;
|
|
11436
12689
|
exports.analyzeAndTraverse = analyzeAndTraverse;
|
11437
12690
|
exports.getOrderedChildren = getOrderedChildren;
|
11438
12691
|
exports.getNodeSourceText = getNodeSourceText;
|
12692
|
+
exports.getTempVar = getTempVar;
|
12693
|
+
exports.getTempVarWithValue = getTempVarWithValue;
|
11439
12694
|
|
11440
|
-
},{"./docblock":20,"esprima-fb":
|
12695
|
+
},{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
|
11441
12696
|
/**
|
11442
12697
|
* Copyright 2013 Facebook, Inc.
|
11443
12698
|
*
|
@@ -11512,7 +12767,14 @@ function visitArrowFunction(traverse, node, path, state) {
|
|
11512
12767
|
|
11513
12768
|
// Bind the function only if `this` value is used
|
11514
12769
|
// inside it or inside any sub-expression.
|
11515
|
-
|
12770
|
+
var containsBindingSyntax =
|
12771
|
+
utils.containsChildMatching(node.body, function(node) {
|
12772
|
+
return node.type === Syntax.ThisExpression
|
12773
|
+
|| (node.type === Syntax.Identifier
|
12774
|
+
&& node.name === "super");
|
12775
|
+
});
|
12776
|
+
|
12777
|
+
if (containsBindingSyntax) {
|
11516
12778
|
utils.append('.bind(this)', state);
|
11517
12779
|
}
|
11518
12780
|
|
@@ -11553,7 +12815,7 @@ function renderExpressionBody(traverse, node, path, state) {
|
|
11553
12815
|
// Special handling of rest param.
|
11554
12816
|
if (node.rest) {
|
11555
12817
|
utils.append(
|
11556
|
-
restParamVisitors.renderRestParamSetup(node),
|
12818
|
+
restParamVisitors.renderRestParamSetup(node, state),
|
11557
12819
|
state
|
11558
12820
|
);
|
11559
12821
|
}
|
@@ -11590,7 +12852,7 @@ exports.visitorList = [
|
|
11590
12852
|
];
|
11591
12853
|
|
11592
12854
|
|
11593
|
-
},{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":
|
12855
|
+
},{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":9}],24:[function(_dereq_,module,exports){
|
11594
12856
|
/**
|
11595
12857
|
* Copyright 2013 Facebook, Inc.
|
11596
12858
|
*
|
@@ -11821,7 +13083,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
|
|
11821
13083
|
|
11822
13084
|
var params = node.params;
|
11823
13085
|
if (params.length > 0) {
|
11824
|
-
utils.
|
13086
|
+
utils.catchupNewlines(params[0].range[0], state);
|
11825
13087
|
for (var i = 0; i < params.length; i++) {
|
11826
13088
|
utils.catchup(node.params[i].range[0], state);
|
11827
13089
|
path.unshift(node);
|
@@ -12159,7 +13421,7 @@ exports.visitorList = [
|
|
12159
13421
|
visitSuperMemberExpression
|
12160
13422
|
];
|
12161
13423
|
|
12162
|
-
},{"../src/utils":22,"./reserved-words-helper":32,"base62":
|
13424
|
+
},{"../src/utils":22,"./reserved-words-helper":32,"base62":8,"esprima-fb":9}],25:[function(_dereq_,module,exports){
|
12163
13425
|
/**
|
12164
13426
|
* Copyright 2014 Facebook, Inc.
|
12165
13427
|
*
|
@@ -12215,7 +13477,7 @@ var restPropertyHelpers = _dereq_('./es7-rest-property-helpers');
|
|
12215
13477
|
|
12216
13478
|
function visitStructuredVariable(traverse, node, path, state) {
|
12217
13479
|
// Allocate new temp for the pattern.
|
12218
|
-
utils.append(
|
13480
|
+
utils.append(utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
|
12219
13481
|
// Skip the pattern and assign the init to the temp.
|
12220
13482
|
utils.catchupWhiteSpace(node.init.range[0], state);
|
12221
13483
|
traverse(node.init, path, state);
|
@@ -12255,14 +13517,14 @@ function getDestructuredComponents(node, state) {
|
|
12255
13517
|
// and also for function param patterns: [x, ...xs, y]
|
12256
13518
|
components.push(item.argument.name +
|
12257
13519
|
'=Array.prototype.slice.call(' +
|
12258
|
-
|
13520
|
+
utils.getTempVar(tmpIndex) + ',' + idx + ')'
|
12259
13521
|
);
|
12260
13522
|
continue;
|
12261
13523
|
}
|
12262
13524
|
|
12263
13525
|
if (item.type === Syntax.SpreadProperty) {
|
12264
13526
|
var restExpression = restPropertyHelpers.renderRestExpression(
|
12265
|
-
|
13527
|
+
utils.getTempVar(tmpIndex),
|
12266
13528
|
patternItems
|
12267
13529
|
);
|
12268
13530
|
components.push(item.argument.name + '=' + restExpression);
|
@@ -12281,8 +13543,8 @@ function getDestructuredComponents(node, state) {
|
|
12281
13543
|
} else {
|
12282
13544
|
// Complex sub-structure.
|
12283
13545
|
components.push(
|
12284
|
-
|
12285
|
-
getDestructuredComponents(value, state)
|
13546
|
+
utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
|
13547
|
+
',' + getDestructuredComponents(value, state)
|
12286
13548
|
);
|
12287
13549
|
}
|
12288
13550
|
}
|
@@ -12295,14 +13557,16 @@ function getPatternItems(node) {
|
|
12295
13557
|
}
|
12296
13558
|
|
12297
13559
|
function getPatternItemAccessor(node, patternItem, tmpIndex, idx) {
|
12298
|
-
var tmpName =
|
13560
|
+
var tmpName = utils.getTempVar(tmpIndex);
|
12299
13561
|
if (node.type === Syntax.ObjectPattern) {
|
12300
13562
|
if (reservedWordsHelper.isReservedWord(patternItem.key.name)) {
|
12301
13563
|
return tmpName + '["' + patternItem.key.name + '"]';
|
12302
|
-
} else {
|
13564
|
+
} else if (patternItem.key.type === Syntax.Literal) {
|
13565
|
+
return tmpName + '[' + JSON.stringify(patternItem.key.value) + ']';
|
13566
|
+
} else if (patternItem.key.type === Syntax.Identifier) {
|
12303
13567
|
return tmpName + '.' + patternItem.key.name;
|
12304
13568
|
}
|
12305
|
-
} else {
|
13569
|
+
} else if (node.type === Syntax.ArrayPattern) {
|
12306
13570
|
return tmpName + '[' + idx + ']';
|
12307
13571
|
}
|
12308
13572
|
}
|
@@ -12313,14 +13577,6 @@ function getPatternItemValue(node, patternItem) {
|
|
12313
13577
|
: patternItem;
|
12314
13578
|
}
|
12315
13579
|
|
12316
|
-
function getInitialValue(index, value) {
|
12317
|
-
return getTmpVar(index) + '=' + value;
|
12318
|
-
}
|
12319
|
-
|
12320
|
-
function getTmpVar(index) {
|
12321
|
-
return '$__' + index;
|
12322
|
-
}
|
12323
|
-
|
12324
13580
|
// -------------------------------------------------------
|
12325
13581
|
// 2. Assignment expression.
|
12326
13582
|
//
|
@@ -12330,14 +13586,14 @@ function getTmpVar(index) {
|
|
12330
13586
|
|
12331
13587
|
function visitStructuredAssignment(traverse, node, path, state) {
|
12332
13588
|
var exprNode = node.expression;
|
12333
|
-
utils.append('var ' +
|
13589
|
+
utils.append('var ' + utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
|
12334
13590
|
|
12335
13591
|
utils.catchupWhiteSpace(exprNode.right.range[0], state);
|
12336
13592
|
traverse(exprNode.right, path, state);
|
12337
13593
|
utils.catchup(exprNode.right.range[1], state);
|
12338
13594
|
|
12339
13595
|
utils.append(
|
12340
|
-
'
|
13596
|
+
';' + getDestructuredComponents(exprNode.left, state) + ';',
|
12341
13597
|
state
|
12342
13598
|
);
|
12343
13599
|
|
@@ -12362,7 +13618,7 @@ visitStructuredAssignment.test = function(node, path, state) {
|
|
12362
13618
|
// -------------------------------------------------------
|
12363
13619
|
|
12364
13620
|
function visitStructuredParameter(traverse, node, path, state) {
|
12365
|
-
utils.append(
|
13621
|
+
utils.append(utils.getTempVar(getParamIndex(node, path)), state);
|
12366
13622
|
utils.catchupWhiteSpace(node.range[1], state);
|
12367
13623
|
return true;
|
12368
13624
|
}
|
@@ -12407,7 +13663,7 @@ function visitFunctionBodyForStructuredParameter(traverse, node, path, state) {
|
|
12407
13663
|
|
12408
13664
|
if (funcNode.rest) {
|
12409
13665
|
utils.append(
|
12410
|
-
restParamVisitors.renderRestParamSetup(funcNode),
|
13666
|
+
restParamVisitors.renderRestParamSetup(funcNode, state),
|
12411
13667
|
state
|
12412
13668
|
);
|
12413
13669
|
}
|
@@ -12447,7 +13703,7 @@ exports.visitorList = [
|
|
12447
13703
|
exports.renderDestructuredComponents = renderDestructuredComponents;
|
12448
13704
|
|
12449
13705
|
|
12450
|
-
},{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":
|
13706
|
+
},{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":9}],26:[function(_dereq_,module,exports){
|
12451
13707
|
/**
|
12452
13708
|
* Copyright 2013 Facebook, Inc.
|
12453
13709
|
*
|
@@ -12518,7 +13774,7 @@ exports.visitorList = [
|
|
12518
13774
|
visitObjectConciseMethod
|
12519
13775
|
];
|
12520
13776
|
|
12521
|
-
},{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":
|
13777
|
+
},{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":9}],27:[function(_dereq_,module,exports){
|
12522
13778
|
/**
|
12523
13779
|
* Copyright 2013 Facebook, Inc.
|
12524
13780
|
*
|
@@ -12545,7 +13801,7 @@ exports.visitorList = [
|
|
12545
13801
|
* return {x, y}; // {x: x, y: y}
|
12546
13802
|
* };
|
12547
13803
|
*
|
12548
|
-
* //
|
13804
|
+
* // Destructuring.
|
12549
13805
|
* function init({port, ip, coords: {x, y}}) { ... }
|
12550
13806
|
*
|
12551
13807
|
*/
|
@@ -12573,7 +13829,7 @@ exports.visitorList = [
|
|
12573
13829
|
];
|
12574
13830
|
|
12575
13831
|
|
12576
|
-
},{"../src/utils":22,"esprima-fb":
|
13832
|
+
},{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
|
12577
13833
|
/**
|
12578
13834
|
* Copyright 2013 Facebook, Inc.
|
12579
13835
|
*
|
@@ -12593,16 +13849,20 @@ exports.visitorList = [
|
|
12593
13849
|
/*jslint node:true*/
|
12594
13850
|
|
12595
13851
|
/**
|
12596
|
-
* Desugars ES6 rest parameters into ES3 arguments
|
13852
|
+
* Desugars ES6 rest parameters into an ES3 arguments array.
|
12597
13853
|
*
|
12598
13854
|
* function printf(template, ...args) {
|
12599
13855
|
* args.forEach(...);
|
12600
|
-
* }
|
13856
|
+
* }
|
13857
|
+
*
|
13858
|
+
* We could use `Array.prototype.slice.call`, but that usage of arguments causes
|
13859
|
+
* functions to be deoptimized in V8, so instead we use a for-loop.
|
12601
13860
|
*
|
12602
13861
|
* function printf(template) {
|
12603
|
-
* var args = []
|
13862
|
+
* for (var args = [], $__0 = 1, $__1 = arguments.length; $__0 < $__1; $__0++)
|
13863
|
+
* args.push(arguments[$__0]);
|
12604
13864
|
* args.forEach(...);
|
12605
|
-
* }
|
13865
|
+
* }
|
12606
13866
|
*
|
12607
13867
|
*/
|
12608
13868
|
var Syntax = _dereq_('esprima-fb').Syntax;
|
@@ -12647,17 +13907,22 @@ visitFunctionParamsWithRestParam.test = function(node, path, state) {
|
|
12647
13907
|
return _nodeIsFunctionWithRestParam(node);
|
12648
13908
|
};
|
12649
13909
|
|
12650
|
-
function renderRestParamSetup(functionNode) {
|
12651
|
-
|
12652
|
-
|
12653
|
-
|
12654
|
-
|
13910
|
+
function renderRestParamSetup(functionNode, state) {
|
13911
|
+
var idx = state.localScope.tempVarIndex++;
|
13912
|
+
var len = state.localScope.tempVarIndex++;
|
13913
|
+
|
13914
|
+
return 'for (var ' + functionNode.rest.name + '=[],' +
|
13915
|
+
utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
|
13916
|
+
utils.getTempVarWithValue(len, 'arguments.length') + ';' +
|
13917
|
+
utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
|
13918
|
+
utils.getTempVar(idx) + '++) ' +
|
13919
|
+
functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
|
12655
13920
|
}
|
12656
13921
|
|
12657
13922
|
function visitFunctionBodyWithRestParam(traverse, node, path, state) {
|
12658
13923
|
utils.catchup(node.range[0] + 1, state);
|
12659
13924
|
var parentNode = path[0];
|
12660
|
-
utils.append(renderRestParamSetup(parentNode), state);
|
13925
|
+
utils.append(renderRestParamSetup(parentNode, state), state);
|
12661
13926
|
return true;
|
12662
13927
|
}
|
12663
13928
|
|
@@ -12672,7 +13937,7 @@ exports.visitorList = [
|
|
12672
13937
|
visitFunctionBodyWithRestParam
|
12673
13938
|
];
|
12674
13939
|
|
12675
|
-
},{"../src/utils":22,"esprima-fb":
|
13940
|
+
},{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
|
12676
13941
|
/**
|
12677
13942
|
* Copyright 2013 Facebook, Inc.
|
12678
13943
|
*
|
@@ -12830,7 +14095,7 @@ exports.visitorList = [
|
|
12830
14095
|
visitTaggedTemplateExpression
|
12831
14096
|
];
|
12832
14097
|
|
12833
|
-
},{"../src/utils":22,"esprima-fb":
|
14098
|
+
},{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
|
12834
14099
|
/**
|
12835
14100
|
* Copyright 2013 Facebook, Inc.
|
12836
14101
|
*
|
@@ -12913,7 +14178,7 @@ function renderRestExpression(accessorExpression, excludedProperties) {
|
|
12913
14178
|
|
12914
14179
|
exports.renderRestExpression = renderRestExpression;
|
12915
14180
|
|
12916
|
-
},{"../src/utils":22,"esprima-fb":
|
14181
|
+
},{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
|
12917
14182
|
/**
|
12918
14183
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
12919
14184
|
*/
|
@@ -12985,7 +14250,11 @@ function visitObjectLiteralSpread(traverse, node, path, state) {
|
|
12985
14250
|
}
|
12986
14251
|
}
|
12987
14252
|
|
12988
|
-
|
14253
|
+
// Strip any non-whitespace between the last item and the end.
|
14254
|
+
// We only catch up on whitespace so that we ignore any trailing commas which
|
14255
|
+
// are stripped out for IE8 support. Unfortunately, this also strips out any
|
14256
|
+
// trailing comments.
|
14257
|
+
utils.catchupWhiteSpace(node.range[1] - 1, state);
|
12989
14258
|
|
12990
14259
|
// Skip the trailing }
|
12991
14260
|
utils.move(node.range[1], state);
|
@@ -13019,7 +14288,7 @@ exports.visitorList = [
|
|
13019
14288
|
visitObjectLiteralSpread
|
13020
14289
|
];
|
13021
14290
|
|
13022
|
-
},{"../src/utils":22,"esprima-fb":
|
14291
|
+
},{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
|
13023
14292
|
/**
|
13024
14293
|
* Copyright 2014 Facebook, Inc.
|
13025
14294
|
*
|
@@ -13061,7 +14330,7 @@ var RESERVED_WORDS = [].concat(
|
|
13061
14330
|
LITERALS
|
13062
14331
|
);
|
13063
14332
|
|
13064
|
-
var reservedWordsMap =
|
14333
|
+
var reservedWordsMap = Object.create(null);
|
13065
14334
|
RESERVED_WORDS.forEach(function(k) {
|
13066
14335
|
reservedWordsMap[k] = true;
|
13067
14336
|
});
|
@@ -13072,7 +14341,7 @@ exports.isReservedWord = function(word) {
|
|
13072
14341
|
|
13073
14342
|
},{}],33:[function(_dereq_,module,exports){
|
13074
14343
|
var esprima = _dereq_('esprima-fb');
|
13075
|
-
var utils = _dereq_('
|
14344
|
+
var utils = _dereq_('../src/utils');
|
13076
14345
|
|
13077
14346
|
var Syntax = esprima.Syntax;
|
13078
14347
|
|
@@ -13083,6 +14352,7 @@ function _isFunctionNode(node) {
|
|
13083
14352
|
}
|
13084
14353
|
|
13085
14354
|
function visitClassProperty(traverse, node, path, state) {
|
14355
|
+
utils.catchup(node.range[0], state);
|
13086
14356
|
utils.catchupWhiteOut(node.range[1], state);
|
13087
14357
|
return false;
|
13088
14358
|
}
|
@@ -13090,18 +14360,50 @@ visitClassProperty.test = function(node, path, state) {
|
|
13090
14360
|
return node.type === Syntax.ClassProperty;
|
13091
14361
|
};
|
13092
14362
|
|
14363
|
+
function visitTypeAlias(traverse, node, path, state) {
|
14364
|
+
utils.catchupWhiteOut(node.range[1], state);
|
14365
|
+
return false;
|
14366
|
+
}
|
14367
|
+
visitTypeAlias.test = function(node, path, state) {
|
14368
|
+
return node.type === Syntax.TypeAlias;
|
14369
|
+
};
|
14370
|
+
|
14371
|
+
function visitInterfaceDeclaration(traverse, node, path, state) {
|
14372
|
+
utils.catchupWhiteOut(node.range[1], state);
|
14373
|
+
return false;
|
14374
|
+
}
|
14375
|
+
visitInterfaceDeclaration.test = function(node, path, state) {
|
14376
|
+
return node.type === Syntax.InterfaceDeclaration;
|
14377
|
+
};
|
14378
|
+
|
14379
|
+
function visitDeclare(traverse, node, path, state) {
|
14380
|
+
utils.catchupWhiteOut(node.range[1], state);
|
14381
|
+
return false;
|
14382
|
+
}
|
14383
|
+
visitDeclare.test = function(node, path, state) {
|
14384
|
+
switch (node.type) {
|
14385
|
+
case Syntax.DeclareVariable:
|
14386
|
+
case Syntax.DeclareFunction:
|
14387
|
+
case Syntax.DeclareClass:
|
14388
|
+
case Syntax.DeclareModule: return true
|
14389
|
+
}
|
14390
|
+
return false;
|
14391
|
+
}
|
14392
|
+
|
13093
14393
|
function visitFunctionParametricAnnotation(traverse, node, path, state) {
|
14394
|
+
utils.catchup(node.range[0], state);
|
13094
14395
|
utils.catchupWhiteOut(node.range[1], state);
|
13095
14396
|
return false;
|
13096
14397
|
}
|
13097
14398
|
visitFunctionParametricAnnotation.test = function(node, path, state) {
|
13098
|
-
return node.type === Syntax.
|
14399
|
+
return node.type === Syntax.TypeParameterDeclaration
|
13099
14400
|
&& path[0]
|
13100
14401
|
&& _isFunctionNode(path[0])
|
13101
|
-
&& node === path[0].
|
14402
|
+
&& node === path[0].typeParameters;
|
13102
14403
|
};
|
13103
14404
|
|
13104
14405
|
function visitFunctionReturnAnnotation(traverse, node, path, state) {
|
14406
|
+
utils.catchup(node.range[0], state);
|
13105
14407
|
utils.catchupWhiteOut(node.range[1], state);
|
13106
14408
|
return false;
|
13107
14409
|
}
|
@@ -13110,38 +14412,83 @@ visitFunctionReturnAnnotation.test = function(node, path, state) {
|
|
13110
14412
|
};
|
13111
14413
|
|
13112
14414
|
function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) {
|
13113
|
-
|
13114
|
-
traverse(node.id, path, state);
|
13115
|
-
path.shift();
|
13116
|
-
utils.catchup(node.id.range[1], state);
|
14415
|
+
utils.catchup(node.range[0] + node.name.length, state);
|
13117
14416
|
utils.catchupWhiteOut(node.range[1], state);
|
13118
14417
|
return false;
|
13119
14418
|
}
|
13120
14419
|
visitOptionalFunctionParameterAnnotation.test = function(node, path, state) {
|
13121
|
-
return node.type === Syntax.
|
14420
|
+
return node.type === Syntax.Identifier
|
14421
|
+
&& node.optional
|
13122
14422
|
&& path[0]
|
13123
14423
|
&& _isFunctionNode(path[0]);
|
13124
14424
|
};
|
13125
14425
|
|
13126
14426
|
function visitTypeAnnotatedIdentifier(traverse, node, path, state) {
|
13127
|
-
|
13128
|
-
utils.
|
13129
|
-
utils.catchupWhiteOut(node.range[1], state);
|
14427
|
+
utils.catchup(node.typeAnnotation.range[0], state);
|
14428
|
+
utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
|
13130
14429
|
return false;
|
13131
14430
|
}
|
13132
14431
|
visitTypeAnnotatedIdentifier.test = function(node, path, state) {
|
13133
|
-
return node.type === Syntax.
|
14432
|
+
return node.type === Syntax.Identifier && node.typeAnnotation;
|
14433
|
+
};
|
14434
|
+
|
14435
|
+
function visitTypeAnnotatedObjectOrArrayPattern(traverse, node, path, state) {
|
14436
|
+
utils.catchup(node.typeAnnotation.range[0], state);
|
14437
|
+
utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
|
14438
|
+
return false;
|
14439
|
+
}
|
14440
|
+
visitTypeAnnotatedObjectOrArrayPattern.test = function(node, path, state) {
|
14441
|
+
var rightType = node.type === Syntax.ObjectPattern
|
14442
|
+
|| node.type === Syntax.ArrayPattern;
|
14443
|
+
return rightType && node.typeAnnotation;
|
14444
|
+
};
|
14445
|
+
|
14446
|
+
/**
|
14447
|
+
* Methods cause trouble, since esprima parses them as a key/value pair, where
|
14448
|
+
* the location of the value starts at the method body. For example
|
14449
|
+
* { bar(x:number,...y:Array<number>):number {} }
|
14450
|
+
* is parsed as
|
14451
|
+
* { bar: function(x: number, ...y:Array<number>): number {} }
|
14452
|
+
* except that the location of the FunctionExpression value is 40-something,
|
14453
|
+
* which is the location of the function body. This means that by the time we
|
14454
|
+
* visit the params, rest param, and return type organically, we've already
|
14455
|
+
* catchup()'d passed them.
|
14456
|
+
*/
|
14457
|
+
function visitMethod(traverse, node, path, state) {
|
14458
|
+
path.unshift(node);
|
14459
|
+
traverse(node.key, path, state);
|
14460
|
+
|
14461
|
+
path.unshift(node.value);
|
14462
|
+
traverse(node.value.params, path, state);
|
14463
|
+
node.value.rest && traverse(node.value.rest, path, state);
|
14464
|
+
node.value.returnType && traverse(node.value.returnType, path, state);
|
14465
|
+
traverse(node.value.body, path, state);
|
14466
|
+
|
14467
|
+
path.shift();
|
14468
|
+
|
14469
|
+
path.shift();
|
14470
|
+
return false;
|
14471
|
+
}
|
14472
|
+
|
14473
|
+
visitMethod.test = function(node, path, state) {
|
14474
|
+
return (node.type === "Property" && (node.method || node.kind === "set" || node.kind === "get"))
|
14475
|
+
|| (node.type === "MethodDefinition");
|
13134
14476
|
};
|
13135
14477
|
|
13136
14478
|
exports.visitorList = [
|
13137
14479
|
visitClassProperty,
|
14480
|
+
visitDeclare,
|
14481
|
+
visitInterfaceDeclaration,
|
13138
14482
|
visitFunctionParametricAnnotation,
|
13139
14483
|
visitFunctionReturnAnnotation,
|
14484
|
+
visitMethod,
|
13140
14485
|
visitOptionalFunctionParameterAnnotation,
|
13141
|
-
|
14486
|
+
visitTypeAlias,
|
14487
|
+
visitTypeAnnotatedIdentifier,
|
14488
|
+
visitTypeAnnotatedObjectOrArrayPattern
|
13142
14489
|
];
|
13143
14490
|
|
13144
|
-
},{"
|
14491
|
+
},{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
|
13145
14492
|
/**
|
13146
14493
|
* Copyright 2013-2014, Facebook, Inc.
|
13147
14494
|
* All rights reserved.
|
@@ -13153,7 +14500,7 @@ exports.visitorList = [
|
|
13153
14500
|
/*global exports:true*/
|
13154
14501
|
"use strict";
|
13155
14502
|
|
13156
|
-
var Syntax = _dereq_('
|
14503
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
13157
14504
|
var utils = _dereq_('jstransform/src/utils');
|
13158
14505
|
|
13159
14506
|
var FALLBACK_TAGS = _dereq_('./xjs').knownTags;
|
@@ -13396,7 +14743,7 @@ exports.visitorList = [
|
|
13396
14743
|
visitReactTag
|
13397
14744
|
];
|
13398
14745
|
|
13399
|
-
},{"./xjs":36,"
|
14746
|
+
},{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
|
13400
14747
|
/**
|
13401
14748
|
* Copyright 2013-2014, Facebook, Inc.
|
13402
14749
|
* All rights reserved.
|
@@ -13408,7 +14755,7 @@ exports.visitorList = [
|
|
13408
14755
|
/*global exports:true*/
|
13409
14756
|
"use strict";
|
13410
14757
|
|
13411
|
-
var Syntax = _dereq_('
|
14758
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
13412
14759
|
var utils = _dereq_('jstransform/src/utils');
|
13413
14760
|
|
13414
14761
|
function addDisplayName(displayName, object, state) {
|
@@ -13491,7 +14838,7 @@ exports.visitorList = [
|
|
13491
14838
|
visitReactDisplayName
|
13492
14839
|
];
|
13493
14840
|
|
13494
|
-
},{"
|
14841
|
+
},{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
|
13495
14842
|
/**
|
13496
14843
|
* Copyright 2013-2014, Facebook, Inc.
|
13497
14844
|
* All rights reserved.
|
@@ -13502,7 +14849,7 @@ exports.visitorList = [
|
|
13502
14849
|
*/
|
13503
14850
|
/*global exports:true*/
|
13504
14851
|
"use strict";
|
13505
|
-
var Syntax = _dereq_('
|
14852
|
+
var Syntax = _dereq_('jstransform').Syntax;
|
13506
14853
|
var utils = _dereq_('jstransform/src/utils');
|
13507
14854
|
|
13508
14855
|
var knownTags = {
|
@@ -13740,7 +15087,7 @@ exports.renderXJSLiteral = renderXJSLiteral;
|
|
13740
15087
|
exports.quoteAttrName = quoteAttrName;
|
13741
15088
|
exports.trimLeft = trimLeft;
|
13742
15089
|
|
13743
|
-
},{"
|
15090
|
+
},{"jstransform":21,"jstransform/src/utils":22}],37:[function(_dereq_,module,exports){
|
13744
15091
|
/*global exports:true*/
|
13745
15092
|
var es6ArrowFunctions = _dereq_('jstransform/visitors/es6-arrow-function-visitors');
|
13746
15093
|
var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors');
|
@@ -13752,7 +15099,6 @@ var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
|
|
13752
15099
|
var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
|
13753
15100
|
var react = _dereq_('./transforms/react');
|
13754
15101
|
var reactDisplayName = _dereq_('./transforms/reactDisplayName');
|
13755
|
-
var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
|
13756
15102
|
|
13757
15103
|
/**
|
13758
15104
|
* Map from transformName => orderedListOfVisitors.
|
@@ -13766,8 +15112,7 @@ var transformVisitors = {
|
|
13766
15112
|
'es6-rest-params': es6RestParameters.visitorList,
|
13767
15113
|
'es6-templates': es6Templates.visitorList,
|
13768
15114
|
'es7-spread-property': es7SpreadProperty.visitorList,
|
13769
|
-
'react': react.visitorList.concat(reactDisplayName.visitorList)
|
13770
|
-
'types': typesSyntax.visitorList
|
15115
|
+
'react': react.visitorList.concat(reactDisplayName.visitorList)
|
13771
15116
|
};
|
13772
15117
|
|
13773
15118
|
var transformSets = {
|
@@ -13783,9 +15128,6 @@ var transformSets = {
|
|
13783
15128
|
],
|
13784
15129
|
'react': [
|
13785
15130
|
'react'
|
13786
|
-
],
|
13787
|
-
'type-annotations': [
|
13788
|
-
'types'
|
13789
15131
|
]
|
13790
15132
|
};
|
13791
15133
|
|
@@ -13793,7 +15135,6 @@ var transformSets = {
|
|
13793
15135
|
* Specifies the order in which each transform should run.
|
13794
15136
|
*/
|
13795
15137
|
var transformRunOrder = [
|
13796
|
-
'types',
|
13797
15138
|
'es6-arrow-functions',
|
13798
15139
|
'es6-object-concise-method',
|
13799
15140
|
'es6-object-short-notation',
|
@@ -13854,5 +15195,5 @@ exports.getVisitorsBySet = getVisitorsBySet;
|
|
13854
15195
|
exports.getAllVisitors = getAllVisitors;
|
13855
15196
|
exports.transformVisitors = transformVisitors;
|
13856
15197
|
|
13857
|
-
},{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31
|
15198
|
+
},{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31}]},{},[1])(1)
|
13858
15199
|
});
|