From 2f7556256a211effc8f61295e5ed1b4e9b89eb01 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 21 Sep 2015 21:30:10 -0700 Subject: [PATCH] removed duplicate function implementation --- src/compiler/scanner.ts | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 82fbc8c2a59..58ca14ab577 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -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++; @@ -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); @@ -1439,7 +1427,7 @@ 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(); @@ -1447,9 +1435,9 @@ namespace ts { 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(); @@ -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; @@ -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 {