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

Method convertToken

src/parser.ts:295–322  ·  view source on GitHub ↗
(token: RawToken)

Source from the content-addressed store, hash-verified

293 }
294
295 convertToken(token: RawToken): TokenEntry {
296 const t: TokenEntry = {
297 type: TokenName[token.type],
298 value: this.getTokenRaw(token)
299 };
300 if (this.config.range) {
301 t.range = [token.start, token.end];
302 }
303 if (this.config.loc) {
304 t.loc = {
305 start: {
306 line: this.startMarker.line,
307 column: this.startMarker.column
308 },
309 end: {
310 line: this.scanner.lineNumber,
311 column: this.scanner.index - this.scanner.lineStart
312 }
313 };
314 }
315 if (token.type === Token.RegularExpression) {
316 const pattern = token.pattern as string;
317 const flags = token.flags as string;
318 t.regex = { pattern, flags };
319 }
320
321 return t;
322 }
323
324 nextToken(): RawToken {
325 const token = this.lookahead;

Callers 4

nextTokenMethod · 0.95
nextRegexTokenMethod · 0.95
nextJSXTokenMethod · 0.80
nextJSXTextMethod · 0.80

Calls 1

getTokenRawMethod · 0.95

Tested by

no test coverage detected