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

Function scanPunctuator

jsonpath.js:638–786  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

636 // 7.7 Punctuators
637
638 function scanPunctuator() {
639 var start = index,
640 code = source.charCodeAt(index),
641 code2,
642 ch1 = source[index],
643 ch2,
644 ch3,
645 ch4;
646
647 switch (code) {
648
649 // Check for most common single-character punctuators.
650 case 0x2E: // . dot
651 case 0x28: // ( open bracket
652 case 0x29: // ) close bracket
653 case 0x3B: // ; semicolon
654 case 0x2C: // , comma
655 case 0x7B: // { open curly brace
656 case 0x7D: // } close curly brace
657 case 0x5B: // [
658 case 0x5D: // ]
659 case 0x3A: // :
660 case 0x3F: // ?
661 case 0x7E: // ~
662 ++index;
663 if (extra.tokenize) {
664 if (code === 0x28) {
665 extra.openParenToken = extra.tokens.length;
666 } else if (code === 0x7B) {
667 extra.openCurlyToken = extra.tokens.length;
668 }
669 }
670 return {
671 type: Token.Punctuator,
672 value: String.fromCharCode(code),
673 lineNumber: lineNumber,
674 lineStart: lineStart,
675 start: start,
676 end: index
677 };
678
679 default:
680 code2 = source.charCodeAt(index + 1);
681
682 // '=' (U+003D) marks an assignment or comparison operator.
683 if (code2 === 0x3D) {
684 switch (code) {
685 case 0x2B: // +
686 case 0x2D: // -
687 case 0x2F: // /
688 case 0x3C: // <
689 case 0x3E: // >
690 case 0x5E: // ^
691 case 0x7C: // |
692 case 0x25: // %
693 case 0x26: // &
694 case 0x2A: // *
695 index += 2;

Callers 2

advanceSlashFunction · 0.85
advanceFunction · 0.85

Calls 1

throwErrorFunction · 0.85

Tested by

no test coverage detected