MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / parseIdentifier

Method parseIdentifier

src/common/json5.ts:239–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

237 }
238
239 private parseIdentifier(): any {
240 const start = this.index;
241 // An identifier can start with a letter, underscore, or dollar sign.
242 const firstChar = this.currentChar();
243 if (!/[a-zA-Z$_]/.test(firstChar)) {
244 throw this.error(`Unexpected token '${firstChar}'`);
245 }
246 this.index++;
247 while (!this.isAtEnd()) {
248 const ch = this.currentChar();
249 if (!/[a-zA-Z0-9$_]/.test(ch)) break;
250 this.index++;
251 }
252 const token = this.text.slice(start, this.index);
253 // Recognize standard literals.
254 if (token === 'true') return true;
255 if (token === 'false') return false;
256 if (token === 'null') return null;
257 if (token === 'Infinity') return Infinity;
258 if (token === 'NaN') return NaN;
259 return token;
260 }
261
262 skipWhitespace(): void {
263 while (!this.isAtEnd()) {

Callers 2

parseValueMethod · 0.95
parseObjectMethod · 0.95

Calls 4

currentCharMethod · 0.95
errorMethod · 0.95
isAtEndMethod · 0.95
sliceMethod · 0.65

Tested by

no test coverage detected