Skip to content

Commit

Permalink
Add missing nextLine entry to whitespace, remove unnecessary branches.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Jul 2, 2024
1 parent 9e5e29f commit db10cae
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,12 @@ for (
[CharacterCodes.paragraphSeparator, TokenCategory.LineBreak],

// Single Line Whitespace
[CharacterCodes.space, TokenCategory.Whitespace],
[CharacterCodes.tab, TokenCategory.Whitespace],
[CharacterCodes.verticalTab, TokenCategory.Whitespace],
[CharacterCodes.formFeed, TokenCategory.Whitespace],
[CharacterCodes.space, TokenCategory.Whitespace],
[CharacterCodes.nonBreakingSpace, TokenCategory.Whitespace],
[CharacterCodes.nextLine, TokenCategory.Whitespace],
[CharacterCodes.ogham, TokenCategory.Whitespace],
[CharacterCodes.enQuad, TokenCategory.Whitespace],
[CharacterCodes.emQuad, TokenCategory.Whitespace],
Expand Down Expand Up @@ -2033,15 +2034,6 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
if (identifierKind) {
return token = identifierKind;
}
else if (isWhiteSpaceSingleLine(ch)) {
pos += charSize(ch);
continue;
}
else if (isLineBreak(ch)) {
tokenFlags |= TokenFlags.PrecedingLineBreak;
pos += charSize(ch);
continue;
}
const size = charSize(ch);
error(Diagnostics.Invalid_character, pos, size);
pos += size;
Expand All @@ -2061,6 +2053,12 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
}
}

if (tokenCategory & TokenCategory.LineBreak) {
tokenFlags |= TokenFlags.PrecedingLineBreak;
pos += charSize(ch);
continue;
}

if (tokenCategory & TokenCategory.SimpleToken) {
pos++;
return token = tokenCategory & TokenCategory.SimpleTokenMask;
Expand Down

0 comments on commit db10cae

Please sign in to comment.