clojure.js 20 KB

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