semantic_attr.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. "use strict";
  2. var __rest = (this && this.__rest) || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5. t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  7. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  8. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  9. t[p[i]] = s[p[i]];
  10. }
  11. return t;
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.SemanticMap = exports.NamedSymbol = void 0;
  15. exports.addFunctionSemantic = addFunctionSemantic;
  16. exports.equal = equal;
  17. exports.isMatchingFence = isMatchingFence;
  18. const semantic_meaning_js_1 = require("./semantic_meaning.js");
  19. const Alphabet = require("../speech_rules/alphabet.js");
  20. exports.NamedSymbol = {
  21. functionApplication: String.fromCodePoint(0x2061),
  22. invisibleTimes: String.fromCodePoint(0x2062),
  23. invisibleComma: String.fromCodePoint(0x2063),
  24. invisiblePlus: String.fromCodePoint(0x2064)
  25. };
  26. class meaningMap extends Map {
  27. get(symbol) {
  28. return (super.get(symbol) || {
  29. role: semantic_meaning_js_1.SemanticRole.UNKNOWN,
  30. type: semantic_meaning_js_1.SemanticType.UNKNOWN,
  31. font: semantic_meaning_js_1.SemanticFont.UNKNOWN
  32. });
  33. }
  34. }
  35. class secondaryMap extends Map {
  36. set(char, kind, annotation = '') {
  37. super.set(this.secKey(kind, char), annotation || kind);
  38. return this;
  39. }
  40. has(char, kind) {
  41. return super.has(this.secKey(kind, char));
  42. }
  43. get(char, kind) {
  44. return super.get(this.secKey(kind, char));
  45. }
  46. secKey(kind, char) {
  47. return char ? `${kind} ${char}` : `${kind}`;
  48. }
  49. }
  50. exports.SemanticMap = {
  51. Meaning: new meaningMap(),
  52. Secondary: new secondaryMap(),
  53. FencesHoriz: new Map(),
  54. FencesVert: new Map(),
  55. LatexCommands: new Map()
  56. };
  57. function addMeaning(symbols, meaning) {
  58. for (const symbol of symbols) {
  59. exports.SemanticMap.Meaning.set(symbol, {
  60. role: meaning.role || semantic_meaning_js_1.SemanticRole.UNKNOWN,
  61. type: meaning.type || semantic_meaning_js_1.SemanticType.UNKNOWN,
  62. font: meaning.font || semantic_meaning_js_1.SemanticFont.UNKNOWN
  63. });
  64. if (meaning.secondary) {
  65. exports.SemanticMap.Secondary.set(symbol, meaning.secondary);
  66. }
  67. }
  68. }
  69. function initMeaning() {
  70. const sets = [
  71. {
  72. set: [
  73. '23',
  74. '26',
  75. '40',
  76. '5c',
  77. 'a1',
  78. 'a7',
  79. 'b6',
  80. 'bf',
  81. '2017',
  82. ['2022', '2025'],
  83. '2027',
  84. '203b',
  85. '203c',
  86. ['2041', '2043'],
  87. ['2047', '2049'],
  88. ['204b', '204d'],
  89. '2050',
  90. '2055',
  91. '2056',
  92. ['2058', '205e'],
  93. '2234',
  94. '2235',
  95. 'fe45',
  96. 'fe46',
  97. 'fe5f',
  98. 'fe60',
  99. 'fe68',
  100. 'fe6b',
  101. 'ff03',
  102. 'ff06',
  103. 'ff0f',
  104. 'ff20',
  105. 'ff3c'
  106. ],
  107. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  108. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  109. },
  110. {
  111. set: [
  112. '22',
  113. 'ab',
  114. 'bb',
  115. '2dd',
  116. ['2018', '201f'],
  117. '2039',
  118. '203a',
  119. ['301d', '301f'],
  120. 'fe10',
  121. 'ff02',
  122. 'ff07'
  123. ],
  124. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  125. role: semantic_meaning_js_1.SemanticRole.QUOTES
  126. },
  127. {
  128. set: ['3b', '204f', '2a1f', '2a3e', 'fe14', 'fe54', 'ff1b'],
  129. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  130. role: semantic_meaning_js_1.SemanticRole.SEMICOLON
  131. },
  132. {
  133. set: ['3f', '203d', 'fe16', 'fe56', 'ff1f'],
  134. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  135. role: semantic_meaning_js_1.SemanticRole.QUESTION
  136. },
  137. {
  138. set: ['21', 'fe15', 'fe57', 'ff01'],
  139. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  140. role: semantic_meaning_js_1.SemanticRole.EXCLAMATION
  141. },
  142. {
  143. set: [
  144. '5e',
  145. '60',
  146. 'a8',
  147. 'aa',
  148. 'b4',
  149. 'ba',
  150. '2c7',
  151. ['2d8', '2da'],
  152. '2040',
  153. '207a',
  154. '207d',
  155. '207e',
  156. 'ff3e',
  157. 'ff40'
  158. ],
  159. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  160. role: semantic_meaning_js_1.SemanticRole.OVERACCENT
  161. },
  162. {
  163. set: ['b8', '2db', '2038', '203f', '2054', '208a', '208d', '208e'],
  164. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  165. role: semantic_meaning_js_1.SemanticRole.UNDERACCENT
  166. },
  167. {
  168. set: ['3a', '2982', 'fe13', 'fe30', 'fe55', 'ff1a'],
  169. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  170. role: semantic_meaning_js_1.SemanticRole.COLON
  171. },
  172. {
  173. set: ['2c', '2063', 'fe50', 'ff0c'],
  174. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  175. role: semantic_meaning_js_1.SemanticRole.COMMA
  176. },
  177. {
  178. set: ['2026', ['22ee', '22f1'], 'fe19'],
  179. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  180. role: semantic_meaning_js_1.SemanticRole.ELLIPSIS
  181. },
  182. {
  183. set: ['2e', 'fe52', 'ff0e'],
  184. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  185. role: semantic_meaning_js_1.SemanticRole.FULLSTOP
  186. },
  187. {
  188. set: ['2d', '207b', '208b', '2212', '2796', 'fe63', 'ff0d'],
  189. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  190. role: semantic_meaning_js_1.SemanticRole.DASH,
  191. secondary: semantic_meaning_js_1.SemanticSecondary.BAR
  192. },
  193. {
  194. set: [
  195. '5f',
  196. 'af',
  197. ['2010', '2015'],
  198. '203e',
  199. '208b',
  200. ['fe49', 'fe4f'],
  201. 'fe58',
  202. 'ff3f',
  203. 'ffe3'
  204. ],
  205. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  206. role: semantic_meaning_js_1.SemanticRole.DASH,
  207. secondary: semantic_meaning_js_1.SemanticSecondary.BAR
  208. },
  209. {
  210. set: [
  211. '7e',
  212. '2dc',
  213. '2f7',
  214. '303',
  215. '330',
  216. '334',
  217. '2053',
  218. '223c',
  219. '223d',
  220. '301c',
  221. 'ff5e'
  222. ],
  223. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  224. role: semantic_meaning_js_1.SemanticRole.TILDE,
  225. secondary: semantic_meaning_js_1.SemanticSecondary.TILDE
  226. },
  227. {
  228. set: ['27', '2b9', '2ba', ['2032', '2037'], '2057'],
  229. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  230. role: semantic_meaning_js_1.SemanticRole.PRIME
  231. },
  232. {
  233. set: ['b0'],
  234. type: semantic_meaning_js_1.SemanticType.PUNCTUATION,
  235. role: semantic_meaning_js_1.SemanticRole.DEGREE
  236. },
  237. {
  238. set: [
  239. '2b',
  240. 'b1',
  241. '2064',
  242. '2213',
  243. '2214',
  244. '2228',
  245. '222a',
  246. ['228c', '228e'],
  247. '2294',
  248. '2295',
  249. '229d',
  250. '229e',
  251. '22bb',
  252. '22bd',
  253. '22c4',
  254. '22ce',
  255. '22d3',
  256. '2304',
  257. '271b',
  258. '271c',
  259. '2795',
  260. '27cf',
  261. '29fa',
  262. '29fb',
  263. '29fe',
  264. ['2a22', '2a28'],
  265. '2a2d',
  266. '2a2e',
  267. '2a39',
  268. '2a42',
  269. '2a45',
  270. '2a46',
  271. '2a48',
  272. '2a4a',
  273. '2a4c',
  274. '2a4f',
  275. '2a50',
  276. '2a52',
  277. '2a54',
  278. '2a56',
  279. '2a57',
  280. '2a59',
  281. '2a5b',
  282. '2a5d',
  283. ['2a61', '2a63'],
  284. '2adc',
  285. '2add',
  286. 'fe62',
  287. 'ff0b'
  288. ],
  289. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  290. role: semantic_meaning_js_1.SemanticRole.ADDITION
  291. },
  292. {
  293. set: [
  294. '2a',
  295. 'b7',
  296. 'd7',
  297. '2020',
  298. '2021',
  299. '204e',
  300. '2051',
  301. '2062',
  302. ['2217', '2219'],
  303. '2227',
  304. '2229',
  305. '2240',
  306. '2293',
  307. '2297',
  308. ['2299', '229b'],
  309. '22a0',
  310. '22a1',
  311. '22b9',
  312. '22bc',
  313. ['22c5', '22cc'],
  314. '22cf',
  315. '22d2',
  316. '22d4',
  317. '2303',
  318. '2305',
  319. '2306',
  320. '25cb',
  321. '2715',
  322. '2716',
  323. '27ce',
  324. '27d1',
  325. ['29d1', '29d7'],
  326. '29e2',
  327. '2a1d',
  328. ['2a2f', '2a37'],
  329. ['2a3b', '2a3d'],
  330. '2a40',
  331. '2a43',
  332. '2a44',
  333. '2a47',
  334. '2a49',
  335. '2a4b',
  336. '2a4d',
  337. '2a4e',
  338. '2a51',
  339. '2a53',
  340. '2a55',
  341. '2a58',
  342. '2a5a',
  343. '2a5c',
  344. ['2a5e', '2a60'],
  345. '2ada',
  346. '2adb',
  347. 'fe61',
  348. 'ff0a'
  349. ],
  350. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  351. role: semantic_meaning_js_1.SemanticRole.MULTIPLICATION
  352. },
  353. {
  354. set: [
  355. '2d',
  356. 'af',
  357. '2010',
  358. '2011',
  359. '2052',
  360. '207b',
  361. '208b',
  362. '2212',
  363. '2216',
  364. '2238',
  365. '2242',
  366. '2296',
  367. '229f',
  368. '2796',
  369. '29ff',
  370. ['2a29', '2a2c'],
  371. '2a3a',
  372. '2a41',
  373. 'fe63',
  374. 'ff0d'
  375. ],
  376. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  377. role: semantic_meaning_js_1.SemanticRole.SUBTRACTION
  378. },
  379. {
  380. set: [
  381. '2f',
  382. 'f7',
  383. '2044',
  384. '2215',
  385. '2298',
  386. '2797',
  387. '27cc',
  388. '29bc',
  389. ['29f5', '29f9'],
  390. '2a38'
  391. ],
  392. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  393. role: semantic_meaning_js_1.SemanticRole.DIVISION
  394. },
  395. {
  396. set: ['25', '2030', '2031', 'ff05', 'fe6a'],
  397. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  398. role: semantic_meaning_js_1.SemanticRole.POSTFIXOP
  399. },
  400. {
  401. set: [
  402. 'ac',
  403. '2200',
  404. '2201',
  405. '2203',
  406. '2204',
  407. '2206',
  408. ['221a', '221c'],
  409. '2310',
  410. 'ffe2'
  411. ],
  412. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  413. role: semantic_meaning_js_1.SemanticRole.PREFIXOP
  414. },
  415. {
  416. set: [
  417. '2320',
  418. '2321',
  419. '23aa',
  420. '23ae',
  421. '23af',
  422. '23b2',
  423. '23b3',
  424. '23b6',
  425. '23b7'
  426. ],
  427. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  428. role: semantic_meaning_js_1.SemanticRole.PREFIXOP
  429. },
  430. {
  431. set: ['1d7ca', '1d7cb'],
  432. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  433. role: semantic_meaning_js_1.SemanticRole.PREFIXOP,
  434. font: semantic_meaning_js_1.SemanticFont.BOLD
  435. },
  436. {
  437. set: [
  438. '3d',
  439. '7e',
  440. '207c',
  441. '208c',
  442. '221d',
  443. '2237',
  444. ['223a', '223f'],
  445. '2243',
  446. '2245',
  447. '2248',
  448. ['224a', '224e'],
  449. ['2251', '225f'],
  450. '2261',
  451. '2263',
  452. '229c',
  453. '22cd',
  454. '22d5',
  455. '29e4',
  456. '29e6',
  457. '2a66',
  458. '2a67',
  459. ['2a6a', '2a6c'],
  460. ['2a6c', '2a78'],
  461. 'fe66',
  462. 'ff1d'
  463. ],
  464. type: semantic_meaning_js_1.SemanticType.RELATION,
  465. role: semantic_meaning_js_1.SemanticRole.EQUALITY
  466. },
  467. {
  468. set: [
  469. '3c',
  470. '3e',
  471. '2241',
  472. '2242',
  473. '2244',
  474. '2246',
  475. '2247',
  476. '2249',
  477. '224f',
  478. '2250',
  479. '2260',
  480. '2262',
  481. ['2264', '2281'],
  482. '22b0',
  483. '22b1',
  484. ['22d6', '22e1'],
  485. ['22e6', '22e9'],
  486. ['2976', '2978'],
  487. '29c0',
  488. '29c1',
  489. '29e1',
  490. '29e3',
  491. '29e5',
  492. ['2a79', '2abc'],
  493. ['2af7', '2afa'],
  494. 'fe64',
  495. 'fe65',
  496. 'ff1c',
  497. 'ff1e'
  498. ],
  499. type: semantic_meaning_js_1.SemanticType.RELATION,
  500. role: semantic_meaning_js_1.SemanticRole.INEQUALITY
  501. },
  502. {
  503. set: [
  504. ['2282', '228b'],
  505. ['228f', '2292'],
  506. ['22b2', '22b8'],
  507. '22d0',
  508. '22d1',
  509. ['22e2', '22e5'],
  510. ['22ea', '22ed'],
  511. '27c3',
  512. '27c4',
  513. ['27c7', '27c9'],
  514. ['27d5', '27d7'],
  515. '27dc',
  516. ['2979', '297b'],
  517. '29df',
  518. ['2abd', '2ad8']
  519. ],
  520. type: semantic_meaning_js_1.SemanticType.RELATION,
  521. role: semantic_meaning_js_1.SemanticRole.SET
  522. },
  523. {
  524. set: [
  525. '2236',
  526. ['27e0', '27e5'],
  527. '292b',
  528. '292c',
  529. ['29b5', '29bb'],
  530. '29be',
  531. '29bf',
  532. ['29c2', '29d0']
  533. ],
  534. type: semantic_meaning_js_1.SemanticType.RELATION,
  535. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  536. },
  537. {
  538. set: ['2205', ['29b0', '29b4']],
  539. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  540. role: semantic_meaning_js_1.SemanticRole.SETEMPTY
  541. },
  542. {
  543. set: ['1ab2', '221e', ['29dc', '29de']],
  544. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  545. role: semantic_meaning_js_1.SemanticRole.INFTY
  546. },
  547. {
  548. set: [
  549. '22a2',
  550. '22a3',
  551. ['22a6', '22af'],
  552. '27da',
  553. '27db',
  554. '27dd',
  555. '27de',
  556. '2ade',
  557. ['2ae2', '2ae6'],
  558. '2aec',
  559. '2aed'
  560. ],
  561. type: semantic_meaning_js_1.SemanticType.RELATION,
  562. role: semantic_meaning_js_1.SemanticRole.LOGIC
  563. },
  564. {
  565. set: [
  566. '22a4',
  567. '22a5',
  568. '22ba',
  569. '27d8',
  570. '27d9',
  571. '27df',
  572. '2adf',
  573. '2ae0',
  574. ['2ae7', '2aeb'],
  575. '2af1'
  576. ],
  577. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  578. role: semantic_meaning_js_1.SemanticRole.LOGIC
  579. },
  580. {
  581. set: [
  582. ['2190', '21ff'],
  583. '2301',
  584. '2324',
  585. '238b',
  586. '2794',
  587. ['2798', '27af'],
  588. ['27b1', '27be'],
  589. ['27f0', '27ff'],
  590. ['2900', '292a'],
  591. ['292d', '2975'],
  592. ['297c', '297f'],
  593. ['2b00', '2b11'],
  594. ['2b30', '2b4c'],
  595. ['ffe9', 'ffec']
  596. ],
  597. type: semantic_meaning_js_1.SemanticType.RELATION,
  598. role: semantic_meaning_js_1.SemanticRole.ARROW
  599. },
  600. {
  601. set: ['2208', '220a', ['22f2', '22f9'], '22ff', '27d2', '2ad9'],
  602. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  603. role: semantic_meaning_js_1.SemanticRole.ELEMENT
  604. },
  605. {
  606. set: ['2209'],
  607. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  608. role: semantic_meaning_js_1.SemanticRole.NONELEMENT
  609. },
  610. {
  611. set: ['220b', '220d', ['22fa', '22fe']],
  612. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  613. role: semantic_meaning_js_1.SemanticRole.REELEMENT
  614. },
  615. {
  616. set: ['220c'],
  617. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  618. role: semantic_meaning_js_1.SemanticRole.RENONELEMENT
  619. },
  620. {
  621. set: [
  622. ['220f', '2211'],
  623. ['22c0', '22c3'],
  624. ['2a00', '2a0b'],
  625. '2a3f',
  626. '2afc',
  627. '2aff'
  628. ],
  629. type: semantic_meaning_js_1.SemanticType.LARGEOP,
  630. role: semantic_meaning_js_1.SemanticRole.SUM
  631. },
  632. {
  633. set: ['2140'],
  634. type: semantic_meaning_js_1.SemanticType.LARGEOP,
  635. role: semantic_meaning_js_1.SemanticRole.SUM,
  636. font: semantic_meaning_js_1.SemanticFont.DOUBLESTRUCK
  637. },
  638. {
  639. set: [
  640. ['222b', '2233'],
  641. ['2a0c', '2a17'],
  642. ['2a17', '2a1c']
  643. ],
  644. type: semantic_meaning_js_1.SemanticType.LARGEOP,
  645. role: semantic_meaning_js_1.SemanticRole.INTEGRAL
  646. },
  647. {
  648. set: [['2500', '257F']],
  649. type: semantic_meaning_js_1.SemanticType.RELATION,
  650. role: semantic_meaning_js_1.SemanticRole.BOX
  651. },
  652. {
  653. set: [['2580', '259F']],
  654. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  655. role: semantic_meaning_js_1.SemanticRole.BLOCK
  656. },
  657. {
  658. set: [
  659. ['25A0', '25FF'],
  660. ['2B12', '2B2F'],
  661. ['2B50', '2B59']
  662. ],
  663. type: semantic_meaning_js_1.SemanticType.RELATION,
  664. role: semantic_meaning_js_1.SemanticRole.GEOMETRY
  665. },
  666. {
  667. set: [
  668. '220e',
  669. '2300',
  670. '2302',
  671. '2311',
  672. '29bd',
  673. '29e0',
  674. ['29e8', '29f3'],
  675. '2a1e',
  676. '2afe',
  677. 'ffed',
  678. 'ffee'
  679. ],
  680. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  681. role: semantic_meaning_js_1.SemanticRole.GEOMETRY
  682. },
  683. {
  684. set: [
  685. ['221f', '2222'],
  686. '22be',
  687. '22bf',
  688. ['2312', '2314'],
  689. '237c',
  690. '27c0',
  691. ['299b', '29af']
  692. ],
  693. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  694. role: semantic_meaning_js_1.SemanticRole.GEOMETRY
  695. },
  696. {
  697. set: [
  698. '24',
  699. ['a2', 'a5'],
  700. 'b5',
  701. '2123',
  702. ['2125', '2127'],
  703. '212a',
  704. '212b',
  705. 'fe69',
  706. 'ff04',
  707. 'ffe0',
  708. 'ffe1',
  709. 'ffe5',
  710. 'ffe6'
  711. ],
  712. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  713. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  714. },
  715. {
  716. set: [
  717. 'a9',
  718. 'ae',
  719. '210f',
  720. '2114',
  721. '2116',
  722. '2117',
  723. ['211e', '2122'],
  724. '212e',
  725. '2132',
  726. ['2139', '213b'],
  727. ['2141', '2144'],
  728. '214d',
  729. '214e',
  730. ['1f12a', '1f12c'],
  731. '1f18a'
  732. ],
  733. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  734. role: semantic_meaning_js_1.SemanticRole.OTHERLETTER
  735. },
  736. {
  737. set: [
  738. '2224',
  739. '2226',
  740. '2239',
  741. '2307',
  742. '27b0',
  743. '27bf',
  744. '27c1',
  745. '27c2',
  746. '27ca',
  747. '27cb',
  748. '27cd',
  749. '27d0',
  750. '27d3',
  751. '27d4',
  752. '2981',
  753. '2999',
  754. '299a',
  755. '29e7',
  756. '29f4',
  757. '2a20',
  758. '2a21',
  759. '2a64',
  760. '2a65',
  761. '2a68',
  762. '2a69',
  763. '2ae1',
  764. ['2aee', '2af0'],
  765. '2af2',
  766. '2af3',
  767. '2af5',
  768. '2af6',
  769. '2afb',
  770. '2afd'
  771. ],
  772. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  773. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  774. },
  775. {
  776. set: ['2605', '2606', '26aa', '26ab', ['2720', '274d']],
  777. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  778. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  779. },
  780. {
  781. set: [['2145', '2149']],
  782. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  783. role: semantic_meaning_js_1.SemanticRole.LATINLETTER,
  784. font: semantic_meaning_js_1.SemanticFont.DOUBLESTRUCKITALIC,
  785. secondary: semantic_meaning_js_1.SemanticSecondary.ALLLETTERS
  786. },
  787. {
  788. set: [['213c', '213f']],
  789. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  790. role: semantic_meaning_js_1.SemanticRole.GREEKLETTER,
  791. font: semantic_meaning_js_1.SemanticFont.DOUBLESTRUCK,
  792. secondary: semantic_meaning_js_1.SemanticSecondary.ALLLETTERS
  793. },
  794. {
  795. set: [
  796. '3d0',
  797. '3d7',
  798. '3f6',
  799. ['1d26', '1d2a'],
  800. '1d5e',
  801. '1d60',
  802. ['1d66', '1d6a']
  803. ],
  804. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  805. role: semantic_meaning_js_1.SemanticRole.GREEKLETTER,
  806. font: semantic_meaning_js_1.SemanticFont.NORMAL,
  807. secondary: semantic_meaning_js_1.SemanticSecondary.ALLLETTERS
  808. },
  809. {
  810. set: [['2135', '2138']],
  811. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  812. role: semantic_meaning_js_1.SemanticRole.OTHERLETTER,
  813. font: semantic_meaning_js_1.SemanticFont.NORMAL,
  814. secondary: semantic_meaning_js_1.SemanticSecondary.ALLLETTERS
  815. },
  816. {
  817. set: ['131', '237'],
  818. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  819. role: semantic_meaning_js_1.SemanticRole.LATINLETTER,
  820. font: semantic_meaning_js_1.SemanticFont.NORMAL
  821. },
  822. {
  823. set: ['1d6a4', '1d6a5'],
  824. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  825. role: semantic_meaning_js_1.SemanticRole.LATINLETTER,
  826. font: semantic_meaning_js_1.SemanticFont.ITALIC
  827. },
  828. {
  829. set: ['2113', '2118'],
  830. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  831. role: semantic_meaning_js_1.SemanticRole.LATINLETTER,
  832. font: semantic_meaning_js_1.SemanticFont.SCRIPT
  833. },
  834. {
  835. set: [
  836. ['c0', 'd6'],
  837. ['d8', 'f6'],
  838. ['f8', '1bf'],
  839. ['1c4', '2af'],
  840. ['1d00', '1d25'],
  841. ['1d6b', '1d9a'],
  842. ['1e00', '1ef9'],
  843. ['363', '36f'],
  844. ['1dd3', '1de6'],
  845. ['1d62', '1d65'],
  846. '1dca',
  847. '2071',
  848. '207f',
  849. ['2090', '209c'],
  850. '2c7c'
  851. ],
  852. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  853. role: semantic_meaning_js_1.SemanticRole.LATINLETTER,
  854. font: semantic_meaning_js_1.SemanticFont.NORMAL
  855. },
  856. {
  857. set: [['00bc', '00be'], ['2150', '215f'], '2189'],
  858. type: semantic_meaning_js_1.SemanticType.NUMBER,
  859. role: semantic_meaning_js_1.SemanticRole.FLOAT
  860. },
  861. {
  862. set: ['23E8', ['3248', '324f']],
  863. type: semantic_meaning_js_1.SemanticType.NUMBER,
  864. role: semantic_meaning_js_1.SemanticRole.INTEGER
  865. },
  866. {
  867. set: [['214A', '214C'], '2705', '2713', '2714', '2717', '2718'],
  868. type: semantic_meaning_js_1.SemanticType.IDENTIFIER,
  869. role: semantic_meaning_js_1.SemanticRole.UNKNOWN
  870. },
  871. {
  872. set: [
  873. '20',
  874. 'a0',
  875. 'ad',
  876. ['2000', '200f'],
  877. ['2028', '202f'],
  878. ['205f', '2060'],
  879. '206a',
  880. '206b',
  881. '206e',
  882. '206f',
  883. 'feff',
  884. ['fff9', 'fffb']
  885. ],
  886. type: semantic_meaning_js_1.SemanticType.TEXT,
  887. role: semantic_meaning_js_1.SemanticRole.SPACE
  888. },
  889. {
  890. set: [
  891. '7c',
  892. 'a6',
  893. '2223',
  894. '23b8',
  895. '23b9',
  896. '23d0',
  897. '2758',
  898. ['fe31', 'fe34'],
  899. 'ff5c',
  900. 'ffe4',
  901. 'ffe8'
  902. ],
  903. type: semantic_meaning_js_1.SemanticType.FENCE,
  904. role: semantic_meaning_js_1.SemanticRole.NEUTRAL
  905. },
  906. {
  907. set: ['2016', '2225', '2980', '2af4'],
  908. type: semantic_meaning_js_1.SemanticType.FENCE,
  909. role: semantic_meaning_js_1.SemanticRole.METRIC
  910. }
  911. ];
  912. sets.forEach((_a) => {
  913. var { set: s } = _a, m = __rest(_a, ["set"]);
  914. return addMeaning(Alphabet.makeMultiInterval(s), m);
  915. });
  916. }
  917. function addFences(map, ints, sep = 1) {
  918. const used = {};
  919. const codes = Alphabet.makeCodeInterval(ints);
  920. for (const code of codes) {
  921. if (used[code])
  922. continue;
  923. map.set(String.fromCodePoint(code), String.fromCodePoint(code + sep));
  924. used[code] = true;
  925. used[code + sep] = true;
  926. }
  927. }
  928. function initFences() {
  929. addFences(exports.SemanticMap.FencesVert, [
  930. '23b4',
  931. ['23dc', '23e1'],
  932. ['fe35', 'fe44'],
  933. 'fe47'
  934. ]);
  935. addFences(exports.SemanticMap.FencesHoriz, [
  936. '28',
  937. '2045',
  938. ['2308', '230f'],
  939. ['231c', '231f'],
  940. '2329',
  941. '23b0',
  942. ['2768', '2775'],
  943. '27c5',
  944. ['27e6', '27ef'],
  945. ['2983', '2998'],
  946. ['29d8', '29db'],
  947. '29fc',
  948. ['2e22', '2e29'],
  949. ['3008', '3011'],
  950. ['3014', '301b'],
  951. 'fd3e',
  952. 'fe17',
  953. ['fe59', 'fe5e'],
  954. 'ff08',
  955. 'ff5f',
  956. 'ff62'
  957. ]);
  958. addFences(exports.SemanticMap.FencesHoriz, ['5b', '7b', 'ff3b', 'ff5b'], 2);
  959. addFences(exports.SemanticMap.FencesHoriz, [['239b', '23a6']], 3);
  960. addFences(exports.SemanticMap.FencesHoriz, [['23a7', '23a9']], 4);
  961. addMeaning([...exports.SemanticMap.FencesHoriz.keys()], {
  962. type: semantic_meaning_js_1.SemanticType.FENCE,
  963. role: semantic_meaning_js_1.SemanticRole.OPEN
  964. });
  965. addMeaning([...exports.SemanticMap.FencesHoriz.values()], {
  966. type: semantic_meaning_js_1.SemanticType.FENCE,
  967. role: semantic_meaning_js_1.SemanticRole.CLOSE
  968. });
  969. addMeaning([...exports.SemanticMap.FencesVert.keys()], {
  970. type: semantic_meaning_js_1.SemanticType.FENCE,
  971. role: semantic_meaning_js_1.SemanticRole.TOP
  972. });
  973. addMeaning([...exports.SemanticMap.FencesVert.values()], {
  974. type: semantic_meaning_js_1.SemanticType.FENCE,
  975. role: semantic_meaning_js_1.SemanticRole.BOTTOM
  976. });
  977. }
  978. const trigonometricFunctions = [
  979. 'cos',
  980. 'cot',
  981. 'csc',
  982. 'sec',
  983. 'sin',
  984. 'tan',
  985. 'arccos',
  986. 'arccot',
  987. 'arccsc',
  988. 'arcsec',
  989. 'arcsin',
  990. 'arctan'
  991. ];
  992. const hyperbolicFunctions = [
  993. 'cosh',
  994. 'coth',
  995. 'csch',
  996. 'sech',
  997. 'sinh',
  998. 'tanh',
  999. 'arcosh',
  1000. 'arcoth',
  1001. 'arcsch',
  1002. 'arsech',
  1003. 'arsinh',
  1004. 'artanh'
  1005. ];
  1006. const algebraicFunctions = ['deg', 'det', 'dim', 'hom', 'ker', 'Tr'];
  1007. const elementaryFunctions = [
  1008. 'log',
  1009. 'ln',
  1010. 'lg',
  1011. 'exp',
  1012. 'gcd',
  1013. 'lcm',
  1014. 'arg',
  1015. 'im',
  1016. 're',
  1017. 'Pr'
  1018. ];
  1019. const prefixFunctions = trigonometricFunctions.concat(hyperbolicFunctions, algebraicFunctions, elementaryFunctions);
  1020. function initFunctions() {
  1021. addMeaning([
  1022. 'inf',
  1023. 'lim',
  1024. 'liminf',
  1025. 'limsup',
  1026. 'max',
  1027. 'min',
  1028. 'sup',
  1029. 'injlim',
  1030. 'projlim'
  1031. ], {
  1032. type: semantic_meaning_js_1.SemanticType.FUNCTION,
  1033. role: semantic_meaning_js_1.SemanticRole.LIMFUNC
  1034. });
  1035. addMeaning(prefixFunctions, {
  1036. type: semantic_meaning_js_1.SemanticType.FUNCTION,
  1037. role: semantic_meaning_js_1.SemanticRole.PREFIXFUNC
  1038. });
  1039. addMeaning(['mod', 'rem'], {
  1040. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  1041. role: semantic_meaning_js_1.SemanticRole.PREFIXFUNC
  1042. });
  1043. }
  1044. function addFunctionSemantic(base, names) {
  1045. const meaning = exports.SemanticMap.Meaning.get(base) || {
  1046. type: semantic_meaning_js_1.SemanticType.FUNCTION,
  1047. role: semantic_meaning_js_1.SemanticRole.PREFIXFUNC
  1048. };
  1049. addMeaning(names, meaning);
  1050. }
  1051. function equal(meaning1, meaning2) {
  1052. return (meaning1.type === meaning2.type &&
  1053. meaning1.role === meaning2.role &&
  1054. meaning1.font === meaning2.font);
  1055. }
  1056. function isMatchingFence(open, close) {
  1057. const meaning = exports.SemanticMap.Meaning.get(open);
  1058. if (meaning.type !== semantic_meaning_js_1.SemanticType.FENCE) {
  1059. return false;
  1060. }
  1061. if (meaning.role === semantic_meaning_js_1.SemanticRole.NEUTRAL ||
  1062. meaning.role === semantic_meaning_js_1.SemanticRole.METRIC) {
  1063. return open === close;
  1064. }
  1065. return (exports.SemanticMap.FencesHoriz.get(open) === close ||
  1066. exports.SemanticMap.FencesVert.get(open) === close);
  1067. }
  1068. function changeSemantics(alphabet, change) {
  1069. for (const [pos, meaning] of Object.entries(change)) {
  1070. const character = alphabet[pos];
  1071. if (character !== undefined) {
  1072. exports.SemanticMap.Meaning.set(character, meaning);
  1073. }
  1074. }
  1075. }
  1076. function addSecondaries(alphabet, change) {
  1077. for (const [pos, meaning] of Object.entries(change)) {
  1078. const character = alphabet[pos];
  1079. if (character !== undefined) {
  1080. exports.SemanticMap.Secondary.set(character, meaning);
  1081. }
  1082. }
  1083. }
  1084. function singleAlphabet(alphabet, type, role, font, semfont, secondaries = [], change = {}, secondary = {}) {
  1085. const interval = Alphabet.INTERVALS.get(Alphabet.alphabetName(alphabet, font));
  1086. if (interval) {
  1087. interval.unicode.forEach((x) => {
  1088. exports.SemanticMap.Meaning.set(x, {
  1089. type: type,
  1090. role: role,
  1091. font: semfont
  1092. });
  1093. secondaries.forEach((sec) => exports.SemanticMap.Secondary.set(x, sec));
  1094. });
  1095. changeSemantics(interval.unicode, change);
  1096. addSecondaries(interval.unicode, secondary);
  1097. }
  1098. }
  1099. function initAlphabets() {
  1100. for (const [name, font] of Object.entries(semantic_meaning_js_1.SemanticFont)) {
  1101. const emb = !!Alphabet.Embellish[name];
  1102. const semfont = emb
  1103. ? semantic_meaning_js_1.SemanticFont.UNKNOWN
  1104. : font === semantic_meaning_js_1.SemanticFont.FULLWIDTH
  1105. ? semantic_meaning_js_1.SemanticFont.NORMAL
  1106. : font;
  1107. singleAlphabet(Alphabet.Base.LATINCAP, semantic_meaning_js_1.SemanticType.IDENTIFIER, semantic_meaning_js_1.SemanticRole.LATINLETTER, font, semfont, [semantic_meaning_js_1.SemanticSecondary.ALLLETTERS]);
  1108. singleAlphabet(Alphabet.Base.LATINSMALL, semantic_meaning_js_1.SemanticType.IDENTIFIER, semantic_meaning_js_1.SemanticRole.LATINLETTER, font, semfont, [semantic_meaning_js_1.SemanticSecondary.ALLLETTERS], {}, { 3: semantic_meaning_js_1.SemanticSecondary.D });
  1109. singleAlphabet(Alphabet.Base.GREEKCAP, semantic_meaning_js_1.SemanticType.IDENTIFIER, semantic_meaning_js_1.SemanticRole.GREEKLETTER, font, semfont, [semantic_meaning_js_1.SemanticSecondary.ALLLETTERS]);
  1110. singleAlphabet(Alphabet.Base.GREEKSMALL, semantic_meaning_js_1.SemanticType.IDENTIFIER, semantic_meaning_js_1.SemanticRole.GREEKLETTER, font, semfont, [semantic_meaning_js_1.SemanticSecondary.ALLLETTERS], {
  1111. 0: {
  1112. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  1113. role: semantic_meaning_js_1.SemanticRole.PREFIXOP,
  1114. font: semfont
  1115. },
  1116. 26: {
  1117. type: semantic_meaning_js_1.SemanticType.OPERATOR,
  1118. role: semantic_meaning_js_1.SemanticRole.PREFIXOP,
  1119. font: semfont
  1120. }
  1121. });
  1122. singleAlphabet(Alphabet.Base.DIGIT, semantic_meaning_js_1.SemanticType.NUMBER, semantic_meaning_js_1.SemanticRole.INTEGER, font, semfont);
  1123. }
  1124. }
  1125. initMeaning();
  1126. initFences();
  1127. initAlphabets();
  1128. initFunctions();