Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/dylan
File: dylan.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
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
CodeMirror.defineMode("dylan", function(_config) {
[13] Fix | Delete
// Words
[14] Fix | Delete
var words = {
[15] Fix | Delete
// Words that introduce unnamed definitions like "define interface"
[16] Fix | Delete
unnamedDefinition: ["interface"],
[17] Fix | Delete
[18] Fix | Delete
// Words that introduce simple named definitions like "define library"
[19] Fix | Delete
namedDefinition: ["module", "library", "macro",
[20] Fix | Delete
"C-struct", "C-union",
[21] Fix | Delete
"C-function", "C-callable-wrapper"
[22] Fix | Delete
],
[23] Fix | Delete
[24] Fix | Delete
// Words that introduce type definitions like "define class".
[25] Fix | Delete
// These are also parameterized like "define method" and are
[26] Fix | Delete
// appended to otherParameterizedDefinitionWords
[27] Fix | Delete
typeParameterizedDefinition: ["class", "C-subtype", "C-mapped-subtype"],
[28] Fix | Delete
[29] Fix | Delete
// Words that introduce trickier definitions like "define method".
[30] Fix | Delete
// These require special definitions to be added to startExpressions
[31] Fix | Delete
otherParameterizedDefinition: ["method", "function",
[32] Fix | Delete
"C-variable", "C-address"
[33] Fix | Delete
],
[34] Fix | Delete
[35] Fix | Delete
// Words that introduce module constant definitions.
[36] Fix | Delete
// These must also be simple definitions and are
[37] Fix | Delete
// appended to otherSimpleDefinitionWords
[38] Fix | Delete
constantSimpleDefinition: ["constant"],
[39] Fix | Delete
[40] Fix | Delete
// Words that introduce module variable definitions.
[41] Fix | Delete
// These must also be simple definitions and are
[42] Fix | Delete
// appended to otherSimpleDefinitionWords
[43] Fix | Delete
variableSimpleDefinition: ["variable"],
[44] Fix | Delete
[45] Fix | Delete
// Other words that introduce simple definitions
[46] Fix | Delete
// (without implicit bodies).
[47] Fix | Delete
otherSimpleDefinition: ["generic", "domain",
[48] Fix | Delete
"C-pointer-type",
[49] Fix | Delete
"table"
[50] Fix | Delete
],
[51] Fix | Delete
[52] Fix | Delete
// Words that begin statements with implicit bodies.
[53] Fix | Delete
statement: ["if", "block", "begin", "method", "case",
[54] Fix | Delete
"for", "select", "when", "unless", "until",
[55] Fix | Delete
"while", "iterate", "profiling", "dynamic-bind"
[56] Fix | Delete
],
[57] Fix | Delete
[58] Fix | Delete
// Patterns that act as separators in compound statements.
[59] Fix | Delete
// This may include any general pattern that must be indented
[60] Fix | Delete
// specially.
[61] Fix | Delete
separator: ["finally", "exception", "cleanup", "else",
[62] Fix | Delete
"elseif", "afterwards"
[63] Fix | Delete
],
[64] Fix | Delete
[65] Fix | Delete
// Keywords that do not require special indentation handling,
[66] Fix | Delete
// but which should be highlighted
[67] Fix | Delete
other: ["above", "below", "by", "from", "handler", "in",
[68] Fix | Delete
"instance", "let", "local", "otherwise", "slot",
[69] Fix | Delete
"subclass", "then", "to", "keyed-by", "virtual"
[70] Fix | Delete
],
[71] Fix | Delete
[72] Fix | Delete
// Condition signaling function calls
[73] Fix | Delete
signalingCalls: ["signal", "error", "cerror",
[74] Fix | Delete
"break", "check-type", "abort"
[75] Fix | Delete
]
[76] Fix | Delete
};
[77] Fix | Delete
[78] Fix | Delete
words["otherDefinition"] =
[79] Fix | Delete
words["unnamedDefinition"]
[80] Fix | Delete
.concat(words["namedDefinition"])
[81] Fix | Delete
.concat(words["otherParameterizedDefinition"]);
[82] Fix | Delete
[83] Fix | Delete
words["definition"] =
[84] Fix | Delete
words["typeParameterizedDefinition"]
[85] Fix | Delete
.concat(words["otherDefinition"]);
[86] Fix | Delete
[87] Fix | Delete
words["parameterizedDefinition"] =
[88] Fix | Delete
words["typeParameterizedDefinition"]
[89] Fix | Delete
.concat(words["otherParameterizedDefinition"]);
[90] Fix | Delete
[91] Fix | Delete
words["simpleDefinition"] =
[92] Fix | Delete
words["constantSimpleDefinition"]
[93] Fix | Delete
.concat(words["variableSimpleDefinition"])
[94] Fix | Delete
.concat(words["otherSimpleDefinition"]);
[95] Fix | Delete
[96] Fix | Delete
words["keyword"] =
[97] Fix | Delete
words["statement"]
[98] Fix | Delete
.concat(words["separator"])
[99] Fix | Delete
.concat(words["other"]);
[100] Fix | Delete
[101] Fix | Delete
// Patterns
[102] Fix | Delete
var symbolPattern = "[-_a-zA-Z?!*@<>$%]+";
[103] Fix | Delete
var symbol = new RegExp("^" + symbolPattern);
[104] Fix | Delete
var patterns = {
[105] Fix | Delete
// Symbols with special syntax
[106] Fix | Delete
symbolKeyword: symbolPattern + ":",
[107] Fix | Delete
symbolClass: "<" + symbolPattern + ">",
[108] Fix | Delete
symbolGlobal: "\\*" + symbolPattern + "\\*",
[109] Fix | Delete
symbolConstant: "\\$" + symbolPattern
[110] Fix | Delete
};
[111] Fix | Delete
var patternStyles = {
[112] Fix | Delete
symbolKeyword: "atom",
[113] Fix | Delete
symbolClass: "tag",
[114] Fix | Delete
symbolGlobal: "variable-2",
[115] Fix | Delete
symbolConstant: "variable-3"
[116] Fix | Delete
};
[117] Fix | Delete
[118] Fix | Delete
// Compile all patterns to regular expressions
[119] Fix | Delete
for (var patternName in patterns)
[120] Fix | Delete
if (patterns.hasOwnProperty(patternName))
[121] Fix | Delete
patterns[patternName] = new RegExp("^" + patterns[patternName]);
[122] Fix | Delete
[123] Fix | Delete
// Names beginning "with-" and "without-" are commonly
[124] Fix | Delete
// used as statement macro
[125] Fix | Delete
patterns["keyword"] = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
[126] Fix | Delete
[127] Fix | Delete
var styles = {};
[128] Fix | Delete
styles["keyword"] = "keyword";
[129] Fix | Delete
styles["definition"] = "def";
[130] Fix | Delete
styles["simpleDefinition"] = "def";
[131] Fix | Delete
styles["signalingCalls"] = "builtin";
[132] Fix | Delete
[133] Fix | Delete
// protected words lookup table
[134] Fix | Delete
var wordLookup = {};
[135] Fix | Delete
var styleLookup = {};
[136] Fix | Delete
[137] Fix | Delete
[
[138] Fix | Delete
"keyword",
[139] Fix | Delete
"definition",
[140] Fix | Delete
"simpleDefinition",
[141] Fix | Delete
"signalingCalls"
[142] Fix | Delete
].forEach(function(type) {
[143] Fix | Delete
words[type].forEach(function(word) {
[144] Fix | Delete
wordLookup[word] = type;
[145] Fix | Delete
styleLookup[word] = styles[type];
[146] Fix | Delete
});
[147] Fix | Delete
});
[148] Fix | Delete
[149] Fix | Delete
[150] Fix | Delete
function chain(stream, state, f) {
[151] Fix | Delete
state.tokenize = f;
[152] Fix | Delete
return f(stream, state);
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
function tokenBase(stream, state) {
[156] Fix | Delete
// String
[157] Fix | Delete
var ch = stream.peek();
[158] Fix | Delete
if (ch == "'" || ch == '"') {
[159] Fix | Delete
stream.next();
[160] Fix | Delete
return chain(stream, state, tokenString(ch, "string"));
[161] Fix | Delete
}
[162] Fix | Delete
// Comment
[163] Fix | Delete
else if (ch == "/") {
[164] Fix | Delete
stream.next();
[165] Fix | Delete
if (stream.eat("*")) {
[166] Fix | Delete
return chain(stream, state, tokenComment);
[167] Fix | Delete
} else if (stream.eat("/")) {
[168] Fix | Delete
stream.skipToEnd();
[169] Fix | Delete
return "comment";
[170] Fix | Delete
}
[171] Fix | Delete
stream.backUp(1);
[172] Fix | Delete
}
[173] Fix | Delete
// Decimal
[174] Fix | Delete
else if (/[+\-\d\.]/.test(ch)) {
[175] Fix | Delete
if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) ||
[176] Fix | Delete
stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) ||
[177] Fix | Delete
stream.match(/^[+-]?\d+/)) {
[178] Fix | Delete
return "number";
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
// Hash
[182] Fix | Delete
else if (ch == "#") {
[183] Fix | Delete
stream.next();
[184] Fix | Delete
// Symbol with string syntax
[185] Fix | Delete
ch = stream.peek();
[186] Fix | Delete
if (ch == '"') {
[187] Fix | Delete
stream.next();
[188] Fix | Delete
return chain(stream, state, tokenString('"', "string"));
[189] Fix | Delete
}
[190] Fix | Delete
// Binary number
[191] Fix | Delete
else if (ch == "b") {
[192] Fix | Delete
stream.next();
[193] Fix | Delete
stream.eatWhile(/[01]/);
[194] Fix | Delete
return "number";
[195] Fix | Delete
}
[196] Fix | Delete
// Hex number
[197] Fix | Delete
else if (ch == "x") {
[198] Fix | Delete
stream.next();
[199] Fix | Delete
stream.eatWhile(/[\da-f]/i);
[200] Fix | Delete
return "number";
[201] Fix | Delete
}
[202] Fix | Delete
// Octal number
[203] Fix | Delete
else if (ch == "o") {
[204] Fix | Delete
stream.next();
[205] Fix | Delete
stream.eatWhile(/[0-7]/);
[206] Fix | Delete
return "number";
[207] Fix | Delete
}
[208] Fix | Delete
// Token concatenation in macros
[209] Fix | Delete
else if (ch == '#') {
[210] Fix | Delete
stream.next();
[211] Fix | Delete
return "punctuation";
[212] Fix | Delete
}
[213] Fix | Delete
// Sequence literals
[214] Fix | Delete
else if ((ch == '[') || (ch == '(')) {
[215] Fix | Delete
stream.next();
[216] Fix | Delete
return "bracket";
[217] Fix | Delete
// Hash symbol
[218] Fix | Delete
} else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) {
[219] Fix | Delete
return "atom";
[220] Fix | Delete
} else {
[221] Fix | Delete
stream.eatWhile(/[-a-zA-Z]/);
[222] Fix | Delete
return "error";
[223] Fix | Delete
}
[224] Fix | Delete
} else if (ch == "~") {
[225] Fix | Delete
stream.next();
[226] Fix | Delete
ch = stream.peek();
[227] Fix | Delete
if (ch == "=") {
[228] Fix | Delete
stream.next();
[229] Fix | Delete
ch = stream.peek();
[230] Fix | Delete
if (ch == "=") {
[231] Fix | Delete
stream.next();
[232] Fix | Delete
return "operator";
[233] Fix | Delete
}
[234] Fix | Delete
return "operator";
[235] Fix | Delete
}
[236] Fix | Delete
return "operator";
[237] Fix | Delete
} else if (ch == ":") {
[238] Fix | Delete
stream.next();
[239] Fix | Delete
ch = stream.peek();
[240] Fix | Delete
if (ch == "=") {
[241] Fix | Delete
stream.next();
[242] Fix | Delete
return "operator";
[243] Fix | Delete
} else if (ch == ":") {
[244] Fix | Delete
stream.next();
[245] Fix | Delete
return "punctuation";
[246] Fix | Delete
}
[247] Fix | Delete
} else if ("[](){}".indexOf(ch) != -1) {
[248] Fix | Delete
stream.next();
[249] Fix | Delete
return "bracket";
[250] Fix | Delete
} else if (".,".indexOf(ch) != -1) {
[251] Fix | Delete
stream.next();
[252] Fix | Delete
return "punctuation";
[253] Fix | Delete
} else if (stream.match("end")) {
[254] Fix | Delete
return "keyword";
[255] Fix | Delete
}
[256] Fix | Delete
for (var name in patterns) {
[257] Fix | Delete
if (patterns.hasOwnProperty(name)) {
[258] Fix | Delete
var pattern = patterns[name];
[259] Fix | Delete
if ((pattern instanceof Array && pattern.some(function(p) {
[260] Fix | Delete
return stream.match(p);
[261] Fix | Delete
})) || stream.match(pattern))
[262] Fix | Delete
return patternStyles[name];
[263] Fix | Delete
}
[264] Fix | Delete
}
[265] Fix | Delete
if (/[+\-*\/^=<>&|]/.test(ch)) {
[266] Fix | Delete
stream.next();
[267] Fix | Delete
return "operator";
[268] Fix | Delete
}
[269] Fix | Delete
if (stream.match("define")) {
[270] Fix | Delete
return "def";
[271] Fix | Delete
} else {
[272] Fix | Delete
stream.eatWhile(/[\w\-]/);
[273] Fix | Delete
// Keyword
[274] Fix | Delete
if (wordLookup[stream.current()]) {
[275] Fix | Delete
return styleLookup[stream.current()];
[276] Fix | Delete
} else if (stream.current().match(symbol)) {
[277] Fix | Delete
return "variable";
[278] Fix | Delete
} else {
[279] Fix | Delete
stream.next();
[280] Fix | Delete
return "variable-2";
[281] Fix | Delete
}
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
function tokenComment(stream, state) {
[286] Fix | Delete
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
[287] Fix | Delete
while ((ch = stream.next())) {
[288] Fix | Delete
if (ch == "/" && maybeEnd) {
[289] Fix | Delete
if (nestedCount > 0) {
[290] Fix | Delete
nestedCount--;
[291] Fix | Delete
} else {
[292] Fix | Delete
state.tokenize = tokenBase;
[293] Fix | Delete
break;
[294] Fix | Delete
}
[295] Fix | Delete
} else if (ch == "*" && maybeNested) {
[296] Fix | Delete
nestedCount++;
[297] Fix | Delete
}
[298] Fix | Delete
maybeEnd = (ch == "*");
[299] Fix | Delete
maybeNested = (ch == "/");
[300] Fix | Delete
}
[301] Fix | Delete
return "comment";
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
function tokenString(quote, style) {
[305] Fix | Delete
return function(stream, state) {
[306] Fix | Delete
var escaped = false, next, end = false;
[307] Fix | Delete
while ((next = stream.next()) != null) {
[308] Fix | Delete
if (next == quote && !escaped) {
[309] Fix | Delete
end = true;
[310] Fix | Delete
break;
[311] Fix | Delete
}
[312] Fix | Delete
escaped = !escaped && next == "\\";
[313] Fix | Delete
}
[314] Fix | Delete
if (end || !escaped) {
[315] Fix | Delete
state.tokenize = tokenBase;
[316] Fix | Delete
}
[317] Fix | Delete
return style;
[318] Fix | Delete
};
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
// Interface
[322] Fix | Delete
return {
[323] Fix | Delete
startState: function() {
[324] Fix | Delete
return {
[325] Fix | Delete
tokenize: tokenBase,
[326] Fix | Delete
currentIndent: 0
[327] Fix | Delete
};
[328] Fix | Delete
},
[329] Fix | Delete
token: function(stream, state) {
[330] Fix | Delete
if (stream.eatSpace())
[331] Fix | Delete
return null;
[332] Fix | Delete
var style = state.tokenize(stream, state);
[333] Fix | Delete
return style;
[334] Fix | Delete
},
[335] Fix | Delete
blockCommentStart: "/*",
[336] Fix | Delete
blockCommentEnd: "*/"
[337] Fix | Delete
};
[338] Fix | Delete
});
[339] Fix | Delete
[340] Fix | Delete
CodeMirror.defineMIME("text/x-dylan", "dylan");
[341] Fix | Delete
[342] Fix | Delete
});
[343] Fix | Delete
[344] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function