1/** 2 * @license Copyright (C) 2011 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/** 18 * @fileoverview 19 * Registers a language handler for Clojure. 20 * 21 * 22 * To use, include prettify.js and this file in your HTML page. 23 * Then put your code in an HTML tag like 24 * <pre class="prettyprint lang-lisp">(my lisp code)</pre> 25 * The lang-cl class identifies the language as common lisp. 26 * This file supports the following language extensions: 27 * lang-clj - Clojure 28 * 29 * 30 * I used lang-lisp.js as the basis for this adding the clojure specific 31 * keywords and syntax. 32 * 33 * "Name" = 'Clojure' 34 * "Author" = 'Rich Hickey' 35 * "Version" = '1.2' 36 * "About" = 'Clojure is a lisp for the jvm with concurrency primitives and a richer set of types.' 37 * 38 * 39 * I used <a href="http://clojure.org/Reference">Clojure.org Reference</a> as 40 * the basis for the reserved word list. 41 * 42 * 43 * @author jwall@google.com 44 */ 45 46PR['registerLangHandler']( 47 PR['createSimpleLexer']( 48 [ 49 // clojure has more paren types than minimal lisp. 50 ['opn', /^[\(\{\[]+/, null, '([{'], 51 ['clo', /^[\)\}\]]+/, null, ')]}'], 52 // A line comment that starts with ; 53 [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'], 54 // Whitespace 55 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 56 // A double quoted, possibly multi-line, string. 57 [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 58 ], 59 [ 60 // clojure has a much larger set of keywords 61 [PR['PR_KEYWORD'], /^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/, null], 62 [PR['PR_TYPE'], /^:[0-9a-zA-Z\-]+/] 63 ]), 64 ['clj']); 65