Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/clojure
File: clojure.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Author: Hans Engel
[4] Fix | Delete
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
(function(mod) {
[8] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[9] Fix | Delete
mod(require("../../lib/codemirror"));
[10] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[11] Fix | Delete
define(["../../lib/codemirror"], mod);
[12] Fix | Delete
else // Plain browser env
[13] Fix | Delete
mod(CodeMirror);
[14] Fix | Delete
})(function(CodeMirror) {
[15] Fix | Delete
"use strict";
[16] Fix | Delete
[17] Fix | Delete
CodeMirror.defineMode("clojure", function (options) {
[18] Fix | Delete
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
[19] Fix | Delete
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
[20] Fix | Delete
var INDENT_WORD_SKIP = options.indentUnit || 2;
[21] Fix | Delete
var NORMAL_INDENT_UNIT = options.indentUnit || 2;
[22] Fix | Delete
[23] Fix | Delete
function makeKeywords(str) {
[24] Fix | Delete
var obj = {}, words = str.split(" ");
[25] Fix | Delete
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
[26] Fix | Delete
return obj;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
var atoms = makeKeywords("true false nil");
[30] Fix | Delete
[31] Fix | Delete
var keywords = makeKeywords(
[32] Fix | Delete
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest " +
[33] Fix | Delete
"slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn " +
[34] Fix | Delete
"do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync " +
[35] Fix | Delete
"doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars " +
[36] Fix | Delete
"binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
[37] Fix | Delete
[38] Fix | Delete
var builtins = makeKeywords(
[39] Fix | Delete
"* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* " +
[40] Fix | Delete
"*compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* " +
[41] Fix | Delete
"*math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* " +
[42] Fix | Delete
"*source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> " +
[43] Fix | Delete
"->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor " +
[44] Fix | Delete
"aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! " +
[45] Fix | Delete
"alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double " +
[46] Fix | Delete
"aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 " +
[47] Fix | Delete
"bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set " +
[48] Fix | Delete
"bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast " +
[49] Fix | Delete
"byte byte-array bytes case cat cast char char-array char-escape-string char-name-string char? chars chunk chunk-append " +
[50] Fix | Delete
"chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors " +
[51] Fix | Delete
"clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond condp " +
[52] Fix | Delete
"conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? " +
[53] Fix | Delete
"declare dedupe default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol " +
[54] Fix | Delete
"defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc " +
[55] Fix | Delete
"dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last " +
[56] Fix | Delete
"drop-while eduction empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info " +
[57] Fix | Delete
"extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword " +
[58] Fix | Delete
"find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? " +
[59] Fix | Delete
"fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? " +
[60] Fix | Delete
"gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash " +
[61] Fix | Delete
"hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? " +
[62] Fix | Delete
"int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep " +
[63] Fix | Delete
"keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file " +
[64] Fix | Delete
"load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array " +
[65] Fix | Delete
"make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods " +
[66] Fix | Delete
"min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty " +
[67] Fix | Delete
"not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias " +
[68] Fix | Delete
"ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all " +
[69] Fix | Delete
"partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers " +
[70] Fix | Delete
"primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str " +
[71] Fix | Delete
"prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues " +
[72] Fix | Delete
"quot rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern " +
[73] Fix | Delete
"re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history " +
[74] Fix | Delete
"ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods " +
[75] Fix | Delete
"remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest " +
[76] Fix | Delete
"restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? " +
[77] Fix | Delete
"seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts " +
[78] Fix | Delete
"shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? " +
[79] Fix | Delete
"special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol " +
[80] Fix | Delete
"symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transduce " +
[81] Fix | Delete
"transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec " +
[82] Fix | Delete
"unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int " +
[83] Fix | Delete
"unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int "+
[84] Fix | Delete
"unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote " +
[85] Fix | Delete
"unquote-splicing update update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of " +
[86] Fix | Delete
"vector? volatile! volatile? vreset! vswap! when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context " +
[87] Fix | Delete
"with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap " +
[88] Fix | Delete
"*default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! " +
[89] Fix | Delete
"set-agent-send-off-executor! some-> some->>");
[90] Fix | Delete
[91] Fix | Delete
var indentKeys = makeKeywords(
[92] Fix | Delete
// Built-ins
[93] Fix | Delete
"ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto " +
[94] Fix | Delete
"locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type " +
[95] Fix | Delete
"try catch " +
[96] Fix | Delete
[97] Fix | Delete
// Binding forms
[98] Fix | Delete
"let letfn binding loop for doseq dotimes when-let if-let " +
[99] Fix | Delete
[100] Fix | Delete
// Data structures
[101] Fix | Delete
"defstruct struct-map assoc " +
[102] Fix | Delete
[103] Fix | Delete
// clojure.test
[104] Fix | Delete
"testing deftest " +
[105] Fix | Delete
[106] Fix | Delete
// contrib
[107] Fix | Delete
"handler-case handle dotrace deftrace");
[108] Fix | Delete
[109] Fix | Delete
var tests = {
[110] Fix | Delete
digit: /\d/,
[111] Fix | Delete
digit_or_colon: /[\d:]/,
[112] Fix | Delete
hex: /[0-9a-f]/i,
[113] Fix | Delete
sign: /[+-]/,
[114] Fix | Delete
exponent: /e/i,
[115] Fix | Delete
keyword_char: /[^\s\(\[\;\)\]]/,
[116] Fix | Delete
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
[117] Fix | Delete
block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
[118] Fix | Delete
};
[119] Fix | Delete
[120] Fix | Delete
function stateStack(indent, type, prev) { // represents a state stack object
[121] Fix | Delete
this.indent = indent;
[122] Fix | Delete
this.type = type;
[123] Fix | Delete
this.prev = prev;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
function pushStack(state, indent, type) {
[127] Fix | Delete
state.indentStack = new stateStack(indent, type, state.indentStack);
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
function popStack(state) {
[131] Fix | Delete
state.indentStack = state.indentStack.prev;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
function isNumber(ch, stream){
[135] Fix | Delete
// hex
[136] Fix | Delete
if ( ch === '0' && stream.eat(/x/i) ) {
[137] Fix | Delete
stream.eatWhile(tests.hex);
[138] Fix | Delete
return true;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
// leading sign
[142] Fix | Delete
if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
[143] Fix | Delete
stream.eat(tests.sign);
[144] Fix | Delete
ch = stream.next();
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
if ( tests.digit.test(ch) ) {
[148] Fix | Delete
stream.eat(ch);
[149] Fix | Delete
stream.eatWhile(tests.digit);
[150] Fix | Delete
[151] Fix | Delete
if ( '.' == stream.peek() ) {
[152] Fix | Delete
stream.eat('.');
[153] Fix | Delete
stream.eatWhile(tests.digit);
[154] Fix | Delete
} else if ('/' == stream.peek() ) {
[155] Fix | Delete
stream.eat('/');
[156] Fix | Delete
stream.eatWhile(tests.digit);
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if ( stream.eat(tests.exponent) ) {
[160] Fix | Delete
stream.eat(tests.sign);
[161] Fix | Delete
stream.eatWhile(tests.digit);
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
return true;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
return false;
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
// Eat character that starts after backslash \
[171] Fix | Delete
function eatCharacter(stream) {
[172] Fix | Delete
var first = stream.next();
[173] Fix | Delete
// Read special literals: backspace, newline, space, return.
[174] Fix | Delete
// Just read all lowercase letters.
[175] Fix | Delete
if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
[176] Fix | Delete
return;
[177] Fix | Delete
}
[178] Fix | Delete
// Read unicode character: \u1000 \uA0a1
[179] Fix | Delete
if (first === "u") {
[180] Fix | Delete
stream.match(/[0-9a-z]{4}/i, true);
[181] Fix | Delete
}
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
return {
[185] Fix | Delete
startState: function () {
[186] Fix | Delete
return {
[187] Fix | Delete
indentStack: null,
[188] Fix | Delete
indentation: 0,
[189] Fix | Delete
mode: false
[190] Fix | Delete
};
[191] Fix | Delete
},
[192] Fix | Delete
[193] Fix | Delete
token: function (stream, state) {
[194] Fix | Delete
if (state.indentStack == null && stream.sol()) {
[195] Fix | Delete
// update indentation, but only if indentStack is empty
[196] Fix | Delete
state.indentation = stream.indentation();
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
// skip spaces
[200] Fix | Delete
if (state.mode != "string" && stream.eatSpace()) {
[201] Fix | Delete
return null;
[202] Fix | Delete
}
[203] Fix | Delete
var returnType = null;
[204] Fix | Delete
[205] Fix | Delete
switch(state.mode){
[206] Fix | Delete
case "string": // multi-line string parsing mode
[207] Fix | Delete
var next, escaped = false;
[208] Fix | Delete
while ((next = stream.next()) != null) {
[209] Fix | Delete
if (next == "\"" && !escaped) {
[210] Fix | Delete
[211] Fix | Delete
state.mode = false;
[212] Fix | Delete
break;
[213] Fix | Delete
}
[214] Fix | Delete
escaped = !escaped && next == "\\";
[215] Fix | Delete
}
[216] Fix | Delete
returnType = STRING; // continue on in string mode
[217] Fix | Delete
break;
[218] Fix | Delete
default: // default parsing mode
[219] Fix | Delete
var ch = stream.next();
[220] Fix | Delete
[221] Fix | Delete
if (ch == "\"") {
[222] Fix | Delete
state.mode = "string";
[223] Fix | Delete
returnType = STRING;
[224] Fix | Delete
} else if (ch == "\\") {
[225] Fix | Delete
eatCharacter(stream);
[226] Fix | Delete
returnType = CHARACTER;
[227] Fix | Delete
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
[228] Fix | Delete
returnType = ATOM;
[229] Fix | Delete
} else if (ch == ";") { // comment
[230] Fix | Delete
stream.skipToEnd(); // rest of the line is a comment
[231] Fix | Delete
returnType = COMMENT;
[232] Fix | Delete
} else if (isNumber(ch,stream)){
[233] Fix | Delete
returnType = NUMBER;
[234] Fix | Delete
} else if (ch == "(" || ch == "[" || ch == "{" ) {
[235] Fix | Delete
var keyWord = '', indentTemp = stream.column(), letter;
[236] Fix | Delete
/**
[237] Fix | Delete
Either
[238] Fix | Delete
(indent-word ..
[239] Fix | Delete
(non-indent-word ..
[240] Fix | Delete
(;something else, bracket, etc.
[241] Fix | Delete
*/
[242] Fix | Delete
[243] Fix | Delete
if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
[244] Fix | Delete
keyWord += letter;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
[248] Fix | Delete
tests.block_indent.test(keyWord))) { // indent-word
[249] Fix | Delete
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
[250] Fix | Delete
} else { // non-indent word
[251] Fix | Delete
// we continue eating the spaces
[252] Fix | Delete
stream.eatSpace();
[253] Fix | Delete
if (stream.eol() || stream.peek() == ";") {
[254] Fix | Delete
// nothing significant after
[255] Fix | Delete
// we restart indentation the user defined spaces after
[256] Fix | Delete
pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch);
[257] Fix | Delete
} else {
[258] Fix | Delete
pushStack(state, indentTemp + stream.current().length, ch); // else we match
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
stream.backUp(stream.current().length - 1); // undo all the eating
[262] Fix | Delete
[263] Fix | Delete
returnType = BRACKET;
[264] Fix | Delete
} else if (ch == ")" || ch == "]" || ch == "}") {
[265] Fix | Delete
returnType = BRACKET;
[266] Fix | Delete
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) {
[267] Fix | Delete
popStack(state);
[268] Fix | Delete
}
[269] Fix | Delete
} else if ( ch == ":" ) {
[270] Fix | Delete
stream.eatWhile(tests.symbol);
[271] Fix | Delete
return ATOM;
[272] Fix | Delete
} else {
[273] Fix | Delete
stream.eatWhile(tests.symbol);
[274] Fix | Delete
[275] Fix | Delete
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
[276] Fix | Delete
returnType = KEYWORD;
[277] Fix | Delete
} else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
[278] Fix | Delete
returnType = BUILTIN;
[279] Fix | Delete
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
[280] Fix | Delete
returnType = ATOM;
[281] Fix | Delete
} else {
[282] Fix | Delete
returnType = VAR;
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
return returnType;
[288] Fix | Delete
},
[289] Fix | Delete
[290] Fix | Delete
indent: function (state) {
[291] Fix | Delete
if (state.indentStack == null) return state.indentation;
[292] Fix | Delete
return state.indentStack.indent;
[293] Fix | Delete
},
[294] Fix | Delete
[295] Fix | Delete
closeBrackets: {pairs: "()[]{}\"\""},
[296] Fix | Delete
lineComment: ";;"
[297] Fix | Delete
};
[298] Fix | Delete
});
[299] Fix | Delete
[300] Fix | Delete
CodeMirror.defineMIME("text/x-clojure", "clojure");
[301] Fix | Delete
CodeMirror.defineMIME("text/x-clojurescript", "clojure");
[302] Fix | Delete
CodeMirror.defineMIME("application/edn", "clojure");
[303] Fix | Delete
[304] Fix | Delete
});
[305] Fix | Delete
[306] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function