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

Function skipComment

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

Source from the content-addressed store, hash-verified

465 }
466
467 function skipComment() {
468 var ch, start;
469 hasLineTerminator = false;
470
471 start = (index === 0);
472 while (index < length) {
473 ch = source.charCodeAt(index);
474
475 if (isWhiteSpace(ch)) {
476 ++index;
477 } else if (isLineTerminator(ch)) {
478 hasLineTerminator = true;
479 ++index;
480 if (ch === 0x0D && source.charCodeAt(index) === 0x0A) {
481 ++index;
482 }
483 ++lineNumber;
484 lineStart = index;
485 start = true;
486 } else if (ch === 0x2F) { // U+002F is '/'
487 ch = source.charCodeAt(index + 1);
488 if (ch === 0x2F) {
489 ++index;
490 ++index;
491 skipSingleLineComment(2);
492 start = true;
493 } else if (ch === 0x2A) { // U+002A is '*'
494 ++index;
495 ++index;
496 skipMultiLineComment();
497 } else {
498 break;
499 }
500 } else if (start && ch === 0x2D) { // U+002D is '-'
501 // U+003E is '>'
502 if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) {
503 // '-->' is a single-line comment
504 index += 3;
505 skipSingleLineComment(3);
506 } else {
507 break;
508 }
509 } else if (ch === 0x3C) { // U+003C is '<'
510 if (source.slice(index + 1, index + 4) === '!--') {
511 ++index; // `<`
512 ++index; // `!`
513 ++index; // `-`
514 ++index; // `-`
515 skipSingleLineComment(4);
516 } else {
517 break;
518 }
519 } else {
520 break;
521 }
522 }
523 }
524

Callers 4

scanRegExpFunction · 0.85
collectRegexFunction · 0.85
lexFunction · 0.85
peekFunction · 0.85

Calls 4

isWhiteSpaceFunction · 0.85
isLineTerminatorFunction · 0.85
skipSingleLineCommentFunction · 0.85
skipMultiLineCommentFunction · 0.85

Tested by

no test coverage detected