MCPcopy Index your code
hub / github.com/BloombergGraphics/whatiscode / scanPunctuator

Function scanPunctuator

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

Source from the content-addressed store, hash-verified

671 // 7.7 Punctuators
672
673 function scanPunctuator() {
674 var token, str;
675
676 token = {
677 type: Token.Punctuator,
678 value: '',
679 lineNumber: lineNumber,
680 lineStart: lineStart,
681 start: index,
682 end: index
683 };
684
685 // Check for most common single-character punctuators.
686 str = source[index];
687 switch (str) {
688
689 case '(':
690 if (extra.tokenize) {
691 extra.openParenToken = extra.tokens.length;
692 }
693 ++index;
694 break;
695
696 case '{':
697 if (extra.tokenize) {
698 extra.openCurlyToken = extra.tokens.length;
699 }
700 ++index;
701 break;
702
703 case '.':
704 ++index;
705 if (source[index] === '.' && source[index + 1] === '.') {
706 // Spread operator: ...
707 index += 2;
708 str = '...';
709 }
710 break;
711
712 case ')':
713 case ';':
714 case ',':
715 case '}':
716 case '[':
717 case ']':
718 case ':':
719 case '?':
720 case '~':
721 ++index;
722 break;
723
724 default:
725 // 4-character punctuator.
726 str = source.substr(index, 4);
727 if (str === '>>>=') {
728 index += 4;
729 } else {
730

Callers 2

advanceSlashFunction · 0.85
advanceFunction · 0.85

Calls 1

throwUnexpectedTokenFunction · 0.85

Tested by

no test coverage detected