Lines Matching full:this
19 while (this.type !== tt.eof) {
20 let stmt = this.parseStatement(true, true, exports)
23 this.next()
24 if (this.options.ecmaVersion >= 6) {
25 node.sourceType = this.options.sourceType
27 return this.finishNode(node, "Program")
33 if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false
34 skipWhiteSpace.lastIndex = this.pos
35 let skip = skipWhiteSpace.exec(this.input)
36 let next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)
39 for (var pos = next + 1; isIdentifierChar(this.input.charCodeAt(pos), true); ++pos) {}
40 let ident = this.input.slice(next, pos)
41 if (!this.isKeyword(ident)) return true
50 if (this.type !== tt.name || this.options.ecmaVersion < 8 || this.value != "async")
53 skipWhiteSpace.lastIndex = this.pos
54 let skip = skipWhiteSpace.exec(this.input)
55 let next = this.pos + skip[0].length
56 return !lineBreak.test(this.input.slice(this.pos, next)) &&
57 this.input.slice(next, next + 8) === "function" &&
58 (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))
64 // regular expression literal. This is to handle cases like
69 let starttype = this.type, node = this.startNode(), kind
71 if (this.isLet()) {
81 …case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
82 case tt._debugger: return this.parseDebuggerStatement(node)
83 case tt._do: return this.parseDoStatement(node)
84 case tt._for: return this.parseForStatement(node)
86 if (!declaration && this.options.ecmaVersion >= 6) this.unexpected()
87 return this.parseFunctionStatement(node, false)
89 if (!declaration) this.unexpected()
90 return this.parseClass(node, true)
91 case tt._if: return this.parseIfStatement(node)
92 case tt._return: return this.parseReturnStatement(node)
93 case tt._switch: return this.parseSwitchStatement(node)
94 case tt._throw: return this.parseThrowStatement(node)
95 case tt._try: return this.parseTryStatement(node)
97 kind = kind || this.value
98 if (!declaration && kind != "var") this.unexpected()
99 return this.parseVarStatement(node, kind)
100 case tt._while: return this.parseWhileStatement(node)
101 case tt._with: return this.parseWithStatement(node)
102 case tt.braceL: return this.parseBlock()
103 case tt.semi: return this.parseEmptyStatement(node)
106 if (!this.options.allowImportExportEverywhere) {
108 this.raise(this.start, "'import' and 'export' may only appear at the top level")
109 if (!this.inModule)
110 this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'")
112 return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports)
120 if (this.isAsyncFunction() && declaration) {
121 this.next()
122 return this.parseFunctionStatement(node, true)
125 let maybeName = this.value, expr = this.parseExpression()
126 if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon))
127 return this.parseLabeledStatement(node, maybeName, expr)
128 else return this.parseExpressionStatement(node, expr)
134 this.next()
135 if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null
136 else if (this.type !== tt.name) this.unexpected()
138 node.label = this.parseIdent()
139 this.semicolon()
144 for (var i = 0; i < this.labels.length; ++i) {
145 let lab = this.labels[i]
151 if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword)
152 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
156 this.next()
157 this.semicolon()
158 return this.finishNode(node, "DebuggerStatement")
162 this.next()
163 this.labels.push(loopLabel)
164 node.body = this.parseStatement(false)
165 this.labels.pop()
166 this.expect(tt._while)
167 node.test = this.parseParenExpression()
168 if (this.options.ecmaVersion >= 6)
169 this.eat(tt.semi)
171 this.semicolon()
172 return this.finishNode(node, "DoWhileStatement")
184 this.next()
185 this.labels.push(loopLabel)
186 this.expect(tt.parenL)
187 if (this.type === tt.semi) return this.parseFor(node, null)
188 let isLet = this.isLet()
189 if (this.type === tt._var || this.type === tt._const || isLet) {
190 let init = this.startNode(), kind = isLet ? "let" : this.value
191 this.next()
192 this.parseVar(init, true, kind)
193 this.finishNode(init, "VariableDeclaration")
194 …if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.d…
196 return this.parseForIn(node, init)
197 return this.parseFor(node, init)
200 let init = this.parseExpression(true, refDestructuringErrors)
201 if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
202 this.toAssignable(init)
203 this.checkLVal(init)
204 this.checkPatternErrors(refDestructuringErrors, true)
205 return this.parseForIn(node, init)
207 this.checkExpressionErrors(refDestructuringErrors, true)
209 return this.parseFor(node, init)
213 this.next()
214 return this.parseFunction(node, true, false, isAsync)
218 return this.type === tt._function || this.isAsyncFunction()
222 this.next()
223 node.test = this.parseParenExpression()
225 node.consequent = this.parseStatement(!this.strict && this.isFunction())
226 …node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null
227 return this.finishNode(node, "IfStatement")
231 if (!this.inFunction && !this.options.allowReturnOutsideFunction)
232 this.raise(this.start, "'return' outside of function")
233 this.next()
239 if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null
240 else { node.argument = this.parseExpression(); this.semicolon() }
241 return this.finishNode(node, "ReturnStatement")
245 this.next()
246 node.discriminant = this.parseParenExpression()
248 this.expect(tt.braceL)
249 this.labels.push(switchLabel)
255 for (var cur, sawDefault = false; this.type != tt.braceR;) {
256 if (this.type === tt._case || this.type === tt._default) {
257 let isCase = this.type === tt._case
258 if (cur) this.finishNode(cur, "SwitchCase")
259 node.cases.push(cur = this.startNode())
261 this.next()
263 cur.test = this.parseExpression()
265 if (sawDefault) this.raiseRecoverable(this.lastTokStart, "Multiple default clauses")
269 this.expect(tt.colon)
271 if (!cur) this.unexpected()
272 cur.consequent.push(this.parseStatement(true))
275 if (cur) this.finishNode(cur, "SwitchCase")
276 this.next() // Closing brace
277 this.labels.pop()
278 return this.finishNode(node, "SwitchStatement")
282 this.next()
283 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
284 this.raise(this.lastTokEnd, "Illegal newline after throw")
285 node.argument = this.parseExpression()
286 this.semicolon()
287 return this.finishNode(node, "ThrowStatement")
295 this.next()
296 node.block = this.parseBlock()
298 if (this.type === tt._catch) {
299 let clause = this.startNode()
300 this.next()
301 this.expect(tt.parenL)
302 clause.param = this.parseBindingAtom()
303 this.checkLVal(clause.param, true)
304 this.expect(tt.parenR)
305 clause.body = this.parseBlock()
306 node.handler = this.finishNode(clause, "CatchClause")
308 node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null
310 this.raise(node.start, "Missing catch or finally clause")
311 return this.finishNode(node, "TryStatement")
315 this.next()
316 this.parseVar(node, false, kind)
317 this.semicolon()
318 return this.finishNode(node, "VariableDeclaration")
322 this.next()
323 node.test = this.parseParenExpression()
324 this.labels.push(loopLabel)
325 node.body = this.parseStatement(false)
326 this.labels.pop()
327 return this.finishNode(node, "WhileStatement")
331 if (this.strict) this.raise(this.start, "'with' in strict mode")
332 this.next()
333 node.object = this.parseParenExpression()
334 node.body = this.parseStatement(false)
335 return this.finishNode(node, "WithStatement")
339 this.next()
340 return this.finishNode(node, "EmptyStatement")
344 for (let i = 0; i < this.labels.length; ++i)
345 …if (this.labels[i].name === maybeName) this.raise(expr.start, "Label '" + maybeName + "' is alread…
346 let kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null
347 for (let i = this.labels.length - 1; i >= 0; i--) {
348 let label = this.labels[i]
350 label.statementStart = this.start
354 this.labels.push({name: maybeName, kind: kind, statementStart: this.start})
355 node.body = this.parseStatement(true)
357 node.body.type == "VariableDeclaration" && (this.strict || node.body.kind != "var") ||
358 node.body.type == "FunctionDeclaration" && (this.strict || node.body.generator))
359 this.raiseRecoverable(node.body.start, "Invalid labeled declaration")
360 this.labels.pop()
362 return this.finishNode(node, "LabeledStatement")
367 this.semicolon()
368 return this.finishNode(node, "ExpressionStatement")
376 let node = this.startNode()
378 this.expect(tt.braceL)
379 while (!this.eat(tt.braceR)) {
380 let stmt = this.parseStatement(true)
383 return this.finishNode(node, "BlockStatement")
392 this.expect(tt.semi)
393 node.test = this.type === tt.semi ? null : this.parseExpression()
394 this.expect(tt.semi)
395 node.update = this.type === tt.parenR ? null : this.parseExpression()
396 this.expect(tt.parenR)
397 node.body = this.parseStatement(false)
398 this.labels.pop()
399 return this.finishNode(node, "ForStatement")
406 let type = this.type === tt._in ? "ForInStatement" : "ForOfStatement"
407 this.next()
409 node.right = this.parseExpression()
410 this.expect(tt.parenR)
411 node.body = this.parseStatement(false)
412 this.labels.pop()
413 return this.finishNode(node, type)
422 let decl = this.startNode()
423 this.parseVarId(decl)
424 if (this.eat(tt.eq)) {
425 decl.init = this.parseMaybeAssign(isFor)
426 …} else if (kind === "const" && !(this.type === tt._in || (this.options.ecmaVersion >= 6 && this.is…
427 this.unexpected()
428 …} else if (decl.id.type != "Identifier" && !(isFor && (this.type === tt._in || this.isContextual("…
429 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value")
433 node.declarations.push(this.finishNode(decl, "VariableDeclarator"))
434 if (!this.eat(tt.comma)) break
440 decl.id = this.parseBindingAtom()
441 this.checkLVal(decl.id, true)
448 this.initFunction(node)
449 if (this.options.ecmaVersion >= 6 && !isAsync)
450 node.generator = this.eat(tt.star)
451 if (this.options.ecmaVersion >= 8)
455 isStatement = this.type == tt.name
457 node.id = this.parseIdent()
459 let oldInGen = this.inGenerator, oldInAsync = this.inAsync,
460 oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction
461 this.inGenerator = node.generator
462 this.inAsync = node.async
463 this.yieldPos = 0
464 this.awaitPos = 0
465 this.inFunction = true
467 if (!isStatement && this.type === tt.name)
468 node.id = this.parseIdent()
469 this.parseFunctionParams(node)
470 this.parseFunctionBody(node, allowExpressionBody)
472 this.inGenerator = oldInGen
473 this.inAsync = oldInAsync
474 this.yieldPos = oldYieldPos
475 this.awaitPos = oldAwaitPos
476 this.inFunction = oldInFunc
477 return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression")
481 this.expect(tt.parenL)
482 node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true)
483 this.checkYieldAwaitInDefaultParams()
490 this.next()
491 if (isStatement == null) isStatement = this.type === tt.name
492 this.parseClassId(node, isStatement)
493 this.parseClassSuper(node)
494 let classBody = this.startNode()
497 this.expect(tt.braceL)
498 while (!this.eat(tt.braceR)) {
499 if (this.eat(tt.semi)) continue
500 let method = this.startNode()
501 let isGenerator = this.eat(tt.star)
503 let isMaybeStatic = this.type === tt.name && this.value === "static"
504 this.parsePropertyName(method)
505 method.static = isMaybeStatic && this.type !== tt.parenL
507 if (isGenerator) this.unexpected()
508 isGenerator = this.eat(tt.star)
509 this.parsePropertyName(method)
511 if (this.options.ecmaVersion >= 8 && !isGenerator && !method.computed &&
512 … method.key.type === "Identifier" && method.key.name === "async" && this.type !== tt.parenL &&
513 !this.canInsertSemicolon()) {
515 this.parsePropertyName(method)
521 …if (!isGenerator && !isAsync && key.type === "Identifier" && this.type !== tt.parenL && (key.name …
524 key = this.parsePropertyName(method)
528 if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class")
529 if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier")
530 if (isGenerator) this.raise(key.start, "Constructor can't be a generator")
531 if (isAsync) this.raise(key.start, "Constructor can't be an async method")
536 this.parseClassMethod(classBody, method, isGenerator, isAsync)
542 this.raiseRecoverable(start, "getter should have no params")
544 this.raiseRecoverable(start, "setter should have exactly one param")
547 this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params")
551 node.body = this.finishNode(classBody, "ClassBody")
552 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
556 method.value = this.parseMethod(isGenerator, isAsync)
557 classBody.body.push(this.finishNode(method, "MethodDefinition"))
561 node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null
565 node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null
571 this.next()
573 if (this.eat(tt.star)) {
574 this.expectContextual("from")
575 node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
576 this.semicolon()
577 return this.finishNode(node, "ExportAllDeclaration")
579 if (this.eat(tt._default)) { // export default ...
580 this.checkExport(exports, "default", this.lastTokStart)
582 if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
583 let fNode = this.startNode()
584 this.next()
585 if (isAsync) this.next()
586 node.declaration = this.parseFunction(fNode, null, false, isAsync)
587 } else if (this.type === tt._class) {
588 let cNode = this.startNode()
589 node.declaration = this.parseClass(cNode, null)
591 node.declaration = this.parseMaybeAssign()
592 this.semicolon()
594 return this.finishNode(node, "ExportDefaultDeclaration")
597 if (this.shouldParseExportStatement()) {
598 node.declaration = this.parseStatement(true)
600 this.checkVariableExport(exports, node.declaration.declarations)
602 this.checkExport(exports, node.declaration.id.name, node.declaration.id.start)
607 node.specifiers = this.parseExportSpecifiers(exports)
608 if (this.eatContextual("from")) {
609 node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
613 …if (this.keywords.test(node.specifiers[i].local.name) || this.reservedWords.test(node.specifiers[i…
614 this.unexpected(node.specifiers[i].local.start)
620 this.semicolon()
622 return this.finishNode(node, "ExportNamedDeclaration")
628 this.raiseRecoverable(pos, "Duplicate export '" + name + "'")
635 this.checkExport(exports, pat.name, pat.start)
638 this.checkPatternExport(exports, pat.properties[i].value)
642 if (elt) this.checkPatternExport(exports, elt)
645 this.checkPatternExport(exports, pat.left)
647 this.checkPatternExport(exports, pat.expression)
653 this.checkPatternExport(exports, decls[i].id)
657 return this.type.keyword === "var"
658 || this.type.keyword === "const"
659 || this.type.keyword === "class"
660 || this.type.keyword === "function"
661 || this.isLet()
662 || this.isAsyncFunction()
670 this.expect(tt.braceL)
671 while (!this.eat(tt.braceR)) {
673 this.expect(tt.comma)
674 if (this.afterTrailingComma(tt.braceR)) break
677 let node = this.startNode()
678 node.local = this.parseIdent(true)
679 node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local
680 this.checkExport(exports, node.exported.name, node.exported.start)
681 nodes.push(this.finishNode(node, "ExportSpecifier"))
689 this.next()
691 if (this.type === tt.string) {
693 node.source = this.parseExprAtom()
695 node.specifiers = this.parseImportSpecifiers()
696 this.expectContextual("from")
697 node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()
699 this.semicolon()
700 return this.finishNode(node, "ImportDeclaration")
707 if (this.type === tt.name) {
709 let node = this.startNode()
710 node.local = this.parseIdent()
711 this.checkLVal(node.local, true)
712 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"))
713 if (!this.eat(tt.comma)) return nodes
715 if (this.type === tt.star) {
716 let node = this.startNode()
717 this.next()
718 this.expectContextual("as")
719 node.local = this.parseIdent()
720 this.checkLVal(node.local, true)
721 nodes.push(this.finishNode(node, "ImportNamespaceSpecifier"))
724 this.expect(tt.braceL)
725 while (!this.eat(tt.braceR)) {
727 this.expect(tt.comma)
728 if (this.afterTrailingComma(tt.braceR)) break
731 let node = this.startNode()
732 node.imported = this.parseIdent(true)
733 if (this.eatContextual("as")) {
734 node.local = this.parseIdent()
737 if (this.isKeyword(node.local.name)) this.unexpected(node.local.start)
738 …if (this.reservedWordsStrict.test(node.local.name)) this.raiseRecoverable(node.local.start, "The k…
740 this.checkLVal(node.local, true)
741 nodes.push(this.finishNode(node, "ImportSpecifier"))