clojure.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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/clojure/clojure.ts
  8. var conf = {
  9. comments: {
  10. lineComment: ";;"
  11. },
  12. brackets: [
  13. ["[", "]"],
  14. ["(", ")"],
  15. ["{", "}"]
  16. ],
  17. autoClosingPairs: [
  18. { open: "[", close: "]" },
  19. { open: '"', close: '"' },
  20. { open: "(", close: ")" },
  21. { open: "{", close: "}" }
  22. ],
  23. surroundingPairs: [
  24. { open: "[", close: "]" },
  25. { open: '"', close: '"' },
  26. { open: "(", close: ")" },
  27. { open: "{", close: "}" }
  28. ]
  29. };
  30. var language = {
  31. defaultToken: "",
  32. ignoreCase: true,
  33. tokenPostfix: ".clj",
  34. brackets: [
  35. { open: "[", close: "]", token: "delimiter.square" },
  36. { open: "(", close: ")", token: "delimiter.parenthesis" },
  37. { open: "{", close: "}", token: "delimiter.curly" }
  38. ],
  39. constants: ["true", "false", "nil"],
  40. numbers: /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/,
  41. characters: /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/,
  42. escapes: /^\\(?:["'\\bfnrt]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  43. qualifiedSymbols: /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/,
  44. specialForms: [
  45. ".",
  46. "catch",
  47. "def",
  48. "do",
  49. "if",
  50. "monitor-enter",
  51. "monitor-exit",
  52. "new",
  53. "quote",
  54. "recur",
  55. "set!",
  56. "throw",
  57. "try",
  58. "var"
  59. ],
  60. coreSymbols: [
  61. "*",
  62. "*'",
  63. "*1",
  64. "*2",
  65. "*3",
  66. "*agent*",
  67. "*allow-unresolved-vars*",
  68. "*assert*",
  69. "*clojure-version*",
  70. "*command-line-args*",
  71. "*compile-files*",
  72. "*compile-path*",
  73. "*compiler-options*",
  74. "*data-readers*",
  75. "*default-data-reader-fn*",
  76. "*e",
  77. "*err*",
  78. "*file*",
  79. "*flush-on-newline*",
  80. "*fn-loader*",
  81. "*in*",
  82. "*math-context*",
  83. "*ns*",
  84. "*out*",
  85. "*print-dup*",
  86. "*print-length*",
  87. "*print-level*",
  88. "*print-meta*",
  89. "*print-namespace-maps*",
  90. "*print-readably*",
  91. "*read-eval*",
  92. "*reader-resolver*",
  93. "*source-path*",
  94. "*suppress-read*",
  95. "*unchecked-math*",
  96. "*use-context-classloader*",
  97. "*verbose-defrecords*",
  98. "*warn-on-reflection*",
  99. "+",
  100. "+'",
  101. "-",
  102. "-'",
  103. "->",
  104. "->>",
  105. "->ArrayChunk",
  106. "->Eduction",
  107. "->Vec",
  108. "->VecNode",
  109. "->VecSeq",
  110. "-cache-protocol-fn",
  111. "-reset-methods",
  112. "..",
  113. "/",
  114. "<",
  115. "<=",
  116. "=",
  117. "==",
  118. ">",
  119. ">=",
  120. "EMPTY-NODE",
  121. "Inst",
  122. "StackTraceElement->vec",
  123. "Throwable->map",
  124. "accessor",
  125. "aclone",
  126. "add-classpath",
  127. "add-watch",
  128. "agent",
  129. "agent-error",
  130. "agent-errors",
  131. "aget",
  132. "alength",
  133. "alias",
  134. "all-ns",
  135. "alter",
  136. "alter-meta!",
  137. "alter-var-root",
  138. "amap",
  139. "ancestors",
  140. "and",
  141. "any?",
  142. "apply",
  143. "areduce",
  144. "array-map",
  145. "as->",
  146. "aset",
  147. "aset-boolean",
  148. "aset-byte",
  149. "aset-char",
  150. "aset-double",
  151. "aset-float",
  152. "aset-int",
  153. "aset-long",
  154. "aset-short",
  155. "assert",
  156. "assoc",
  157. "assoc!",
  158. "assoc-in",
  159. "associative?",
  160. "atom",
  161. "await",
  162. "await-for",
  163. "await1",
  164. "bases",
  165. "bean",
  166. "bigdec",
  167. "bigint",
  168. "biginteger",
  169. "binding",
  170. "bit-and",
  171. "bit-and-not",
  172. "bit-clear",
  173. "bit-flip",
  174. "bit-not",
  175. "bit-or",
  176. "bit-set",
  177. "bit-shift-left",
  178. "bit-shift-right",
  179. "bit-test",
  180. "bit-xor",
  181. "boolean",
  182. "boolean-array",
  183. "boolean?",
  184. "booleans",
  185. "bound-fn",
  186. "bound-fn*",
  187. "bound?",
  188. "bounded-count",
  189. "butlast",
  190. "byte",
  191. "byte-array",
  192. "bytes",
  193. "bytes?",
  194. "case",
  195. "cast",
  196. "cat",
  197. "char",
  198. "char-array",
  199. "char-escape-string",
  200. "char-name-string",
  201. "char?",
  202. "chars",
  203. "chunk",
  204. "chunk-append",
  205. "chunk-buffer",
  206. "chunk-cons",
  207. "chunk-first",
  208. "chunk-next",
  209. "chunk-rest",
  210. "chunked-seq?",
  211. "class",
  212. "class?",
  213. "clear-agent-errors",
  214. "clojure-version",
  215. "coll?",
  216. "comment",
  217. "commute",
  218. "comp",
  219. "comparator",
  220. "compare",
  221. "compare-and-set!",
  222. "compile",
  223. "complement",
  224. "completing",
  225. "concat",
  226. "cond",
  227. "cond->",
  228. "cond->>",
  229. "condp",
  230. "conj",
  231. "conj!",
  232. "cons",
  233. "constantly",
  234. "construct-proxy",
  235. "contains?",
  236. "count",
  237. "counted?",
  238. "create-ns",
  239. "create-struct",
  240. "cycle",
  241. "dec",
  242. "dec'",
  243. "decimal?",
  244. "declare",
  245. "dedupe",
  246. "default-data-readers",
  247. "definline",
  248. "definterface",
  249. "defmacro",
  250. "defmethod",
  251. "defmulti",
  252. "defn",
  253. "defn-",
  254. "defonce",
  255. "defprotocol",
  256. "defrecord",
  257. "defstruct",
  258. "deftype",
  259. "delay",
  260. "delay?",
  261. "deliver",
  262. "denominator",
  263. "deref",
  264. "derive",
  265. "descendants",
  266. "destructure",
  267. "disj",
  268. "disj!",
  269. "dissoc",
  270. "dissoc!",
  271. "distinct",
  272. "distinct?",
  273. "doall",
  274. "dorun",
  275. "doseq",
  276. "dosync",
  277. "dotimes",
  278. "doto",
  279. "double",
  280. "double-array",
  281. "double?",
  282. "doubles",
  283. "drop",
  284. "drop-last",
  285. "drop-while",
  286. "eduction",
  287. "empty",
  288. "empty?",
  289. "ensure",
  290. "ensure-reduced",
  291. "enumeration-seq",
  292. "error-handler",
  293. "error-mode",
  294. "eval",
  295. "even?",
  296. "every-pred",
  297. "every?",
  298. "ex-data",
  299. "ex-info",
  300. "extend",
  301. "extend-protocol",
  302. "extend-type",
  303. "extenders",
  304. "extends?",
  305. "false?",
  306. "ffirst",
  307. "file-seq",
  308. "filter",
  309. "filterv",
  310. "find",
  311. "find-keyword",
  312. "find-ns",
  313. "find-protocol-impl",
  314. "find-protocol-method",
  315. "find-var",
  316. "first",
  317. "flatten",
  318. "float",
  319. "float-array",
  320. "float?",
  321. "floats",
  322. "flush",
  323. "fn",
  324. "fn?",
  325. "fnext",
  326. "fnil",
  327. "for",
  328. "force",
  329. "format",
  330. "frequencies",
  331. "future",
  332. "future-call",
  333. "future-cancel",
  334. "future-cancelled?",
  335. "future-done?",
  336. "future?",
  337. "gen-class",
  338. "gen-interface",
  339. "gensym",
  340. "get",
  341. "get-in",
  342. "get-method",
  343. "get-proxy-class",
  344. "get-thread-bindings",
  345. "get-validator",
  346. "group-by",
  347. "halt-when",
  348. "hash",
  349. "hash-combine",
  350. "hash-map",
  351. "hash-ordered-coll",
  352. "hash-set",
  353. "hash-unordered-coll",
  354. "ident?",
  355. "identical?",
  356. "identity",
  357. "if-let",
  358. "if-not",
  359. "if-some",
  360. "ifn?",
  361. "import",
  362. "in-ns",
  363. "inc",
  364. "inc'",
  365. "indexed?",
  366. "init-proxy",
  367. "inst-ms",
  368. "inst-ms*",
  369. "inst?",
  370. "instance?",
  371. "int",
  372. "int-array",
  373. "int?",
  374. "integer?",
  375. "interleave",
  376. "intern",
  377. "interpose",
  378. "into",
  379. "into-array",
  380. "ints",
  381. "io!",
  382. "isa?",
  383. "iterate",
  384. "iterator-seq",
  385. "juxt",
  386. "keep",
  387. "keep-indexed",
  388. "key",
  389. "keys",
  390. "keyword",
  391. "keyword?",
  392. "last",
  393. "lazy-cat",
  394. "lazy-seq",
  395. "let",
  396. "letfn",
  397. "line-seq",
  398. "list",
  399. "list*",
  400. "list?",
  401. "load",
  402. "load-file",
  403. "load-reader",
  404. "load-string",
  405. "loaded-libs",
  406. "locking",
  407. "long",
  408. "long-array",
  409. "longs",
  410. "loop",
  411. "macroexpand",
  412. "macroexpand-1",
  413. "make-array",
  414. "make-hierarchy",
  415. "map",
  416. "map-entry?",
  417. "map-indexed",
  418. "map?",
  419. "mapcat",
  420. "mapv",
  421. "max",
  422. "max-key",
  423. "memfn",
  424. "memoize",
  425. "merge",
  426. "merge-with",
  427. "meta",
  428. "method-sig",
  429. "methods",
  430. "min",
  431. "min-key",
  432. "mix-collection-hash",
  433. "mod",
  434. "munge",
  435. "name",
  436. "namespace",
  437. "namespace-munge",
  438. "nat-int?",
  439. "neg-int?",
  440. "neg?",
  441. "newline",
  442. "next",
  443. "nfirst",
  444. "nil?",
  445. "nnext",
  446. "not",
  447. "not-any?",
  448. "not-empty",
  449. "not-every?",
  450. "not=",
  451. "ns",
  452. "ns-aliases",
  453. "ns-imports",
  454. "ns-interns",
  455. "ns-map",
  456. "ns-name",
  457. "ns-publics",
  458. "ns-refers",
  459. "ns-resolve",
  460. "ns-unalias",
  461. "ns-unmap",
  462. "nth",
  463. "nthnext",
  464. "nthrest",
  465. "num",
  466. "number?",
  467. "numerator",
  468. "object-array",
  469. "odd?",
  470. "or",
  471. "parents",
  472. "partial",
  473. "partition",
  474. "partition-all",
  475. "partition-by",
  476. "pcalls",
  477. "peek",
  478. "persistent!",
  479. "pmap",
  480. "pop",
  481. "pop!",
  482. "pop-thread-bindings",
  483. "pos-int?",
  484. "pos?",
  485. "pr",
  486. "pr-str",
  487. "prefer-method",
  488. "prefers",
  489. "primitives-classnames",
  490. "print",
  491. "print-ctor",
  492. "print-dup",
  493. "print-method",
  494. "print-simple",
  495. "print-str",
  496. "printf",
  497. "println",
  498. "println-str",
  499. "prn",
  500. "prn-str",
  501. "promise",
  502. "proxy",
  503. "proxy-call-with-super",
  504. "proxy-mappings",
  505. "proxy-name",
  506. "proxy-super",
  507. "push-thread-bindings",
  508. "pvalues",
  509. "qualified-ident?",
  510. "qualified-keyword?",
  511. "qualified-symbol?",
  512. "quot",
  513. "rand",
  514. "rand-int",
  515. "rand-nth",
  516. "random-sample",
  517. "range",
  518. "ratio?",
  519. "rational?",
  520. "rationalize",
  521. "re-find",
  522. "re-groups",
  523. "re-matcher",
  524. "re-matches",
  525. "re-pattern",
  526. "re-seq",
  527. "read",
  528. "read-line",
  529. "read-string",
  530. "reader-conditional",
  531. "reader-conditional?",
  532. "realized?",
  533. "record?",
  534. "reduce",
  535. "reduce-kv",
  536. "reduced",
  537. "reduced?",
  538. "reductions",
  539. "ref",
  540. "ref-history-count",
  541. "ref-max-history",
  542. "ref-min-history",
  543. "ref-set",
  544. "refer",
  545. "refer-clojure",
  546. "reify",
  547. "release-pending-sends",
  548. "rem",
  549. "remove",
  550. "remove-all-methods",
  551. "remove-method",
  552. "remove-ns",
  553. "remove-watch",
  554. "repeat",
  555. "repeatedly",
  556. "replace",
  557. "replicate",
  558. "require",
  559. "reset!",
  560. "reset-meta!",
  561. "reset-vals!",
  562. "resolve",
  563. "rest",
  564. "restart-agent",
  565. "resultset-seq",
  566. "reverse",
  567. "reversible?",
  568. "rseq",
  569. "rsubseq",
  570. "run!",
  571. "satisfies?",
  572. "second",
  573. "select-keys",
  574. "send",
  575. "send-off",
  576. "send-via",
  577. "seq",
  578. "seq?",
  579. "seqable?",
  580. "seque",
  581. "sequence",
  582. "sequential?",
  583. "set",
  584. "set-agent-send-executor!",
  585. "set-agent-send-off-executor!",
  586. "set-error-handler!",
  587. "set-error-mode!",
  588. "set-validator!",
  589. "set?",
  590. "short",
  591. "short-array",
  592. "shorts",
  593. "shuffle",
  594. "shutdown-agents",
  595. "simple-ident?",
  596. "simple-keyword?",
  597. "simple-symbol?",
  598. "slurp",
  599. "some",
  600. "some->",
  601. "some->>",
  602. "some-fn",
  603. "some?",
  604. "sort",
  605. "sort-by",
  606. "sorted-map",
  607. "sorted-map-by",
  608. "sorted-set",
  609. "sorted-set-by",
  610. "sorted?",
  611. "special-symbol?",
  612. "spit",
  613. "split-at",
  614. "split-with",
  615. "str",
  616. "string?",
  617. "struct",
  618. "struct-map",
  619. "subs",
  620. "subseq",
  621. "subvec",
  622. "supers",
  623. "swap!",
  624. "swap-vals!",
  625. "symbol",
  626. "symbol?",
  627. "sync",
  628. "tagged-literal",
  629. "tagged-literal?",
  630. "take",
  631. "take-last",
  632. "take-nth",
  633. "take-while",
  634. "test",
  635. "the-ns",
  636. "thread-bound?",
  637. "time",
  638. "to-array",
  639. "to-array-2d",
  640. "trampoline",
  641. "transduce",
  642. "transient",
  643. "tree-seq",
  644. "true?",
  645. "type",
  646. "unchecked-add",
  647. "unchecked-add-int",
  648. "unchecked-byte",
  649. "unchecked-char",
  650. "unchecked-dec",
  651. "unchecked-dec-int",
  652. "unchecked-divide-int",
  653. "unchecked-double",
  654. "unchecked-float",
  655. "unchecked-inc",
  656. "unchecked-inc-int",
  657. "unchecked-int",
  658. "unchecked-long",
  659. "unchecked-multiply",
  660. "unchecked-multiply-int",
  661. "unchecked-negate",
  662. "unchecked-negate-int",
  663. "unchecked-remainder-int",
  664. "unchecked-short",
  665. "unchecked-subtract",
  666. "unchecked-subtract-int",
  667. "underive",
  668. "unquote",
  669. "unquote-splicing",
  670. "unreduced",
  671. "unsigned-bit-shift-right",
  672. "update",
  673. "update-in",
  674. "update-proxy",
  675. "uri?",
  676. "use",
  677. "uuid?",
  678. "val",
  679. "vals",
  680. "var-get",
  681. "var-set",
  682. "var?",
  683. "vary-meta",
  684. "vec",
  685. "vector",
  686. "vector-of",
  687. "vector?",
  688. "volatile!",
  689. "volatile?",
  690. "vreset!",
  691. "vswap!",
  692. "when",
  693. "when-first",
  694. "when-let",
  695. "when-not",
  696. "when-some",
  697. "while",
  698. "with-bindings",
  699. "with-bindings*",
  700. "with-in-str",
  701. "with-loading-context",
  702. "with-local-vars",
  703. "with-meta",
  704. "with-open",
  705. "with-out-str",
  706. "with-precision",
  707. "with-redefs",
  708. "with-redefs-fn",
  709. "xml-seq",
  710. "zero?",
  711. "zipmap"
  712. ],
  713. tokenizer: {
  714. root: [
  715. { include: "@whitespace" },
  716. [/@numbers/, "number"],
  717. [/@characters/, "string"],
  718. { include: "@string" },
  719. [/[()\[\]{}]/, "@brackets"],
  720. [/\/#"(?:\.|(?:")|[^"\n])*"\/g/, "regexp"],
  721. [/[#'@^`~]/, "meta"],
  722. [
  723. /@qualifiedSymbols/,
  724. {
  725. cases: {
  726. "^:.+$": "constant",
  727. "@specialForms": "keyword",
  728. "@coreSymbols": "keyword",
  729. "@constants": "constant",
  730. "@default": "identifier"
  731. }
  732. }
  733. ]
  734. ],
  735. whitespace: [
  736. [/[\s,]+/, "white"],
  737. [/;.*$/, "comment"],
  738. [/\(comment\b/, "comment", "@comment"]
  739. ],
  740. comment: [
  741. [/\(/, "comment", "@push"],
  742. [/\)/, "comment", "@pop"],
  743. [/[^()]/, "comment"]
  744. ],
  745. string: [[/"/, "string", "@multiLineString"]],
  746. multiLineString: [
  747. [/"/, "string", "@popall"],
  748. [/@escapes/, "string.escape"],
  749. [/./, "string"]
  750. ]
  751. }
  752. };
  753. export {
  754. conf,
  755. language
  756. };