Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lexer.js 52KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. let source, pos, end;
  2. let openTokenDepth,
  3. templateDepth,
  4. lastTokenPos,
  5. lastSlashWasDivision,
  6. templateStack,
  7. templateStackDepth,
  8. openTokenPosStack,
  9. openClassPosStack,
  10. nextBraceIsClass,
  11. starExportMap,
  12. lastStarExportSpecifier,
  13. _exports,
  14. unsafeGetters,
  15. reexports;
  16. function resetState () {
  17. openTokenDepth = 0;
  18. templateDepth = -1;
  19. lastTokenPos = -1;
  20. lastSlashWasDivision = false;
  21. templateStack = new Array(1024);
  22. templateStackDepth = 0;
  23. openTokenPosStack = new Array(1024);
  24. openClassPosStack = new Array(1024);
  25. nextBraceIsClass = false;
  26. starExportMap = Object.create(null);
  27. lastStarExportSpecifier = null;
  28. _exports = new Set();
  29. unsafeGetters = new Set();
  30. reexports = new Set();
  31. }
  32. // RequireType
  33. const Import = 0;
  34. const ExportAssign = 1;
  35. const ExportStar = 2;
  36. function parseCJS (source, name = '@') {
  37. resetState();
  38. try {
  39. parseSource(source);
  40. }
  41. catch (e) {
  42. e.message += `\n at ${name}:${source.slice(0, pos).split('\n').length}:${pos - source.lastIndexOf('\n', pos - 1)}`;
  43. e.loc = pos;
  44. throw e;
  45. }
  46. const result = { exports: [..._exports].filter(expt => expt !== undefined && !unsafeGetters.has(expt)), reexports: [...reexports].filter(reexpt => reexpt !== undefined) };
  47. resetState();
  48. return result;
  49. }
  50. function decode (str) {
  51. if (str[0] === '"' || str[0] === '\'') {
  52. try {
  53. const decoded = (0, eval)(str);
  54. // Filter to exclude non-matching UTF-16 surrogate strings
  55. for (let i = 0; i < decoded.length; i++) {
  56. const surrogatePrefix = decoded.charCodeAt(i) & 0xFC00;
  57. if (surrogatePrefix < 0xD800) {
  58. // Not a surrogate
  59. continue;
  60. }
  61. else if (surrogatePrefix === 0xD800) {
  62. // Validate surrogate pair
  63. if ((decoded.charCodeAt(++i) & 0xFC00) !== 0xDC00)
  64. return;
  65. }
  66. else {
  67. // Out-of-range surrogate code (above 0xD800)
  68. return;
  69. }
  70. }
  71. return decoded;
  72. }
  73. catch {}
  74. }
  75. else {
  76. return str;
  77. }
  78. }
  79. function parseSource (cjsSource) {
  80. source = cjsSource;
  81. pos = -1;
  82. end = source.length - 1;
  83. let ch = 0;
  84. // Handle #!
  85. if (source.charCodeAt(0) === 35/*#*/ && source.charCodeAt(1) === 33/*!*/) {
  86. if (source.length === 2)
  87. return true;
  88. pos += 2;
  89. while (pos++ < end) {
  90. ch = source.charCodeAt(pos);
  91. if (ch === 10/*\n*/ || ch === 13/*\r*/)
  92. break;
  93. }
  94. }
  95. while (pos++ < end) {
  96. ch = source.charCodeAt(pos);
  97. if (ch === 32 || ch < 14 && ch > 8)
  98. continue;
  99. if (openTokenDepth === 0) {
  100. switch (ch) {
  101. case 105/*i*/:
  102. if (source.startsWith('mport', pos + 1) && keywordStart(pos))
  103. throwIfImportStatement();
  104. lastTokenPos = pos;
  105. continue;
  106. case 114/*r*/:
  107. const startPos = pos;
  108. if (tryParseRequire(Import) && keywordStart(startPos))
  109. tryBacktrackAddStarExportBinding(startPos - 1);
  110. lastTokenPos = pos;
  111. continue;
  112. case 95/*_*/:
  113. if (source.startsWith('interopRequireWildcard', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) {
  114. const startPos = pos;
  115. pos += 23;
  116. if (source.charCodeAt(pos) === 40/*(*/) {
  117. pos++;
  118. openTokenPosStack[openTokenDepth++] = lastTokenPos;
  119. if (tryParseRequire(Import) && keywordStart(startPos)) {
  120. tryBacktrackAddStarExportBinding(startPos - 1);
  121. }
  122. }
  123. }
  124. else if (source.startsWith('_export', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) {
  125. pos += 8;
  126. if (source.startsWith('Star', pos))
  127. pos += 4;
  128. if (source.charCodeAt(pos) === 40/*(*/) {
  129. openTokenPosStack[openTokenDepth++] = lastTokenPos;
  130. if (source.charCodeAt(++pos) === 114/*r*/)
  131. tryParseRequire(ExportStar);
  132. }
  133. }
  134. lastTokenPos = pos;
  135. continue;
  136. }
  137. }
  138. switch (ch) {
  139. case 101/*e*/:
  140. if (source.startsWith('xport', pos + 1) && keywordStart(pos)) {
  141. if (source.charCodeAt(pos + 6) === 115/*s*/)
  142. tryParseExportsDotAssign(false);
  143. else if (openTokenDepth === 0)
  144. throwIfExportStatement();
  145. }
  146. break;
  147. case 99/*c*/:
  148. if (keywordStart(pos) && source.startsWith('lass', pos + 1) && isBrOrWs(source.charCodeAt(pos + 5)))
  149. nextBraceIsClass = true;
  150. break;
  151. case 109/*m*/:
  152. if (source.startsWith('odule', pos + 1) && keywordStart(pos))
  153. tryParseModuleExportsDotAssign();
  154. break;
  155. case 79/*O*/:
  156. if (source.startsWith('bject', pos + 1) && keywordStart(pos))
  157. tryParseObjectDefineOrKeys(openTokenDepth === 0);
  158. break;
  159. case 40/*(*/:
  160. openTokenPosStack[openTokenDepth++] = lastTokenPos;
  161. break;
  162. case 41/*)*/:
  163. if (openTokenDepth === 0)
  164. throw new Error('Unexpected closing bracket.');
  165. openTokenDepth--;
  166. break;
  167. case 123/*{*/:
  168. openClassPosStack[openTokenDepth] = nextBraceIsClass;
  169. nextBraceIsClass = false;
  170. openTokenPosStack[openTokenDepth++] = lastTokenPos;
  171. break;
  172. case 125/*}*/:
  173. if (openTokenDepth === 0)
  174. throw new Error('Unexpected closing brace.');
  175. if (openTokenDepth-- === templateDepth) {
  176. templateDepth = templateStack[--templateStackDepth];
  177. templateString();
  178. }
  179. else {
  180. if (templateDepth !== -1 && openTokenDepth < templateDepth)
  181. throw new Error('Unexpected closing brace.');
  182. }
  183. break;
  184. case 60/*>*/:
  185. // TODO: <!-- XML comment support
  186. break;
  187. case 39/*'*/:
  188. case 34/*"*/:
  189. stringLiteral(ch);
  190. break;
  191. case 47/*/*/: {
  192. const next_ch = source.charCodeAt(pos + 1);
  193. if (next_ch === 47/*/*/) {
  194. lineComment();
  195. // dont update lastToken
  196. continue;
  197. }
  198. else if (next_ch === 42/***/) {
  199. blockComment();
  200. // dont update lastToken
  201. continue;
  202. }
  203. else {
  204. // Division / regex ambiguity handling based on checking backtrack analysis of:
  205. // - what token came previously (lastToken)
  206. // - if a closing brace or paren, what token came before the corresponding
  207. // opening brace or paren (lastOpenTokenIndex)
  208. const lastToken = source.charCodeAt(lastTokenPos);
  209. if (isExpressionPunctuator(lastToken) &&
  210. !(lastToken === 46/*.*/ && (source.charCodeAt(lastTokenPos - 1) >= 48/*0*/ && source.charCodeAt(lastTokenPos - 1) <= 57/*9*/)) &&
  211. !(lastToken === 43/*+*/ && source.charCodeAt(lastTokenPos - 1) === 43/*+*/) && !(lastToken === 45/*-*/ && source.charCodeAt(lastTokenPos - 1) === 45/*-*/) ||
  212. lastToken === 41/*)*/ && isParenKeyword(openTokenPosStack[openTokenDepth]) ||
  213. lastToken === 125/*}*/ && (isExpressionTerminator(openTokenPosStack[openTokenDepth]) || openClassPosStack[openTokenDepth]) ||
  214. lastToken === 47/*/*/ && lastSlashWasDivision ||
  215. isExpressionKeyword(lastTokenPos) ||
  216. !lastToken) {
  217. regularExpression();
  218. lastSlashWasDivision = false;
  219. }
  220. else {
  221. lastSlashWasDivision = true;
  222. }
  223. }
  224. break;
  225. }
  226. case 96/*`*/:
  227. templateString();
  228. break;
  229. }
  230. lastTokenPos = pos;
  231. }
  232. if (templateDepth !== -1)
  233. throw new Error('Unterminated template.');
  234. if (openTokenDepth)
  235. throw new Error('Unterminated braces.');
  236. }
  237. function tryBacktrackAddStarExportBinding (bPos) {
  238. while (source.charCodeAt(bPos) === 32/* */ && bPos >= 0)
  239. bPos--;
  240. if (source.charCodeAt(bPos) === 61/*=*/) {
  241. bPos--;
  242. while (source.charCodeAt(bPos) === 32/* */ && bPos >= 0)
  243. bPos--;
  244. let codePoint;
  245. const id_end = bPos;
  246. let identifierStart = false;
  247. while ((codePoint = codePointAtLast(bPos)) && bPos >= 0) {
  248. if (codePoint === 92/*\*/)
  249. return;
  250. if (!isIdentifierChar(codePoint, true))
  251. break;
  252. identifierStart = isIdentifierStart(codePoint, true);
  253. bPos -= codePointLen(codePoint);
  254. }
  255. if (identifierStart && source.charCodeAt(bPos) === 32/* */) {
  256. const starExportId = source.slice(bPos + 1, id_end + 1);
  257. while (source.charCodeAt(bPos) === 32/* */ && bPos >= 0)
  258. bPos--;
  259. switch (source.charCodeAt(bPos)) {
  260. case 114/*r*/:
  261. if (!source.startsWith('va', bPos - 2))
  262. return;
  263. break;
  264. case 116/*t*/:
  265. if (!source.startsWith('le', bPos - 2) && !source.startsWith('cons', bPos - 4))
  266. return;
  267. break;
  268. default: return;
  269. }
  270. starExportMap[starExportId] = lastStarExportSpecifier;
  271. }
  272. }
  273. }
  274. // `Object.` `prototype.`? hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)`
  275. function tryParseObjectHasOwnProperty (it_id) {
  276. ch = commentWhitespace();
  277. if (ch !== 79/*O*/ || !source.startsWith('bject', pos + 1)) return false;
  278. pos += 6;
  279. ch = commentWhitespace();
  280. if (ch !== 46/*.*/) return false;
  281. pos++;
  282. ch = commentWhitespace();
  283. if (ch === 112/*p*/) {
  284. if (!source.startsWith('rototype', pos + 1)) return false;
  285. pos += 9;
  286. ch = commentWhitespace();
  287. if (ch !== 46/*.*/) return false;
  288. pos++;
  289. ch = commentWhitespace();
  290. }
  291. if (ch !== 104/*h*/ || !source.startsWith('asOwnProperty', pos + 1)) return false;
  292. pos += 14;
  293. ch = commentWhitespace();
  294. if (ch !== 46/*.*/) return false;
  295. pos++;
  296. ch = commentWhitespace();
  297. if (ch !== 99/*c*/ || !source.startsWith('all', pos + 1)) return false;
  298. pos += 4;
  299. ch = commentWhitespace();
  300. if (ch !== 40/*(*/) return false;
  301. pos++;
  302. ch = commentWhitespace();
  303. if (!identifier()) return false;
  304. ch = commentWhitespace();
  305. if (ch !== 44/*,*/) return false;
  306. pos++;
  307. ch = commentWhitespace();
  308. if (!source.startsWith(it_id, pos)) return false;
  309. pos += it_id.length;
  310. ch = commentWhitespace();
  311. if (ch !== 41/*)*/) return false;
  312. pos++;
  313. return true;
  314. }
  315. function tryParseObjectDefineOrKeys (keys) {
  316. pos += 6;
  317. let revertPos = pos - 1;
  318. let ch = commentWhitespace();
  319. if (ch === 46/*.*/) {
  320. pos++;
  321. ch = commentWhitespace();
  322. if (ch === 100/*d*/ && source.startsWith('efineProperty', pos + 1)) {
  323. let expt;
  324. while (true) {
  325. pos += 14;
  326. revertPos = pos - 1;
  327. ch = commentWhitespace();
  328. if (ch !== 40/*(*/) break;
  329. pos++;
  330. ch = commentWhitespace();
  331. if (!readExportsOrModuleDotExports(ch)) break;
  332. ch = commentWhitespace();
  333. if (ch !== 44/*,*/) break;
  334. pos++;
  335. ch = commentWhitespace();
  336. if (ch !== 39/*'*/ && ch !== 34/*"*/) break;
  337. const exportPos = pos;
  338. stringLiteral(ch);
  339. expt = source.slice(exportPos, ++pos);
  340. ch = commentWhitespace();
  341. if (ch !== 44/*,*/) break;
  342. pos++;
  343. ch = commentWhitespace();
  344. if (ch !== 123/*{*/) break;
  345. pos++;
  346. ch = commentWhitespace();
  347. if (ch === 101/*e*/) {
  348. if (!source.startsWith('numerable', pos + 1)) break;
  349. pos += 10;
  350. ch = commentWhitespace();
  351. if (ch !== 58/*:*/) break;
  352. pos++;
  353. ch = commentWhitespace();
  354. if (ch !== 116/*t*/ || !source.startsWith('rue', pos + 1)) break;
  355. pos += 4;
  356. ch = commentWhitespace();
  357. if (ch !== 44) break;
  358. pos++;
  359. ch = commentWhitespace();
  360. }
  361. if (ch === 118/*v*/) {
  362. if (!source.startsWith('alue', pos + 1)) break;
  363. pos += 5;
  364. ch = commentWhitespace();
  365. if (ch !== 58/*:*/) break;
  366. _exports.add(decode(expt));
  367. pos = revertPos;
  368. return;
  369. }
  370. else if (ch === 103/*g*/) {
  371. if (!source.startsWith('et', pos + 1)) break;
  372. pos += 3;
  373. ch = commentWhitespace();
  374. if (ch === 58/*:*/) {
  375. pos++;
  376. ch = commentWhitespace();
  377. if (ch !== 102/*f*/) break;
  378. if (!source.startsWith('unction', pos + 1)) break;
  379. pos += 8;
  380. let lastPos = pos;
  381. ch = commentWhitespace();
  382. if (ch !== 40 && (lastPos === pos || !identifier())) break;
  383. ch = commentWhitespace();
  384. }
  385. if (ch !== 40/*(*/) break;
  386. pos++;
  387. ch = commentWhitespace();
  388. if (ch !== 41/*)*/) break;
  389. pos++;
  390. ch = commentWhitespace();
  391. if (ch !== 123/*{*/) break;
  392. pos++;
  393. ch = commentWhitespace();
  394. if (ch !== 114/*r*/) break;
  395. if (!source.startsWith('eturn', pos + 1)) break;
  396. pos += 6;
  397. ch = commentWhitespace();
  398. if (!identifier()) break;
  399. ch = commentWhitespace();
  400. if (ch === 46/*.*/) {
  401. pos++;
  402. commentWhitespace();
  403. if (!identifier()) break;
  404. ch = commentWhitespace();
  405. }
  406. else if (ch === 91/*[*/) {
  407. pos++;
  408. ch = commentWhitespace();
  409. if (ch === 39/*'*/ || ch === 34/*"*/) stringLiteral(ch);
  410. else break;
  411. pos++;
  412. ch = commentWhitespace();
  413. if (ch !== 93/*]*/) break;
  414. pos++;
  415. ch = commentWhitespace();
  416. }
  417. if (ch === 59/*;*/) {
  418. pos++;
  419. ch = commentWhitespace();
  420. }
  421. if (ch !== 125/*}*/) break;
  422. pos++;
  423. ch = commentWhitespace();
  424. if (ch === 44/*,*/) {
  425. pos++;
  426. ch = commentWhitespace();
  427. }
  428. if (ch !== 125/*}*/) break;
  429. pos++;
  430. ch = commentWhitespace();
  431. if (ch !== 41/*)*/) break;
  432. _exports.add(decode(expt));
  433. return;
  434. }
  435. break;
  436. }
  437. if (expt) {
  438. unsafeGetters.add(decode(expt));
  439. }
  440. }
  441. else if (keys && ch === 107/*k*/ && source.startsWith('eys', pos + 1)) {
  442. while (true) {
  443. pos += 4;
  444. revertPos = pos - 1;
  445. ch = commentWhitespace();
  446. if (ch !== 40/*(*/) break;
  447. pos++;
  448. ch = commentWhitespace();
  449. const id_start = pos;
  450. if (!identifier()) break;
  451. const id = source.slice(id_start, pos);
  452. ch = commentWhitespace();
  453. if (ch !== 41/*)*/) break;
  454. revertPos = pos++;
  455. ch = commentWhitespace();
  456. if (ch !== 46/*.*/) break;
  457. pos++;
  458. ch = commentWhitespace();
  459. if (ch !== 102/*f*/ || !source.startsWith('orEach', pos + 1)) break;
  460. pos += 7;
  461. ch = commentWhitespace();
  462. revertPos = pos - 1;
  463. if (ch !== 40/*(*/) break;
  464. pos++;
  465. ch = commentWhitespace();
  466. if (ch !== 102/*f*/ || !source.startsWith('unction', pos + 1)) break;
  467. pos += 8;
  468. ch = commentWhitespace();
  469. if (ch !== 40/*(*/) break;
  470. pos++;
  471. ch = commentWhitespace();
  472. const it_id_start = pos;
  473. if (!identifier()) break;
  474. const it_id = source.slice(it_id_start, pos);
  475. ch = commentWhitespace();
  476. if (ch !== 41/*)*/) break;
  477. pos++;
  478. ch = commentWhitespace();
  479. if (ch !== 123/*{*/) break;
  480. pos++;
  481. ch = commentWhitespace();
  482. if (ch !== 105/*i*/ || source.charCodeAt(pos + 1) !== 102/*f*/) break;
  483. pos += 2;
  484. ch = commentWhitespace();
  485. if (ch !== 40/*(*/) break;
  486. pos++;
  487. ch = commentWhitespace();
  488. if (!source.startsWith(it_id, pos)) break;
  489. pos += it_id.length;
  490. ch = commentWhitespace();
  491. // `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? |
  492. if (ch === 61/*=*/) {
  493. if (!source.startsWith('==', pos + 1)) break;
  494. pos += 3;
  495. ch = commentWhitespace();
  496. if (ch !== 34/*"*/ && ch !== 39/*'*/) break;
  497. let quot = ch;
  498. if (!source.startsWith('default', pos + 1)) break;
  499. pos += 8;
  500. ch = commentWhitespace();
  501. if (ch !== quot) break;
  502. pos += 1;
  503. ch = commentWhitespace();
  504. if (ch !== 124/*|*/ || source.charCodeAt(pos + 1) !== 124/*|*/) break;
  505. pos += 2;
  506. ch = commentWhitespace();
  507. if (source.slice(pos, pos + it_id.length) !== it_id) break;
  508. pos += it_id.length;
  509. ch = commentWhitespace();
  510. if (ch !== 61/*=*/ || source.slice(pos + 1, pos + 3) !== '==') break;
  511. pos += 3;
  512. ch = commentWhitespace();
  513. if (ch !== 34/*"*/ && ch !== 39/*'*/) break;
  514. quot = ch;
  515. if (!source.startsWith('__esModule', pos + 1)) break;
  516. pos += 11;
  517. ch = commentWhitespace();
  518. if (ch !== quot) break;
  519. pos += 1;
  520. ch = commentWhitespace();
  521. if (ch !== 41/*)*/) break;
  522. pos += 1;
  523. ch = commentWhitespace();
  524. if (ch !== 114/*r*/ || !source.startsWith('eturn', pos + 1)) break;
  525. pos += 6;
  526. ch = commentWhitespace();
  527. if (ch === 59/*;*/)
  528. pos++;
  529. ch = commentWhitespace();
  530. // `if (`
  531. if (ch === 105/*i*/ && source.charCodeAt(pos + 1) === 102/*f*/) {
  532. let inIf = true;
  533. pos += 2;
  534. ch = commentWhitespace();
  535. if (ch !== 40/*(*/) break;
  536. pos++;
  537. const ifInnerPos = pos;
  538. // `Object.prototype.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)) return` `;`?
  539. if (tryParseObjectHasOwnProperty(it_id)) {
  540. ch = commentWhitespace();
  541. if (ch !== 41/*)*/) break;
  542. pos++;
  543. ch = commentWhitespace();
  544. if (ch !== 114/*r*/ || !source.startsWith('eturn', pos + 1)) break;
  545. pos += 6;
  546. ch = commentWhitespace();
  547. if (ch === 59/*;*/)
  548. pos++;
  549. ch = commentWhitespace();
  550. // match next if
  551. if (ch === 105/*i*/ && source.charCodeAt(pos + 1) === 102/*f*/) {
  552. pos += 2;
  553. ch = commentWhitespace();
  554. if (ch !== 40/*(*/) break;
  555. pos++;
  556. }
  557. else {
  558. inIf = false;
  559. }
  560. }
  561. else {
  562. pos = ifInnerPos;
  563. }
  564. // IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`?
  565. if (inIf) {
  566. if (!source.startsWith(it_id, pos)) break;
  567. pos += it_id.length;
  568. ch = commentWhitespace();
  569. if (ch !== 105/*i*/ || !source.startsWith('n ', pos + 1)) break;
  570. pos += 3;
  571. ch = commentWhitespace();
  572. if (!readExportsOrModuleDotExports(ch)) break;
  573. ch = commentWhitespace();
  574. if (ch !== 38/*&*/ || source.charCodeAt(pos + 1) !== 38/*&*/) break;
  575. pos += 2;
  576. ch = commentWhitespace();
  577. if (!readExportsOrModuleDotExports(ch)) break;
  578. ch = commentWhitespace();
  579. if (ch !== 91/*[*/) break;
  580. pos++;
  581. ch = commentWhitespace();
  582. if (!source.startsWith(it_id, pos)) break;
  583. pos += it_id.length;
  584. ch = commentWhitespace();
  585. if (ch !== 93/*]*/) break;
  586. pos++;
  587. ch = commentWhitespace();
  588. if (ch !== 61/*=*/ || !source.startsWith('==', pos + 1)) break;
  589. pos += 3;
  590. ch = commentWhitespace();
  591. if (!source.startsWith(id, pos)) break;
  592. pos += id.length;
  593. ch = commentWhitespace();
  594. if (ch !== 91/*[*/) break;
  595. pos++;
  596. ch = commentWhitespace();
  597. if (!source.startsWith(it_id, pos)) break;
  598. pos += it_id.length;
  599. ch = commentWhitespace();
  600. if (ch !== 93/*]*/) break;
  601. pos++;
  602. ch = commentWhitespace();
  603. if (ch !== 41/*)*/) break;
  604. pos++;
  605. ch = commentWhitespace();
  606. if (ch !== 114/*r*/ || !source.startsWith('eturn', pos + 1)) break;
  607. pos += 6;
  608. ch = commentWhitespace();
  609. if (ch === 59/*;*/)
  610. pos++;
  611. ch = commentWhitespace();
  612. }
  613. }
  614. }
  615. // `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) (`&& !` IDENTIFIER `.hasOwnProperty(` IDENTIFIER$2 `)` )? `)`
  616. else if (ch === 33/*!*/) {
  617. if (!source.startsWith('==', pos + 1)) break;
  618. pos += 3;
  619. ch = commentWhitespace();
  620. if (ch !== 34/*"*/ && ch !== 39/*'*/) break;
  621. const quot = ch;
  622. if (!source.startsWith('default', pos + 1)) break;
  623. pos += 8;
  624. ch = commentWhitespace();
  625. if (ch !== quot) break;
  626. pos += 1;
  627. ch = commentWhitespace();
  628. if (ch === 38/*&*/) {
  629. if (source.charCodeAt(pos + 1) !== 38/*&*/) break;
  630. pos += 2;
  631. ch = commentWhitespace();
  632. if (ch !== 33/*!*/) break;
  633. pos += 1;
  634. ch = commentWhitespace();
  635. if (ch === 79/*O*/ && source.startsWith('bject', pos + 1) && source[pos + 6] === '.') {
  636. if (!tryParseObjectHasOwnProperty(it_id)) break;
  637. }
  638. else if (identifier()) {
  639. ch = commentWhitespace();
  640. if (ch !== 46/*.*/) break;
  641. pos++;
  642. ch = commentWhitespace();
  643. if (ch !== 104/*h*/ || !source.startsWith('asOwnProperty', pos + 1)) break;
  644. pos += 14;
  645. ch = commentWhitespace();
  646. if (ch !== 40/*(*/) break;
  647. pos += 1;
  648. ch = commentWhitespace();
  649. if (!source.startsWith(it_id, pos)) break;
  650. pos += it_id.length;
  651. ch = commentWhitespace();
  652. if (ch !== 41/*)*/) break;
  653. pos += 1;
  654. }
  655. else break;
  656. ch = commentWhitespace();
  657. }
  658. if (ch !== 41/*)*/) break;
  659. pos += 1;
  660. ch = commentWhitespace();
  661. }
  662. else break;
  663. // EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]`
  664. if (readExportsOrModuleDotExports(ch)) {
  665. ch = commentWhitespace();
  666. if (ch !== 91/*[*/) break;
  667. pos++;
  668. ch = commentWhitespace();
  669. if (source.slice(pos, pos + it_id.length) !== it_id) break;
  670. pos += it_id.length;
  671. ch = commentWhitespace();
  672. if (ch !== 93/*]*/) break;
  673. pos++;
  674. ch = commentWhitespace();
  675. if (ch !== 61/*=*/) break;
  676. pos++;
  677. ch = commentWhitespace();
  678. if (source.slice(pos, pos + id.length) !== id) break;
  679. pos += id.length;
  680. ch = commentWhitespace();
  681. if (ch !== 91/*[*/) break;
  682. pos++;
  683. ch = commentWhitespace();
  684. if (source.slice(pos, pos + it_id.length) !== it_id) break;
  685. pos += it_id.length;
  686. ch = commentWhitespace();
  687. if (ch !== 93/*]*/) break;
  688. pos++;
  689. ch = commentWhitespace();
  690. if (ch === 59/*;*/) {
  691. pos++;
  692. ch = commentWhitespace();
  693. }
  694. }
  695. // `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get: function () { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]; } })`
  696. else if (ch === 79/*O*/) {
  697. if (source.slice(pos + 1, pos + 6) !== 'bject') break;
  698. pos += 6;
  699. ch = commentWhitespace();
  700. if (ch !== 46/*.*/) break;
  701. pos++;
  702. ch = commentWhitespace();
  703. if (ch !== 100/*d*/ || !source.startsWith('efineProperty', pos + 1)) break;
  704. pos += 14;
  705. ch = commentWhitespace();
  706. if (ch !== 40/*(*/) break;
  707. pos++;
  708. ch = commentWhitespace();
  709. if (!readExportsOrModuleDotExports(ch)) break;
  710. ch = commentWhitespace();
  711. if (ch !== 44/*,*/) break;
  712. pos++;
  713. ch = commentWhitespace();
  714. if (!source.startsWith(it_id, pos)) break;
  715. pos += it_id.length;
  716. ch = commentWhitespace();
  717. if (ch !== 44/*,*/) break;
  718. pos++;
  719. ch = commentWhitespace();
  720. if (ch !== 123/*{*/) break;
  721. pos++;
  722. ch = commentWhitespace();
  723. if (ch !== 101/*e*/ || !source.startsWith('numerable', pos + 1)) break;
  724. pos += 10;
  725. ch = commentWhitespace();
  726. if (ch !== 58/*:*/) break;
  727. pos++;
  728. ch = commentWhitespace();
  729. if (ch !== 116/*t*/ && !source.startsWith('rue', pos + 1)) break;
  730. pos += 4;
  731. ch = commentWhitespace();
  732. if (ch !== 44/*,*/) break;
  733. pos++;
  734. ch = commentWhitespace();
  735. if (ch !== 103/*g*/ || !source.startsWith('et', pos + 1)) break;
  736. pos += 3;
  737. ch = commentWhitespace();
  738. if (ch === 58/*:*/) {
  739. pos++;
  740. ch = commentWhitespace();
  741. if (ch !== 102/*f*/) break;
  742. if (!source.startsWith('unction', pos + 1)) break;
  743. pos += 8;
  744. let lastPos = pos;
  745. ch = commentWhitespace();
  746. if (ch !== 40 && (lastPos === pos || !identifier())) break;
  747. ch = commentWhitespace();
  748. }
  749. if (ch !== 40/*(*/) break;
  750. pos++;
  751. ch = commentWhitespace();
  752. if (ch !== 41/*)*/) break;
  753. pos++;
  754. ch = commentWhitespace();
  755. if (ch !== 123/*{*/) break;
  756. pos++;
  757. ch = commentWhitespace();
  758. if (ch !== 114/*r*/ || !source.startsWith('eturn', pos + 1)) break;
  759. pos += 6;
  760. ch = commentWhitespace();
  761. if (!source.startsWith(id, pos)) break;
  762. pos += id.length;
  763. ch = commentWhitespace();
  764. if (ch !== 91/*[*/) break;
  765. pos++;
  766. ch = commentWhitespace();
  767. if (!source.startsWith(it_id, pos)) break;
  768. pos += it_id.length;
  769. ch = commentWhitespace();
  770. if (ch !== 93/*]*/) break;
  771. pos++;
  772. ch = commentWhitespace();
  773. if (ch === 59/*;*/) {
  774. pos++;
  775. ch = commentWhitespace();
  776. }
  777. if (ch !== 125/*}*/) break;
  778. pos++;
  779. ch = commentWhitespace();
  780. if (ch === 44/*,*/) {
  781. pos++;
  782. ch = commentWhitespace();
  783. }
  784. if (ch !== 125/*}*/) break;
  785. pos++;
  786. ch = commentWhitespace();
  787. if (ch !== 41/*)*/) break;
  788. pos++;
  789. ch = commentWhitespace();
  790. if (ch === 59/*;*/) {
  791. pos++;
  792. ch = commentWhitespace();
  793. }
  794. }
  795. else break;
  796. if (ch !== 125/*}*/) break;
  797. pos++;
  798. ch = commentWhitespace();
  799. if (ch !== 41/*)*/) break;
  800. const starExportSpecifier = starExportMap[id];
  801. if (starExportSpecifier) {
  802. reexports.add(decode(starExportSpecifier));
  803. pos = revertPos;
  804. return;
  805. }
  806. return;
  807. }
  808. }
  809. }
  810. pos = revertPos;
  811. }
  812. function readExportsOrModuleDotExports (ch) {
  813. const revertPos = pos;
  814. if (ch === 109/*m*/ && source.startsWith('odule', pos + 1)) {
  815. pos += 6;
  816. ch = commentWhitespace();
  817. if (ch !== 46/*.*/) {
  818. pos = revertPos;
  819. return false;
  820. }
  821. pos++;
  822. ch = commentWhitespace();
  823. }
  824. if (ch === 101/*e*/ && source.startsWith('xports', pos + 1)) {
  825. pos += 7;
  826. return true;
  827. }
  828. else {
  829. pos = revertPos;
  830. return false;
  831. }
  832. }
  833. function tryParseModuleExportsDotAssign () {
  834. pos += 6;
  835. const revertPos = pos - 1;
  836. let ch = commentWhitespace();
  837. if (ch === 46/*.*/) {
  838. pos++;
  839. ch = commentWhitespace();
  840. if (ch === 101/*e*/ && source.startsWith('xports', pos + 1)) {
  841. tryParseExportsDotAssign(true);
  842. return;
  843. }
  844. }
  845. pos = revertPos;
  846. }
  847. function tryParseExportsDotAssign (assign) {
  848. pos += 7;
  849. const revertPos = pos - 1;
  850. let ch = commentWhitespace();
  851. switch (ch) {
  852. // exports.asdf
  853. case 46/*.*/: {
  854. pos++;
  855. ch = commentWhitespace();
  856. const startPos = pos;
  857. if (identifier()) {
  858. const endPos = pos;
  859. ch = commentWhitespace();
  860. if (ch === 61/*=*/) {
  861. _exports.add(decode(source.slice(startPos, endPos)));
  862. return;
  863. }
  864. }
  865. break;
  866. }
  867. // exports['asdf']
  868. case 91/*[*/: {
  869. pos++;
  870. ch = commentWhitespace();
  871. if (ch === 39/*'*/ || ch === 34/*"*/) {
  872. const startPos = pos;
  873. stringLiteral(ch);
  874. const endPos = ++pos;
  875. ch = commentWhitespace();
  876. if (ch !== 93/*]*/) break;
  877. pos++;
  878. ch = commentWhitespace();
  879. if (ch !== 61/*=*/) break;
  880. _exports.add(decode(source.slice(startPos, endPos)));
  881. }
  882. break;
  883. }
  884. // module.exports =
  885. case 61/*=*/: {
  886. if (assign) {
  887. if (reexports.size)
  888. reexports = new Set();
  889. pos++;
  890. ch = commentWhitespace();
  891. // { ... }
  892. if (ch === 123/*{*/) {
  893. tryParseLiteralExports();
  894. return;
  895. }
  896. // require('...')
  897. if (ch === 114/*r*/)
  898. tryParseRequire(ExportAssign);
  899. }
  900. }
  901. }
  902. pos = revertPos;
  903. }
  904. function tryParseRequire (requireType) {
  905. // require('...')
  906. const revertPos = pos;
  907. if (source.startsWith('equire', pos + 1)) {
  908. pos += 7;
  909. let ch = commentWhitespace();
  910. if (ch === 40/*(*/) {
  911. pos++;
  912. ch = commentWhitespace();
  913. const reexportStart = pos;
  914. if (ch === 39/*'*/ || ch === 34/*"*/) {
  915. stringLiteral(ch);
  916. const reexportEnd = ++pos;
  917. ch = commentWhitespace();
  918. if (ch === 41/*)*/) {
  919. switch (requireType) {
  920. case ExportAssign:
  921. reexports.add(decode(source.slice(reexportStart, reexportEnd)));
  922. return true;
  923. case ExportStar:
  924. reexports.add(decode(source.slice(reexportStart, reexportEnd)));
  925. return true;
  926. default:
  927. lastStarExportSpecifier = decode(source.slice(reexportStart, reexportEnd));
  928. return true;
  929. }
  930. }
  931. }
  932. }
  933. pos = revertPos;
  934. }
  935. return false;
  936. }
  937. function tryParseLiteralExports () {
  938. const revertPos = pos - 1;
  939. while (pos++ < end) {
  940. let ch = commentWhitespace();
  941. const startPos = pos;
  942. if (identifier()) {
  943. const endPos = pos;
  944. ch = commentWhitespace();
  945. if (ch === 58/*:*/) {
  946. pos++;
  947. ch = commentWhitespace();
  948. // nothing more complex than identifier expressions for now
  949. if (!identifier()) {
  950. pos = revertPos;
  951. return;
  952. }
  953. ch = source.charCodeAt(pos);
  954. }
  955. _exports.add(decode(source.slice(startPos, endPos)));
  956. }
  957. else if (ch === 46/*.*/ && source.startsWith('..', pos + 1)) {
  958. pos += 3;
  959. if (source.charCodeAt(pos) === 114/*r*/ && tryParseRequire(ExportAssign)) {
  960. pos++;
  961. }
  962. else if (!identifier()) {
  963. pos = revertPos;
  964. return;
  965. }
  966. ch = commentWhitespace();
  967. }
  968. else if (ch === 39/*'*/ || ch === 34/*"*/) {
  969. const startPos = pos;
  970. stringLiteral(ch);
  971. const endPos = ++pos;
  972. ch = commentWhitespace();
  973. if (ch === 58/*:*/) {
  974. pos++;
  975. ch = commentWhitespace();
  976. // nothing more complex than identifier expressions for now
  977. if (!identifier()) {
  978. pos = revertPos;
  979. return;
  980. }
  981. ch = source.charCodeAt(pos);
  982. _exports.add(decode(source.slice(startPos, endPos)));
  983. }
  984. }
  985. else {
  986. pos = revertPos;
  987. return;
  988. }
  989. if (ch === 125/*}*/)
  990. return;
  991. if (ch !== 44/*,*/) {
  992. pos = revertPos;
  993. return;
  994. }
  995. }
  996. }
  997. // --- Extracted from AcornJS ---
  998. //(https://github.com/acornjs/acorn/blob/master/acorn/src/identifier.js#L23
  999. //
  1000. // MIT License
  1001. // Copyright (C) 2012-2018 by various contributors (see AUTHORS)
  1002. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1003. // of this software and associated documentation files (the "Software"), to deal
  1004. // in the Software without restriction, including without limitation the rights
  1005. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1006. // copies of the Software, and to permit persons to whom the Software is
  1007. // furnished to do so, subject to the following conditions:
  1008. // The above copyright notice and this permission notice shall be included in
  1009. // all copies or substantial portions of the Software.
  1010. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1011. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1012. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1013. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1014. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1015. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1016. // THE SOFTWARE.
  1017. // ## Character categories
  1018. // Big ugly regular expressions that match characters in the
  1019. // whitespace, identifier, and identifier-start categories. These
  1020. // are only applied when a character is found to actually have a
  1021. // code point above 128.
  1022. // Generated by `bin/generate-identifier-regex.js`.
  1023. let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"
  1024. let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"
  1025. const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]")
  1026. const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]")
  1027. nonASCIIidentifierStartChars = nonASCIIidentifierChars = null
  1028. // These are a run-length and offset encoded representation of the
  1029. // >0xffff code points that are a valid part of identifiers. The
  1030. // offset starts at 0x10000, and each pair of numbers represents an
  1031. // offset to the next range, and then a size of the range. They were
  1032. // generated by bin/generate-identifier-regex.js
  1033. // eslint-disable-next-line comma-spacing
  1034. const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938]
  1035. // eslint-disable-next-line comma-spacing
  1036. const astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239]
  1037. // This has a complexity linear to the value of the code. The
  1038. // assumption is that looking up astral identifier characters is
  1039. // rare.
  1040. function isInAstralSet(code, set) {
  1041. let pos = 0x10000
  1042. for (let i = 0; i < set.length; i += 2) {
  1043. pos += set[i]
  1044. if (pos > code) return false
  1045. pos += set[i + 1]
  1046. if (pos >= code) return true
  1047. }
  1048. }
  1049. // Test whether a given character code starts an identifier.
  1050. function isIdentifierStart(code, astral) {
  1051. if (code < 65) return code === 36
  1052. if (code < 91) return true
  1053. if (code < 97) return code === 95
  1054. if (code < 123) return true
  1055. if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))
  1056. if (astral === false) return false
  1057. return isInAstralSet(code, astralIdentifierStartCodes)
  1058. }
  1059. // Test whether a given character is part of an identifier.
  1060. function isIdentifierChar(code, astral) {
  1061. if (code < 48) return code === 36
  1062. if (code < 58) return true
  1063. if (code < 65) return false
  1064. if (code < 91) return true
  1065. if (code < 97) return code === 95
  1066. if (code < 123) return true
  1067. if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code))
  1068. if (astral === false) return false
  1069. return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
  1070. }
  1071. function identifier () {
  1072. let ch = source.codePointAt(pos);
  1073. if (!isIdentifierStart(ch, true) || ch === '\\')
  1074. return false;
  1075. pos += codePointLen(ch);
  1076. while (ch = source.codePointAt(pos)) {
  1077. if (isIdentifierChar(ch, true)) {
  1078. pos += codePointLen(ch);
  1079. }
  1080. else if (ch === '\\') {
  1081. // no identifier escapes support for now
  1082. return false;
  1083. }
  1084. else {
  1085. break;
  1086. }
  1087. }
  1088. return true;
  1089. }
  1090. function codePointLen (ch) {
  1091. if (ch < 0x10000) return 1;
  1092. return 2;
  1093. }
  1094. function codePointAtLast (bPos) {
  1095. // Gives the UTF char for backtracking surrogates
  1096. const ch = source.charCodeAt(bPos);
  1097. if ((ch & 0xFC00) === 0xDC00)
  1098. return (((source.charCodeAt(bPos - 1) & 0x3FF) << 10) | (ch & 0x3FF)) + 0x10000;
  1099. return ch;
  1100. }
  1101. function throwIfImportStatement () {
  1102. const startPos = pos;
  1103. pos += 6;
  1104. const ch = commentWhitespace();
  1105. switch (ch) {
  1106. // dynamic import
  1107. case 40/*(*/:
  1108. openTokenPosStack[openTokenDepth++] = startPos;
  1109. return;
  1110. // import.meta
  1111. case 46/*.*/:
  1112. throw new Error('Unexpected import.meta in CJS module.');
  1113. default:
  1114. // no space after "import" -> not an import keyword
  1115. if (pos === startPos + 6)
  1116. break;
  1117. case 34/*"*/:
  1118. case 39/*'*/:
  1119. case 123/*{*/:
  1120. case 42/***/:
  1121. // import statement only permitted at base-level
  1122. if (openTokenDepth !== 0) {
  1123. pos--;
  1124. return;
  1125. }
  1126. // import statements are a syntax error in CommonJS
  1127. throw new Error('Unexpected import statement in CJS module.');
  1128. }
  1129. }
  1130. function throwIfExportStatement () {
  1131. pos += 6;
  1132. const curPos = pos;
  1133. const ch = commentWhitespace();
  1134. if (pos === curPos && !isPunctuator(ch))
  1135. return;
  1136. throw new Error('Unexpected export statement in CJS module.');
  1137. }
  1138. function commentWhitespace () {
  1139. let ch;
  1140. do {
  1141. ch = source.charCodeAt(pos);
  1142. if (ch === 47/*/*/) {
  1143. const next_ch = source.charCodeAt(pos + 1);
  1144. if (next_ch === 47/*/*/)
  1145. lineComment();
  1146. else if (next_ch === 42/***/)
  1147. blockComment();
  1148. else
  1149. return ch;
  1150. }
  1151. else if (!isBrOrWs(ch)) {
  1152. return ch;
  1153. }
  1154. } while (pos++ < end);
  1155. return ch;
  1156. }
  1157. function templateString () {
  1158. while (pos++ < end) {
  1159. const ch = source.charCodeAt(pos);
  1160. if (ch === 36/*$*/ && source.charCodeAt(pos + 1) === 123/*{*/) {
  1161. pos++;
  1162. templateStack[templateStackDepth++] = templateDepth;
  1163. templateDepth = ++openTokenDepth;
  1164. return;
  1165. }
  1166. if (ch === 96/*`*/)
  1167. return;
  1168. if (ch === 92/*\*/)
  1169. pos++;
  1170. }
  1171. syntaxError();
  1172. }
  1173. function blockComment () {
  1174. pos++;
  1175. while (pos++ < end) {
  1176. const ch = source.charCodeAt(pos);
  1177. if (ch === 42/***/ && source.charCodeAt(pos + 1) === 47/*/*/) {
  1178. pos++;
  1179. return;
  1180. }
  1181. }
  1182. }
  1183. function lineComment () {
  1184. while (pos++ < end) {
  1185. const ch = source.charCodeAt(pos);
  1186. if (ch === 10/*\n*/ || ch === 13/*\r*/)
  1187. return;
  1188. }
  1189. }
  1190. function stringLiteral (quote) {
  1191. while (pos++ < end) {
  1192. let ch = source.charCodeAt(pos);
  1193. if (ch === quote)
  1194. return;
  1195. if (ch === 92/*\*/) {
  1196. ch = source.charCodeAt(++pos);
  1197. if (ch === 13/*\r*/ && source.charCodeAt(pos + 1) === 10/*\n*/)
  1198. pos++;
  1199. }
  1200. else if (isBr(ch))
  1201. break;
  1202. }
  1203. throw new Error('Unterminated string.');
  1204. }
  1205. function regexCharacterClass () {
  1206. while (pos++ < end) {
  1207. let ch = source.charCodeAt(pos);
  1208. if (ch === 93/*]*/)
  1209. return ch;
  1210. if (ch === 92/*\*/)
  1211. pos++;
  1212. else if (ch === 10/*\n*/ || ch === 13/*\r*/)
  1213. break;
  1214. }
  1215. throw new Error('Syntax error reading regular expression class.');
  1216. }
  1217. function regularExpression () {
  1218. while (pos++ < end) {
  1219. let ch = source.charCodeAt(pos);
  1220. if (ch === 47/*/*/)
  1221. return;
  1222. if (ch === 91/*[*/)
  1223. ch = regexCharacterClass();
  1224. else if (ch === 92/*\*/)
  1225. pos++;
  1226. else if (ch === 10/*\n*/ || ch === 13/*\r*/)
  1227. break;
  1228. }
  1229. throw new Error('Syntax error reading regular expression.');
  1230. }
  1231. // Note: non-asii BR and whitespace checks omitted for perf / footprint
  1232. // if there is a significant user need this can be reconsidered
  1233. function isBr (c) {
  1234. return c === 13/*\r*/ || c === 10/*\n*/;
  1235. }
  1236. function isBrOrWs (c) {
  1237. return c > 8 && c < 14 || c === 32 || c === 160;
  1238. }
  1239. function isBrOrWsOrPunctuatorNotDot (c) {
  1240. return c > 8 && c < 14 || c === 32 || c === 160 || isPunctuator(c) && c !== 46/*.*/;
  1241. }
  1242. function keywordStart (pos) {
  1243. return pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1));
  1244. }
  1245. function readPrecedingKeyword (pos, match) {
  1246. if (pos < match.length - 1)
  1247. return false;
  1248. return source.startsWith(match, pos - match.length + 1) && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - match.length)));
  1249. }
  1250. function readPrecedingKeyword1 (pos, ch) {
  1251. return source.charCodeAt(pos) === ch && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1)));
  1252. }
  1253. // Detects one of case, debugger, delete, do, else, in, instanceof, new,
  1254. // return, throw, typeof, void, yield, await
  1255. function isExpressionKeyword (pos) {
  1256. switch (source.charCodeAt(pos)) {
  1257. case 100/*d*/:
  1258. switch (source.charCodeAt(pos - 1)) {
  1259. case 105/*i*/:
  1260. // void
  1261. return readPrecedingKeyword(pos - 2, 'vo');
  1262. case 108/*l*/:
  1263. // yield
  1264. return readPrecedingKeyword(pos - 2, 'yie');
  1265. default:
  1266. return false;
  1267. }
  1268. case 101/*e*/:
  1269. switch (source.charCodeAt(pos - 1)) {
  1270. case 115/*s*/:
  1271. switch (source.charCodeAt(pos - 2)) {
  1272. case 108/*l*/:
  1273. // else
  1274. return readPrecedingKeyword1(pos - 3, 101/*e*/);
  1275. case 97/*a*/:
  1276. // case
  1277. return readPrecedingKeyword1(pos - 3, 99/*c*/);
  1278. default:
  1279. return false;
  1280. }
  1281. case 116/*t*/:
  1282. // delete
  1283. return readPrecedingKeyword(pos - 2, 'dele');
  1284. default:
  1285. return false;
  1286. }
  1287. case 102/*f*/:
  1288. if (source.charCodeAt(pos - 1) !== 111/*o*/ || source.charCodeAt(pos - 2) !== 101/*e*/)
  1289. return false;
  1290. switch (source.charCodeAt(pos - 3)) {
  1291. case 99/*c*/:
  1292. // instanceof
  1293. return readPrecedingKeyword(pos - 4, 'instan');
  1294. case 112/*p*/:
  1295. // typeof
  1296. return readPrecedingKeyword(pos - 4, 'ty');
  1297. default:
  1298. return false;
  1299. }
  1300. case 110/*n*/:
  1301. // in, return
  1302. return readPrecedingKeyword1(pos - 1, 105/*i*/) || readPrecedingKeyword(pos - 1, 'retur');
  1303. case 111/*o*/:
  1304. // do
  1305. return readPrecedingKeyword1(pos - 1, 100/*d*/);
  1306. case 114/*r*/:
  1307. // debugger
  1308. return readPrecedingKeyword(pos - 1, 'debugge');
  1309. case 116/*t*/:
  1310. // await
  1311. return readPrecedingKeyword(pos - 1, 'awai');
  1312. case 119/*w*/:
  1313. switch (source.charCodeAt(pos - 1)) {
  1314. case 101/*e*/:
  1315. // new
  1316. return readPrecedingKeyword1(pos - 2, 110/*n*/);
  1317. case 111/*o*/:
  1318. // throw
  1319. return readPrecedingKeyword(pos - 2, 'thr');
  1320. default:
  1321. return false;
  1322. }
  1323. }
  1324. return false;
  1325. }
  1326. function isParenKeyword (curPos) {
  1327. return source.charCodeAt(curPos) === 101/*e*/ && source.startsWith('whil', curPos - 4) ||
  1328. source.charCodeAt(curPos) === 114/*r*/ && source.startsWith('fo', curPos - 2) ||
  1329. source.charCodeAt(curPos - 1) === 105/*i*/ && source.charCodeAt(curPos) === 102/*f*/;
  1330. }
  1331. function isPunctuator (ch) {
  1332. // 23 possible punctuator endings: !%&()*+,-./:;<=>?[]^{}|~
  1333. return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ ||
  1334. ch > 39 && ch < 48 || ch > 57 && ch < 64 ||
  1335. ch === 91/*[*/ || ch === 93/*]*/ || ch === 94/*^*/ ||
  1336. ch > 122 && ch < 127;
  1337. }
  1338. function isExpressionPunctuator (ch) {
  1339. // 20 possible expression endings: !%&(*+,-.:;<=>?[^{|~
  1340. return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ ||
  1341. ch > 39 && ch < 47 && ch !== 41 || ch > 57 && ch < 64 ||
  1342. ch === 91/*[*/ || ch === 94/*^*/ || ch > 122 && ch < 127 && ch !== 125/*}*/;
  1343. }
  1344. function isExpressionTerminator (curPos) {
  1345. // detects:
  1346. // => ; ) finally catch else
  1347. // as all of these followed by a { will indicate a statement brace
  1348. switch (source.charCodeAt(curPos)) {
  1349. case 62/*>*/:
  1350. return source.charCodeAt(curPos - 1) === 61/*=*/;
  1351. case 59/*;*/:
  1352. case 41/*)*/:
  1353. return true;
  1354. case 104/*h*/:
  1355. return source.startsWith('catc', curPos - 4);
  1356. case 121/*y*/:
  1357. return source.startsWith('finall', curPos - 6);
  1358. case 101/*e*/:
  1359. return source.startsWith('els', curPos - 3);
  1360. }
  1361. return false;
  1362. }
  1363. const initPromise = Promise.resolve();
  1364. module.exports.init = () => initPromise;
  1365. module.exports.parse = parseCJS;