MCPcopy Index your code
hub / github.com/nodejs/node / reScanSlashToken

Function reScanSlashToken

test/fixtures/snapshot/typescript.js:11919–11968  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11917 return token = 63 /* SyntaxKind.EqualsToken */;
11918 }
11919 function reScanSlashToken() {
11920 if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) {
11921 var p = tokenPos + 1;
11922 var inEscape = false;
11923 var inCharacterClass = false;
11924 while (true) {
11925 // If we reach the end of a file, or hit a newline, then this is an unterminated
11926 // regex. Report error and return what we have so far.
11927 if (p >= end) {
11928 tokenFlags |= 4 /* TokenFlags.Unterminated */;
11929 error(ts.Diagnostics.Unterminated_regular_expression_literal);
11930 break;
11931 }
11932 var ch = text.charCodeAt(p);
11933 if (isLineBreak(ch)) {
11934 tokenFlags |= 4 /* TokenFlags.Unterminated */;
11935 error(ts.Diagnostics.Unterminated_regular_expression_literal);
11936 break;
11937 }
11938 if (inEscape) {
11939 // Parsing an escape character;
11940 // reset the flag and just advance to the next char.
11941 inEscape = false;
11942 }
11943 else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) {
11944 // A slash within a character class is permissible,
11945 // but in general it signals the end of the regexp literal.
11946 p++;
11947 break;
11948 }
11949 else if (ch === 91 /* CharacterCodes.openBracket */) {
11950 inCharacterClass = true;
11951 }
11952 else if (ch === 92 /* CharacterCodes.backslash */) {
11953 inEscape = true;
11954 }
11955 else if (ch === 93 /* CharacterCodes.closeBracket */) {
11956 inCharacterClass = false;
11957 }
11958 p++;
11959 }
11960 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
11961 p++;
11962 }
11963 pos = p;
11964 tokenValue = text.substring(tokenPos, pos);
11965 token = 13 /* SyntaxKind.RegularExpressionLiteral */;
11966 }
11967 return token;
11968 }
11969 function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
11970 var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx);
11971 if (type === undefined) {

Callers 1

parsePrimaryExpressionFunction · 0.85

Calls 3

isLineBreakFunction · 0.85
isIdentifierPartFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected