CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
clojure.js185 linesDownload Raw Back to languages
1/*2Language: Clojure3Description: Clojure syntax (based on lisp.js)4Author: mfornos5Website: https://clojure.org6Category: lisp7*/8 9/** @type LanguageFn */10function clojure(hljs) {11  const SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&\'';12  const SYMBOL_RE = '[#]?[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:$#]*';13  const globals = 'def defonce defprotocol defstruct defmulti defmethod defn- defn defmacro deftype defrecord';14  const keywords = {15    $pattern: SYMBOL_RE,16    built_in:17      // Clojure keywords18      globals + ' '19      + 'cond apply if-not if-let if not not= =|0 <|0 >|0 <=|0 >=|0 ==|0 +|0 /|0 *|0 -|0 rem '20      + 'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '21      + 'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '22      + 'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '23      + 'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . '24      + 'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last '25      + 'drop-while while intern condp case reduced cycle split-at split-with repeat replicate '26      + 'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext '27      + 'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends '28      + 'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler '29      + 'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter '30      + 'monitor-exit macroexpand macroexpand-1 for dosync and or '31      + 'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert '32      + 'peek pop doto proxy first rest cons cast coll last butlast '33      + 'sigs reify second ffirst fnext nfirst nnext meta with-meta ns in-ns create-ns import '34      + 'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! '35      + 'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger '36      + 'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline '37      + 'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking '38      + 'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! '39      + 'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! '40      + 'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty '41      + 'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list '42      + 'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer '43      + 'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate '44      + 'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta '45      + 'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'46  };47 48  const SYMBOL = {49    begin: SYMBOL_RE,50    relevance: 051  };52  const NUMBER = {53    scope: 'number',54    relevance: 0,55    variants: [56      { match: /[-+]?0[xX][0-9a-fA-F]+N?/ }, // hexadecimal                 // 0x2a57      { match: /[-+]?0[0-7]+N?/ }, // octal                       // 05258      { match: /[-+]?[1-9][0-9]?[rR][0-9a-zA-Z]+N?/ }, // variable radix from 2 to 36 // 2r101010, 8r52, 36r1659      { match: /[-+]?[0-9]+\/[0-9]+N?/ }, // ratio                       // 1/260      { match: /[-+]?[0-9]+((\.[0-9]*([eE][+-]?[0-9]+)?M?)|([eE][+-]?[0-9]+M?|M))/ }, // float        // 0.42 4.2E-1M 42E1 42M61      { match: /[-+]?([1-9][0-9]*|0)N?/ }, // int (don't match leading 0) // 42 42N62    ]63  };64  const CHARACTER = {65    scope: 'character',66    variants: [67      { match: /\\o[0-3]?[0-7]{1,2}/ }, // Unicode Octal 0 - 37768      { match: /\\u[0-9a-fA-F]{4}/ }, // Unicode Hex 0000 - FFFF69      { match: /\\(newline|space|tab|formfeed|backspace|return)/ }, // special characters70      {71        match: /\\\S/,72        relevance: 073      } // any non-whitespace char74    ]75  };76  const REGEX = {77    scope: 'regex',78    begin: /#"/,79    end: /"/,80    contains: [ hljs.BACKSLASH_ESCAPE ]81  };82  const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null });83  const COMMA = {84    scope: 'punctuation',85    match: /,/,86    relevance: 087  };88  const COMMENT = hljs.COMMENT(89    ';',90    '$',91    { relevance: 0 }92  );93  const LITERAL = {94    className: 'literal',95    begin: /\b(true|false|nil)\b/96  };97  const COLLECTION = {98    begin: "\\[|(#::?" + SYMBOL_RE + ")?\\{",99    end: '[\\]\\}]',100    relevance: 0101  };102  const KEY = {103    className: 'symbol',104    begin: '[:]{1,2}' + SYMBOL_RE105  };106  const LIST = {107    begin: '\\(',108    end: '\\)'109  };110  const BODY = {111    endsWithParent: true,112    relevance: 0113  };114  const NAME = {115    keywords: keywords,116    className: 'name',117    begin: SYMBOL_RE,118    relevance: 0,119    starts: BODY120  };121  const DEFAULT_CONTAINS = [122    COMMA,123    LIST,124    CHARACTER,125    REGEX,126    STRING,127    COMMENT,128    KEY,129    COLLECTION,130    NUMBER,131    LITERAL,132    SYMBOL133  ];134 135  const GLOBAL = {136    beginKeywords: globals,137    keywords: {138      $pattern: SYMBOL_RE,139      keyword: globals140    },141    end: '(\\[|#|\\d|"|:|\\{|\\)|\\(|$)',142    contains: [143      {144        className: 'title',145        begin: SYMBOL_RE,146        relevance: 0,147        excludeEnd: true,148        // we can only have a single title149        endsParent: true150      }151    ].concat(DEFAULT_CONTAINS)152  };153 154  LIST.contains = [155    GLOBAL,156    NAME,157    BODY158  ];159  BODY.contains = DEFAULT_CONTAINS;160  COLLECTION.contains = DEFAULT_CONTAINS;161 162  return {163    name: 'Clojure',164    aliases: [165      'clj',166      'edn'167    ],168    illegal: /\S/,169    contains: [170      COMMA,171      LIST,172      CHARACTER,173      REGEX,174      STRING,175      COMMENT,176      KEY,177      COLLECTION,178      NUMBER,179      LITERAL180    ]181  };182}183 184export { clojure as default };185 
basant307/AI_Governance_Project · CoolFace