MCPcopy
hub / github.com/BloombergGraphics/whatiscode / skipMultiLineComment

Function skipMultiLineComment

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

Source from the content-addressed store, hash-verified

409 }
410
411 function skipMultiLineComment() {
412 var start, loc, ch, comment;
413
414 if (extra.comments) {
415 start = index - 2;
416 loc = {
417 start: {
418 line: lineNumber,
419 column: index - lineStart - 2
420 }
421 };
422 }
423
424 while (index < length) {
425 ch = source.charCodeAt(index);
426 if (isLineTerminator(ch)) {
427 if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) {
428 ++index;
429 }
430 hasLineTerminator = true;
431 ++lineNumber;
432 ++index;
433 lineStart = index;
434 } else if (ch === 0x2A) {
435 // Block comment ends with '*/'.
436 if (source.charCodeAt(index + 1) === 0x2F) {
437 ++index;
438 ++index;
439 if (extra.comments) {
440 comment = source.slice(start + 2, index - 2);
441 loc.end = {
442 line: lineNumber,
443 column: index - lineStart
444 };
445 addComment('Block', comment, start, index, loc);
446 }
447 return;
448 }
449 ++index;
450 } else {
451 ++index;
452 }
453 }
454
455 // Ran off the end of the file - the whole thing is a comment
456 if (extra.comments) {
457 loc.end = {
458 line: lineNumber,
459 column: index - lineStart
460 };
461 comment = source.slice(start + 2, index);
462 addComment('Block', comment, start, index, loc);
463 }
464 tolerateUnexpectedToken();
465 }
466
467 function skipComment() {
468 var ch, start;

Callers 1

skipCommentFunction · 0.85

Calls 3

isLineTerminatorFunction · 0.85
addCommentFunction · 0.85
tolerateUnexpectedTokenFunction · 0.85

Tested by

no test coverage detected