MCPcopy Create free account
hub / github.com/dchester/jsonpath / scanIdentifier

Function scanIdentifier

jsonpath.js:603–633  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

601 }
602
603 function scanIdentifier() {
604 var start, id, type;
605
606 start = index;
607
608 // Backslash (U+005C) starts an escaped character.
609 id = (source.charCodeAt(index) === 0x5C) ? getEscapedIdentifier() : getIdentifier();
610
611 // There is no keyword or literal with only one character.
612 // Thus, it must be an identifier.
613 if (id.length === 1) {
614 type = Token.Identifier;
615 } else if (isKeyword(id)) {
616 type = Token.Keyword;
617 } else if (id === 'null') {
618 type = Token.NullLiteral;
619 } else if (id === 'true' || id === 'false') {
620 type = Token.BooleanLiteral;
621 } else {
622 type = Token.Identifier;
623 }
624
625 return {
626 type: type,
627 value: id,
628 lineNumber: lineNumber,
629 lineStart: lineStart,
630 start: start,
631 end: index
632 };
633 }
634
635
636 // 7.7 Punctuators

Callers 1

advanceFunction · 0.85

Calls 3

getEscapedIdentifierFunction · 0.85
getIdentifierFunction · 0.85
isKeywordFunction · 0.85

Tested by

no test coverage detected