MCPcopy Create free account
hub / github.com/microsoft/SandDance / scanRegExpBody

Function scanRegExpBody

docs/app/js/sanddance-app.js:143901–143932  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143899 }
143900}
143901function scanRegExpBody() {
143902 var ch, str, classMarker, terminated, body;
143903 ch = source[index];
143904 assert(ch === "/", "Regular expression literal must start with a slash");
143905 str = source[index++];
143906 classMarker = false;
143907 terminated = false;
143908 while(index < length){
143909 ch = source[index++];
143910 str += ch;
143911 if (ch === "\\") {
143912 ch = source[index++]; // ECMA-262 7.8.5
143913 if (isLineTerminator(ch.charCodeAt(0))) throwError({}, MessageUnterminatedRegExp);
143914 str += ch;
143915 } else if (isLineTerminator(ch.charCodeAt(0))) throwError({}, MessageUnterminatedRegExp);
143916 else if (classMarker) {
143917 if (ch === "]") classMarker = false;
143918 } else {
143919 if (ch === "/") {
143920 terminated = true;
143921 break;
143922 } else if (ch === "[") classMarker = true;
143923 }
143924 }
143925 if (!terminated) throwError({}, MessageUnterminatedRegExp);
143926 // Exclude leading and trailing slash.
143927 body = str.substr(1, str.length - 2);
143928 return {
143929 value: body,
143930 literal: str
143931 };
143932}
143933function scanRegExpFlags() {
143934 var ch, str, flags;
143935 str = "";

Callers 1

scanRegExpFunction · 0.70

Calls 3

assertFunction · 0.70
isLineTerminatorFunction · 0.70
throwErrorFunction · 0.70

Tested by

no test coverage detected