Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,18 +739,6 @@ namespace ts {
}
}

function isIdentifierStart(ch: number): boolean {
return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
ch === CharacterCodes.$ || ch === CharacterCodes._ ||
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch, languageVersion);
}

function isIdentifierPart(ch: number): boolean {
return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ ||
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
}

function scanNumber(): number {
let start = pos;
while (isDigit(text.charCodeAt(pos))) pos++;
Expand Down Expand Up @@ -1064,12 +1052,12 @@ namespace ts {
let start = pos;
while (pos < end) {
let ch = text.charCodeAt(pos);
if (isIdentifierPart(ch)) {
if (isIdentifierPart(ch, languageVersion)) {
pos++;
}
else if (ch === CharacterCodes.backslash) {
ch = peekUnicodeEscape();
if (!(ch >= 0 && isIdentifierPart(ch))) {
if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
break;
}
result += text.substring(start, pos);
Expand Down Expand Up @@ -1439,17 +1427,17 @@ namespace ts {
return pos++, token = SyntaxKind.AtToken;
case CharacterCodes.backslash:
let cookedChar = peekUnicodeEscape();
if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
pos += 6;
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
return token = getIdentifierToken();
}
error(Diagnostics.Invalid_character);
return pos++, token = SyntaxKind.Unknown;
default:
if (isIdentifierStart(ch)) {
if (isIdentifierStart(ch, languageVersion)) {
pos++;
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) pos++;
while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++;
tokenValue = text.substring(tokenPos, pos);
if (ch === CharacterCodes.backslash) {
tokenValue += scanIdentifierParts();
Expand Down Expand Up @@ -1536,7 +1524,7 @@ namespace ts {
p++;
}

while (p < end && isIdentifierPart(text.charCodeAt(p))) {
while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
p++;
}
pos = p;
Expand Down Expand Up @@ -1599,7 +1587,7 @@ namespace ts {
let firstCharPosition = pos;
while (pos < end) {
let ch = text.charCodeAt(pos);
if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) {
if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) {
pos++;
}
else {
Expand Down