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

Method parseVariableIdentifier

src/parser.ts:2025–2048  ·  view source on GitHub ↗
(kind?: string)

Source from the content-addressed store, hash-verified

2023 // https://tc39.github.io/ecma262/#sec-variable-statement
2024
2025 parseVariableIdentifier(kind?: string): Node.Identifier {
2026 const node = this.createNode();
2027
2028 const token = this.nextToken();
2029 if (token.type === Token.Keyword && token.value === 'yield') {
2030 if (this.context.strict) {
2031 this.tolerateUnexpectedToken(token, Messages.StrictReservedWord);
2032 } else if (!this.context.allowYield) {
2033 this.throwUnexpectedToken(token);
2034 }
2035 } else if (token.type !== Token.Identifier) {
2036 if (this.context.strict && token.type === Token.Keyword && this.scanner.isStrictModeReservedWord(token.value as string)) {
2037 this.tolerateUnexpectedToken(token, Messages.StrictReservedWord);
2038 } else {
2039 if (this.context.strict || token.value !== 'let' || kind !== 'var') {
2040 this.throwUnexpectedToken(token);
2041 }
2042 }
2043 } else if ((this.context.isModule || this.context.await) && token.type === Token.Identifier && token.value === 'await') {
2044 this.tolerateUnexpectedToken(token);
2045 }
2046
2047 return this.finalize(node, new Node.Identifier(token.value));
2048 }
2049
2050 parseVariableDeclaration(options: DeclarationOptions): Node.VariableDeclarator {
2051 const node = this.createNode();

Callers 9

parsePropertyPatternMethod · 0.95
parsePatternMethod · 0.95
parseBreakStatementMethod · 0.95
parseClassDeclarationMethod · 0.95
parseClassExpressionMethod · 0.95
parseImportSpecifierMethod · 0.95

Calls 6

createNodeMethod · 0.95
nextTokenMethod · 0.95
throwUnexpectedTokenMethod · 0.95
finalizeMethod · 0.95

Tested by

no test coverage detected