MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / getEscapedIdentifier

Function getEscapedIdentifier

scripts/libs/esprima.js:572–615  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

570 }
571
572 function getEscapedIdentifier() {
573 var ch, id;
574
575 ch = source.charCodeAt(index++);
576 id = String.fromCharCode(ch);
577
578 // '\u' (U+005C, U+0075) denotes an escaped character.
579 if (ch === 0x5C) {
580 if (source.charCodeAt(index) !== 0x75) {
581 throwUnexpectedToken();
582 }
583 ++index;
584 ch = scanHexEscape('u');
585 if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
586 throwUnexpectedToken();
587 }
588 id = ch;
589 }
590
591 while (index < length) {
592 ch = source.charCodeAt(index);
593 if (!isIdentifierPart(ch)) {
594 break;
595 }
596 ++index;
597 id += String.fromCharCode(ch);
598
599 // '\u' (U+005C, U+0075) denotes an escaped character.
600 if (ch === 0x5C) {
601 id = id.substr(0, id.length - 1);
602 if (source.charCodeAt(index) !== 0x75) {
603 throwUnexpectedToken();
604 }
605 ++index;
606 ch = scanHexEscape('u');
607 if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
608 throwUnexpectedToken();
609 }
610 id += ch;
611 }
612 }
613
614 return id;
615 }
616
617 function getIdentifier() {
618 var start, ch;

Callers 2

getIdentifierFunction · 0.85
scanIdentifierFunction · 0.85

Calls 4

throwUnexpectedTokenFunction · 0.85
scanHexEscapeFunction · 0.85
isIdentifierStartFunction · 0.85
isIdentifierPartFunction · 0.85

Tested by

no test coverage detected