MCPcopy
hub / github.com/jquery/esprima / parseLexicalBinding

Method parseLexicalBinding

src/parser.ts:1833–1860  ·  view source on GitHub ↗
(kind: string, options)

Source from the content-addressed store, hash-verified

1831 // https://tc39.github.io/ecma262/#sec-let-and-const-declarations
1832
1833 parseLexicalBinding(kind: string, options): Node.VariableDeclarator {
1834 const node = this.createNode();
1835 const params = [];
1836 const id = this.parsePattern(params, kind);
1837
1838 if (this.context.strict && id.type === Syntax.Identifier) {
1839 if (this.scanner.isRestrictedWord((id as Node.Identifier).name)) {
1840 this.tolerateError(Messages.StrictVarName);
1841 }
1842 }
1843
1844 let init: Node.Expression | null = null;
1845 if (kind === 'const') {
1846 if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) {
1847 if (this.match('=')) {
1848 this.nextToken();
1849 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
1850 } else {
1851 this.throwError(Messages.DeclarationMissingInitializer, 'const');
1852 }
1853 }
1854 } else if ((!options.inFor && id.type !== Syntax.Identifier) || this.match('=')) {
1855 this.expect('=');
1856 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
1857 }
1858
1859 return this.finalize(node, new Node.VariableDeclarator(id, init));
1860 }
1861
1862 parseBindingList(kind: string, options): Node.VariableDeclarator[] {
1863 const list = [this.parseLexicalBinding(kind, options)];

Callers 1

parseBindingListMethod · 0.95

Calls 12

createNodeMethod · 0.95
parsePatternMethod · 0.95
tolerateErrorMethod · 0.95
matchKeywordMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
isolateCoverGrammarMethod · 0.95
throwErrorMethod · 0.95
expectMethod · 0.95
finalizeMethod · 0.95
isRestrictedWordMethod · 0.80

Tested by

no test coverage detected