postiats.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/postiats/postiats.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "//",
  11. blockComment: ["(*", "*)"]
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"],
  17. ["<", ">"]
  18. ],
  19. autoClosingPairs: [
  20. { open: '"', close: '"', notIn: ["string", "comment"] },
  21. { open: "{", close: "}", notIn: ["string", "comment"] },
  22. { open: "[", close: "]", notIn: ["string", "comment"] },
  23. { open: "(", close: ")", notIn: ["string", "comment"] }
  24. ]
  25. };
  26. var language = {
  27. tokenPostfix: ".pats",
  28. defaultToken: "invalid",
  29. keywords: [
  30. "abstype",
  31. "abst0ype",
  32. "absprop",
  33. "absview",
  34. "absvtype",
  35. "absviewtype",
  36. "absvt0ype",
  37. "absviewt0ype",
  38. "as",
  39. "and",
  40. "assume",
  41. "begin",
  42. "classdec",
  43. "datasort",
  44. "datatype",
  45. "dataprop",
  46. "dataview",
  47. "datavtype",
  48. "dataviewtype",
  49. "do",
  50. "end",
  51. "extern",
  52. "extype",
  53. "extvar",
  54. "exception",
  55. "fn",
  56. "fnx",
  57. "fun",
  58. "prfn",
  59. "prfun",
  60. "praxi",
  61. "castfn",
  62. "if",
  63. "then",
  64. "else",
  65. "ifcase",
  66. "in",
  67. "infix",
  68. "infixl",
  69. "infixr",
  70. "prefix",
  71. "postfix",
  72. "implmnt",
  73. "implement",
  74. "primplmnt",
  75. "primplement",
  76. "import",
  77. "let",
  78. "local",
  79. "macdef",
  80. "macrodef",
  81. "nonfix",
  82. "symelim",
  83. "symintr",
  84. "overload",
  85. "of",
  86. "op",
  87. "rec",
  88. "sif",
  89. "scase",
  90. "sortdef",
  91. "sta",
  92. "stacst",
  93. "stadef",
  94. "static",
  95. "staload",
  96. "dynload",
  97. "try",
  98. "tkindef",
  99. "typedef",
  100. "propdef",
  101. "viewdef",
  102. "vtypedef",
  103. "viewtypedef",
  104. "prval",
  105. "var",
  106. "prvar",
  107. "when",
  108. "where",
  109. "with",
  110. "withtype",
  111. "withprop",
  112. "withview",
  113. "withvtype",
  114. "withviewtype"
  115. ],
  116. keywords_dlr: [
  117. "$delay",
  118. "$ldelay",
  119. "$arrpsz",
  120. "$arrptrsize",
  121. "$d2ctype",
  122. "$effmask",
  123. "$effmask_ntm",
  124. "$effmask_exn",
  125. "$effmask_ref",
  126. "$effmask_wrt",
  127. "$effmask_all",
  128. "$extern",
  129. "$extkind",
  130. "$extype",
  131. "$extype_struct",
  132. "$extval",
  133. "$extfcall",
  134. "$extmcall",
  135. "$literal",
  136. "$myfilename",
  137. "$mylocation",
  138. "$myfunction",
  139. "$lst",
  140. "$lst_t",
  141. "$lst_vt",
  142. "$list",
  143. "$list_t",
  144. "$list_vt",
  145. "$rec",
  146. "$rec_t",
  147. "$rec_vt",
  148. "$record",
  149. "$record_t",
  150. "$record_vt",
  151. "$tup",
  152. "$tup_t",
  153. "$tup_vt",
  154. "$tuple",
  155. "$tuple_t",
  156. "$tuple_vt",
  157. "$break",
  158. "$continue",
  159. "$raise",
  160. "$showtype",
  161. "$vcopyenv_v",
  162. "$vcopyenv_vt",
  163. "$tempenver",
  164. "$solver_assert",
  165. "$solver_verify"
  166. ],
  167. keywords_srp: [
  168. "#if",
  169. "#ifdef",
  170. "#ifndef",
  171. "#then",
  172. "#elif",
  173. "#elifdef",
  174. "#elifndef",
  175. "#else",
  176. "#endif",
  177. "#error",
  178. "#prerr",
  179. "#print",
  180. "#assert",
  181. "#undef",
  182. "#define",
  183. "#include",
  184. "#require",
  185. "#pragma",
  186. "#codegen2",
  187. "#codegen3"
  188. ],
  189. irregular_keyword_list: [
  190. "val+",
  191. "val-",
  192. "val",
  193. "case+",
  194. "case-",
  195. "case",
  196. "addr@",
  197. "addr",
  198. "fold@",
  199. "free@",
  200. "fix@",
  201. "fix",
  202. "lam@",
  203. "lam",
  204. "llam@",
  205. "llam",
  206. "viewt@ype+",
  207. "viewt@ype-",
  208. "viewt@ype",
  209. "viewtype+",
  210. "viewtype-",
  211. "viewtype",
  212. "view+",
  213. "view-",
  214. "view@",
  215. "view",
  216. "type+",
  217. "type-",
  218. "type",
  219. "vtype+",
  220. "vtype-",
  221. "vtype",
  222. "vt@ype+",
  223. "vt@ype-",
  224. "vt@ype",
  225. "viewt@ype+",
  226. "viewt@ype-",
  227. "viewt@ype",
  228. "viewtype+",
  229. "viewtype-",
  230. "viewtype",
  231. "prop+",
  232. "prop-",
  233. "prop",
  234. "type+",
  235. "type-",
  236. "type",
  237. "t@ype",
  238. "t@ype+",
  239. "t@ype-",
  240. "abst@ype",
  241. "abstype",
  242. "absviewt@ype",
  243. "absvt@ype",
  244. "for*",
  245. "for",
  246. "while*",
  247. "while"
  248. ],
  249. keywords_types: [
  250. "bool",
  251. "double",
  252. "byte",
  253. "int",
  254. "short",
  255. "char",
  256. "void",
  257. "unit",
  258. "long",
  259. "float",
  260. "string",
  261. "strptr"
  262. ],
  263. keywords_effects: [
  264. "0",
  265. "fun",
  266. "clo",
  267. "prf",
  268. "funclo",
  269. "cloptr",
  270. "cloref",
  271. "ref",
  272. "ntm",
  273. "1"
  274. ],
  275. operators: [
  276. "@",
  277. "!",
  278. "|",
  279. "`",
  280. ":",
  281. "$",
  282. ".",
  283. "=",
  284. "#",
  285. "~",
  286. "..",
  287. "...",
  288. "=>",
  289. "=<>",
  290. "=/=>",
  291. "=>>",
  292. "=/=>>",
  293. "<",
  294. ">",
  295. "><",
  296. ".<",
  297. ">.",
  298. ".<>.",
  299. "->",
  300. "-<>"
  301. ],
  302. brackets: [
  303. { open: ",(", close: ")", token: "delimiter.parenthesis" },
  304. { open: "`(", close: ")", token: "delimiter.parenthesis" },
  305. { open: "%(", close: ")", token: "delimiter.parenthesis" },
  306. { open: "'(", close: ")", token: "delimiter.parenthesis" },
  307. { open: "'{", close: "}", token: "delimiter.parenthesis" },
  308. { open: "@(", close: ")", token: "delimiter.parenthesis" },
  309. { open: "@{", close: "}", token: "delimiter.brace" },
  310. { open: "@[", close: "]", token: "delimiter.square" },
  311. { open: "#[", close: "]", token: "delimiter.square" },
  312. { open: "{", close: "}", token: "delimiter.curly" },
  313. { open: "[", close: "]", token: "delimiter.square" },
  314. { open: "(", close: ")", token: "delimiter.parenthesis" },
  315. { open: "<", close: ">", token: "delimiter.angle" }
  316. ],
  317. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  318. IDENTFST: /[a-zA-Z_]/,
  319. IDENTRST: /[a-zA-Z0-9_'$]/,
  320. symbolic: /[%&+-./:=@~`^|*!$#?<>]/,
  321. digit: /[0-9]/,
  322. digitseq0: /@digit*/,
  323. xdigit: /[0-9A-Za-z]/,
  324. xdigitseq0: /@xdigit*/,
  325. INTSP: /[lLuU]/,
  326. FLOATSP: /[fFlL]/,
  327. fexponent: /[eE][+-]?[0-9]+/,
  328. fexponent_bin: /[pP][+-]?[0-9]+/,
  329. deciexp: /\.[0-9]*@fexponent?/,
  330. hexiexp: /\.[0-9a-zA-Z]*@fexponent_bin?/,
  331. irregular_keywords: /val[+-]?|case[+-]?|addr\@?|fold\@|free\@|fix\@?|lam\@?|llam\@?|prop[+-]?|type[+-]?|view[+-@]?|viewt@?ype[+-]?|t@?ype[+-]?|v(iew)?t@?ype[+-]?|abst@?ype|absv(iew)?t@?ype|for\*?|while\*?/,
  332. ESCHAR: /[ntvbrfa\\\?'"\(\[\{]/,
  333. start: "root",
  334. tokenizer: {
  335. root: [
  336. { regex: /[ \t\r\n]+/, action: { token: "" } },
  337. { regex: /\(\*\)/, action: { token: "invalid" } },
  338. {
  339. regex: /\(\*/,
  340. action: { token: "comment", next: "lexing_COMMENT_block_ml" }
  341. },
  342. {
  343. regex: /\(/,
  344. action: "@brackets"
  345. },
  346. {
  347. regex: /\)/,
  348. action: "@brackets"
  349. },
  350. {
  351. regex: /\[/,
  352. action: "@brackets"
  353. },
  354. {
  355. regex: /\]/,
  356. action: "@brackets"
  357. },
  358. {
  359. regex: /\{/,
  360. action: "@brackets"
  361. },
  362. {
  363. regex: /\}/,
  364. action: "@brackets"
  365. },
  366. {
  367. regex: /,\(/,
  368. action: "@brackets"
  369. },
  370. { regex: /,/, action: { token: "delimiter.comma" } },
  371. { regex: /;/, action: { token: "delimiter.semicolon" } },
  372. {
  373. regex: /@\(/,
  374. action: "@brackets"
  375. },
  376. {
  377. regex: /@\[/,
  378. action: "@brackets"
  379. },
  380. {
  381. regex: /@\{/,
  382. action: "@brackets"
  383. },
  384. {
  385. regex: /:</,
  386. action: { token: "keyword", next: "@lexing_EFFECT_commaseq0" }
  387. },
  388. { regex: /\.@symbolic+/, action: { token: "identifier.sym" } },
  389. {
  390. regex: /\.@digit*@fexponent@FLOATSP*/,
  391. action: { token: "number.float" }
  392. },
  393. { regex: /\.@digit+/, action: { token: "number.float" } },
  394. {
  395. regex: /\$@IDENTFST@IDENTRST*/,
  396. action: {
  397. cases: {
  398. "@keywords_dlr": { token: "keyword.dlr" },
  399. "@default": { token: "namespace" }
  400. }
  401. }
  402. },
  403. {
  404. regex: /\#@IDENTFST@IDENTRST*/,
  405. action: {
  406. cases: {
  407. "@keywords_srp": { token: "keyword.srp" },
  408. "@default": { token: "identifier" }
  409. }
  410. }
  411. },
  412. { regex: /%\(/, action: { token: "delimiter.parenthesis" } },
  413. {
  414. regex: /^%{(#|\^|\$)?/,
  415. action: {
  416. token: "keyword",
  417. next: "@lexing_EXTCODE",
  418. nextEmbedded: "text/javascript"
  419. }
  420. },
  421. { regex: /^%}/, action: { token: "keyword" } },
  422. { regex: /'\(/, action: { token: "delimiter.parenthesis" } },
  423. { regex: /'\[/, action: { token: "delimiter.bracket" } },
  424. { regex: /'\{/, action: { token: "delimiter.brace" } },
  425. [/(')(\\@ESCHAR|\\[xX]@xdigit+|\\@digit+)(')/, ["string", "string.escape", "string"]],
  426. [/'[^\\']'/, "string"],
  427. [/"/, "string.quote", "@lexing_DQUOTE"],
  428. {
  429. regex: /`\(/,
  430. action: "@brackets"
  431. },
  432. { regex: /\\/, action: { token: "punctuation" } },
  433. {
  434. regex: /@irregular_keywords(?!@IDENTRST)/,
  435. action: { token: "keyword" }
  436. },
  437. {
  438. regex: /@IDENTFST@IDENTRST*[<!\[]?/,
  439. action: {
  440. cases: {
  441. "@keywords": { token: "keyword" },
  442. "@keywords_types": { token: "type" },
  443. "@default": { token: "identifier" }
  444. }
  445. }
  446. },
  447. {
  448. regex: /\/\/\/\//,
  449. action: { token: "comment", next: "@lexing_COMMENT_rest" }
  450. },
  451. { regex: /\/\/.*$/, action: { token: "comment" } },
  452. {
  453. regex: /\/\*/,
  454. action: { token: "comment", next: "@lexing_COMMENT_block_c" }
  455. },
  456. {
  457. regex: /-<|=</,
  458. action: { token: "keyword", next: "@lexing_EFFECT_commaseq0" }
  459. },
  460. {
  461. regex: /@symbolic+/,
  462. action: {
  463. cases: {
  464. "@operators": "keyword",
  465. "@default": "operator"
  466. }
  467. }
  468. },
  469. {
  470. regex: /0[xX]@xdigit+(@hexiexp|@fexponent_bin)@FLOATSP*/,
  471. action: { token: "number.float" }
  472. },
  473. { regex: /0[xX]@xdigit+@INTSP*/, action: { token: "number.hex" } },
  474. {
  475. regex: /0[0-7]+(?![0-9])@INTSP*/,
  476. action: { token: "number.octal" }
  477. },
  478. {
  479. regex: /@digit+(@fexponent|@deciexp)@FLOATSP*/,
  480. action: { token: "number.float" }
  481. },
  482. {
  483. regex: /@digit@digitseq0@INTSP*/,
  484. action: { token: "number.decimal" }
  485. },
  486. { regex: /@digit+@INTSP*/, action: { token: "number" } }
  487. ],
  488. lexing_COMMENT_block_ml: [
  489. [/[^\(\*]+/, "comment"],
  490. [/\(\*/, "comment", "@push"],
  491. [/\(\*/, "comment.invalid"],
  492. [/\*\)/, "comment", "@pop"],
  493. [/\*/, "comment"]
  494. ],
  495. lexing_COMMENT_block_c: [
  496. [/[^\/*]+/, "comment"],
  497. [/\*\//, "comment", "@pop"],
  498. [/[\/*]/, "comment"]
  499. ],
  500. lexing_COMMENT_rest: [
  501. [/$/, "comment", "@pop"],
  502. [/.*/, "comment"]
  503. ],
  504. lexing_EFFECT_commaseq0: [
  505. {
  506. regex: /@IDENTFST@IDENTRST+|@digit+/,
  507. action: {
  508. cases: {
  509. "@keywords_effects": { token: "type.effect" },
  510. "@default": { token: "identifier" }
  511. }
  512. }
  513. },
  514. { regex: /,/, action: { token: "punctuation" } },
  515. { regex: />/, action: { token: "@rematch", next: "@pop" } }
  516. ],
  517. lexing_EXTCODE: [
  518. {
  519. regex: /^%}/,
  520. action: {
  521. token: "@rematch",
  522. next: "@pop",
  523. nextEmbedded: "@pop"
  524. }
  525. },
  526. { regex: /[^%]+/, action: "" }
  527. ],
  528. lexing_DQUOTE: [
  529. { regex: /"/, action: { token: "string.quote", next: "@pop" } },
  530. {
  531. regex: /(\{\$)(@IDENTFST@IDENTRST*)(\})/,
  532. action: [{ token: "string.escape" }, { token: "identifier" }, { token: "string.escape" }]
  533. },
  534. { regex: /\\$/, action: { token: "string.escape" } },
  535. {
  536. regex: /\\(@ESCHAR|[xX]@xdigit+|@digit+)/,
  537. action: { token: "string.escape" }
  538. },
  539. { regex: /[^\\"]+/, action: { token: "string" } }
  540. ]
  541. }
  542. };
  543. export {
  544. conf,
  545. language
  546. };