()
| 363 | } |
| 364 | |
| 365 | function scanNext(): SyntaxKind { |
| 366 | |
| 367 | value = ''; |
| 368 | scanError = ScanError.None; |
| 369 | |
| 370 | tokenOffset = pos; |
| 371 | |
| 372 | if (pos >= len) { |
| 373 | // at the end |
| 374 | tokenOffset = len; |
| 375 | return token = SyntaxKind.EOF; |
| 376 | } |
| 377 | |
| 378 | let code = text.charCodeAt(pos); |
| 379 | // trivia: whitespace |
| 380 | if (isWhitespace(code)) { |
| 381 | do { |
| 382 | pos++; |
| 383 | value += String.fromCharCode(code); |
| 384 | code = text.charCodeAt(pos); |
| 385 | } while (isWhitespace(code)); |
| 386 | |
| 387 | return token = SyntaxKind.Trivia; |
| 388 | } |
| 389 | |
| 390 | // trivia: newlines |
| 391 | if (isLineBreak(code)) { |
| 392 | pos++; |
| 393 | value += String.fromCharCode(code); |
| 394 | if (code === CharacterCodes.carriageReturn && text.charCodeAt(pos) === CharacterCodes.lineFeed) { |
| 395 | pos++; |
| 396 | value += '\n'; |
| 397 | } |
| 398 | return token = SyntaxKind.LineBreakTrivia; |
| 399 | } |
| 400 | |
| 401 | switch (code) { |
| 402 | // tokens: []{}:, |
| 403 | case CharacterCodes.openBrace: |
| 404 | pos++; |
| 405 | return token = SyntaxKind.OpenBraceToken; |
| 406 | case CharacterCodes.closeBrace: |
| 407 | pos++; |
| 408 | return token = SyntaxKind.CloseBraceToken; |
| 409 | case CharacterCodes.openBracket: |
| 410 | pos++; |
| 411 | return token = SyntaxKind.OpenBracketToken; |
| 412 | case CharacterCodes.closeBracket: |
| 413 | pos++; |
| 414 | return token = SyntaxKind.CloseBracketToken; |
| 415 | case CharacterCodes.colon: |
| 416 | pos++; |
| 417 | return token = SyntaxKind.ColonToken; |
| 418 | case CharacterCodes.comma: |
| 419 | pos++; |
| 420 | return token = SyntaxKind.CommaToken; |
| 421 | |
| 422 | // strings |
no test coverage detected
searching dependent graphs…