* Identifies and returns the next token type in the document * * @returns the state of the scanner will have the properties `token`, `value`, `offset` pointing to the current token at the end of this call. * * @notes before this call, `#offset` is pointing to the next charact
()
| 359 | * |
| 360 | */ |
| 361 | scan(): Kind { |
| 362 | |
| 363 | // this token starts at |
| 364 | this.offset = this.#offset; |
| 365 | this.stringValue = undefined; |
| 366 | |
| 367 | if (!(this.eof || isNaN(this.#ch))) { |
| 368 | switch (this.#ch) { |
| 369 | case CharacterCodes.carriageReturn: |
| 370 | return this.newLine(this.#chNext === CharacterCodes.lineFeed ? 2 : 1); |
| 371 | |
| 372 | case CharacterCodes.lineFeed: |
| 373 | return this.newLine(); |
| 374 | |
| 375 | case CharacterCodes.tab: |
| 376 | case CharacterCodes.verticalTab: |
| 377 | case CharacterCodes.formFeed: |
| 378 | case CharacterCodes.space: |
| 379 | case CharacterCodes.nonBreakingSpace: |
| 380 | case CharacterCodes.ogham: |
| 381 | case CharacterCodes.enQuad: |
| 382 | case CharacterCodes.emQuad: |
| 383 | case CharacterCodes.enSpace: |
| 384 | case CharacterCodes.emSpace: |
| 385 | case CharacterCodes.threePerEmSpace: |
| 386 | case CharacterCodes.fourPerEmSpace: |
| 387 | case CharacterCodes.sixPerEmSpace: |
| 388 | case CharacterCodes.figureSpace: |
| 389 | case CharacterCodes.punctuationSpace: |
| 390 | case CharacterCodes.thinSpace: |
| 391 | case CharacterCodes.hairSpace: |
| 392 | case CharacterCodes.zeroWidthSpace: |
| 393 | case CharacterCodes.narrowNoBreakSpace: |
| 394 | case CharacterCodes.mathematicalSpace: |
| 395 | case CharacterCodes.ideographicSpace: |
| 396 | case CharacterCodes.byteOrderMark: |
| 397 | return this.scanWhitespace(); |
| 398 | |
| 399 | case CharacterCodes.$: |
| 400 | return isIdentifierPart(this.#chNext) ? this.scanVariable() : this.next(Kind.Dollar); |
| 401 | |
| 402 | case CharacterCodes.openParen: |
| 403 | return this.next(Kind.OpenParen); |
| 404 | |
| 405 | case CharacterCodes.closeParen: |
| 406 | return this.next(Kind.CloseParen); |
| 407 | |
| 408 | case CharacterCodes.comma: |
| 409 | return this.next(Kind.Comma); |
| 410 | |
| 411 | case CharacterCodes.colon: |
| 412 | return this.next(Kind.Colon); |
| 413 | |
| 414 | case CharacterCodes.semicolon: |
| 415 | return this.next(Kind.Semicolon); |
| 416 | |
| 417 | case CharacterCodes.openBracket: |
| 418 | return this.next(Kind.OpenBracket); |
no test coverage detected