MCPcopy Index your code
hub / github.com/nodejs/node / scanExtendedUnicodeEscape

Function scanExtendedUnicodeEscape

test/fixtures/snapshot/typescript.js:11259–11288  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11257 }
11258 }
11259 function scanExtendedUnicodeEscape() {
11260 var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
11261 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
11262 var isInvalidExtendedEscape = false;
11263 // Validate the value of the digit
11264 if (escapedValue < 0) {
11265 error(ts.Diagnostics.Hexadecimal_digit_expected);
11266 isInvalidExtendedEscape = true;
11267 }
11268 else if (escapedValue > 0x10FFFF) {
11269 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
11270 isInvalidExtendedEscape = true;
11271 }
11272 if (pos >= end) {
11273 error(ts.Diagnostics.Unexpected_end_of_text);
11274 isInvalidExtendedEscape = true;
11275 }
11276 else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) {
11277 // Only swallow the following character up if it's a '}'.
11278 pos++;
11279 }
11280 else {
11281 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
11282 isInvalidExtendedEscape = true;
11283 }
11284 if (isInvalidExtendedEscape) {
11285 return "";
11286 }
11287 return utf16EncodeAsString(escapedValue);
11288 }
11289 // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX'
11290 // and return code point value if valid Unicode escape is found. Otherwise return -1.
11291 function peekUnicodeEscape() {

Callers 4

scanEscapeSequenceFunction · 0.85
scanIdentifierPartsFunction · 0.85
scanFunction · 0.85
scanJsDocTokenFunction · 0.85

Calls 3

utf16EncodeAsStringFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected