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

Method parseVariableDeclaration

src/parser.ts:2050–2071  ·  view source on GitHub ↗
(options: DeclarationOptions)

Source from the content-addressed store, hash-verified

2048 }
2049
2050 parseVariableDeclaration(options: DeclarationOptions): Node.VariableDeclarator {
2051 const node = this.createNode();
2052
2053 const params = [];
2054 const id = this.parsePattern(params, 'var');
2055
2056 if (this.context.strict && id.type === Syntax.Identifier) {
2057 if (this.scanner.isRestrictedWord((id as Node.Identifier).name)) {
2058 this.tolerateError(Messages.StrictVarName);
2059 }
2060 }
2061
2062 let init = null;
2063 if (this.match('=')) {
2064 this.nextToken();
2065 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
2066 } else if (id.type !== Syntax.Identifier && !options.inFor) {
2067 this.expect('=');
2068 }
2069
2070 return this.finalize(node, new Node.VariableDeclarator(id, init));
2071 }
2072
2073 parseVariableDeclarationList(options): Node.VariableDeclarator[] {
2074 const opt: DeclarationOptions = { inFor: options.inFor };

Callers 1

Calls 9

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

Tested by

no test coverage detected