Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/haxe
File: haxe.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("haxe", function(config, parserConfig) {
[13] Fix | Delete
var indentUnit = config.indentUnit;
[14] Fix | Delete
[15] Fix | Delete
// Tokenizer
[16] Fix | Delete
[17] Fix | Delete
function kw(type) {return {type: type, style: "keyword"};}
[18] Fix | Delete
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
[19] Fix | Delete
var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
[20] Fix | Delete
var type = kw("typedef");
[21] Fix | Delete
var keywords = {
[22] Fix | Delete
"if": A, "while": A, "else": B, "do": B, "try": B,
[23] Fix | Delete
"return": C, "break": C, "continue": C, "new": C, "throw": C,
[24] Fix | Delete
"var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
[25] Fix | Delete
"public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
[26] Fix | Delete
"function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
[27] Fix | Delete
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
[28] Fix | Delete
"in": operator, "never": kw("property_access"), "trace":kw("trace"),
[29] Fix | Delete
"class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
[30] Fix | Delete
"true": atom, "false": atom, "null": atom
[31] Fix | Delete
};
[32] Fix | Delete
[33] Fix | Delete
var isOperatorChar = /[+\-*&%=<>!?|]/;
[34] Fix | Delete
[35] Fix | Delete
function chain(stream, state, f) {
[36] Fix | Delete
state.tokenize = f;
[37] Fix | Delete
return f(stream, state);
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
function toUnescaped(stream, end) {
[41] Fix | Delete
var escaped = false, next;
[42] Fix | Delete
while ((next = stream.next()) != null) {
[43] Fix | Delete
if (next == end && !escaped)
[44] Fix | Delete
return true;
[45] Fix | Delete
escaped = !escaped && next == "\\";
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
// Used as scratch variables to communicate multiple values without
[50] Fix | Delete
// consing up tons of objects.
[51] Fix | Delete
var type, content;
[52] Fix | Delete
function ret(tp, style, cont) {
[53] Fix | Delete
type = tp; content = cont;
[54] Fix | Delete
return style;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
function haxeTokenBase(stream, state) {
[58] Fix | Delete
var ch = stream.next();
[59] Fix | Delete
if (ch == '"' || ch == "'") {
[60] Fix | Delete
return chain(stream, state, haxeTokenString(ch));
[61] Fix | Delete
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
[62] Fix | Delete
return ret(ch);
[63] Fix | Delete
} else if (ch == "0" && stream.eat(/x/i)) {
[64] Fix | Delete
stream.eatWhile(/[\da-f]/i);
[65] Fix | Delete
return ret("number", "number");
[66] Fix | Delete
} else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
[67] Fix | Delete
stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
[68] Fix | Delete
return ret("number", "number");
[69] Fix | Delete
} else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
[70] Fix | Delete
toUnescaped(stream, "/");
[71] Fix | Delete
stream.eatWhile(/[gimsu]/);
[72] Fix | Delete
return ret("regexp", "string-2");
[73] Fix | Delete
} else if (ch == "/") {
[74] Fix | Delete
if (stream.eat("*")) {
[75] Fix | Delete
return chain(stream, state, haxeTokenComment);
[76] Fix | Delete
} else if (stream.eat("/")) {
[77] Fix | Delete
stream.skipToEnd();
[78] Fix | Delete
return ret("comment", "comment");
[79] Fix | Delete
} else {
[80] Fix | Delete
stream.eatWhile(isOperatorChar);
[81] Fix | Delete
return ret("operator", null, stream.current());
[82] Fix | Delete
}
[83] Fix | Delete
} else if (ch == "#") {
[84] Fix | Delete
stream.skipToEnd();
[85] Fix | Delete
return ret("conditional", "meta");
[86] Fix | Delete
} else if (ch == "@") {
[87] Fix | Delete
stream.eat(/:/);
[88] Fix | Delete
stream.eatWhile(/[\w_]/);
[89] Fix | Delete
return ret ("metadata", "meta");
[90] Fix | Delete
} else if (isOperatorChar.test(ch)) {
[91] Fix | Delete
stream.eatWhile(isOperatorChar);
[92] Fix | Delete
return ret("operator", null, stream.current());
[93] Fix | Delete
} else {
[94] Fix | Delete
var word;
[95] Fix | Delete
if(/[A-Z]/.test(ch)) {
[96] Fix | Delete
stream.eatWhile(/[\w_<>]/);
[97] Fix | Delete
word = stream.current();
[98] Fix | Delete
return ret("type", "variable-3", word);
[99] Fix | Delete
} else {
[100] Fix | Delete
stream.eatWhile(/[\w_]/);
[101] Fix | Delete
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
[102] Fix | Delete
return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
[103] Fix | Delete
ret("variable", "variable", word);
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
function haxeTokenString(quote) {
[109] Fix | Delete
return function(stream, state) {
[110] Fix | Delete
if (toUnescaped(stream, quote))
[111] Fix | Delete
state.tokenize = haxeTokenBase;
[112] Fix | Delete
return ret("string", "string");
[113] Fix | Delete
};
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
function haxeTokenComment(stream, state) {
[117] Fix | Delete
var maybeEnd = false, ch;
[118] Fix | Delete
while (ch = stream.next()) {
[119] Fix | Delete
if (ch == "/" && maybeEnd) {
[120] Fix | Delete
state.tokenize = haxeTokenBase;
[121] Fix | Delete
break;
[122] Fix | Delete
}
[123] Fix | Delete
maybeEnd = (ch == "*");
[124] Fix | Delete
}
[125] Fix | Delete
return ret("comment", "comment");
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
// Parser
[129] Fix | Delete
[130] Fix | Delete
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
[131] Fix | Delete
[132] Fix | Delete
function HaxeLexical(indented, column, type, align, prev, info) {
[133] Fix | Delete
this.indented = indented;
[134] Fix | Delete
this.column = column;
[135] Fix | Delete
this.type = type;
[136] Fix | Delete
this.prev = prev;
[137] Fix | Delete
this.info = info;
[138] Fix | Delete
if (align != null) this.align = align;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
function inScope(state, varname) {
[142] Fix | Delete
for (var v = state.localVars; v; v = v.next)
[143] Fix | Delete
if (v.name == varname) return true;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
function parseHaxe(state, style, type, content, stream) {
[147] Fix | Delete
var cc = state.cc;
[148] Fix | Delete
// Communicate our context to the combinators.
[149] Fix | Delete
// (Less wasteful than consing up a hundred closures on every call.)
[150] Fix | Delete
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
[151] Fix | Delete
[152] Fix | Delete
if (!state.lexical.hasOwnProperty("align"))
[153] Fix | Delete
state.lexical.align = true;
[154] Fix | Delete
[155] Fix | Delete
while(true) {
[156] Fix | Delete
var combinator = cc.length ? cc.pop() : statement;
[157] Fix | Delete
if (combinator(type, content)) {
[158] Fix | Delete
while(cc.length && cc[cc.length - 1].lex)
[159] Fix | Delete
cc.pop()();
[160] Fix | Delete
if (cx.marked) return cx.marked;
[161] Fix | Delete
if (type == "variable" && inScope(state, content)) return "variable-2";
[162] Fix | Delete
if (type == "variable" && imported(state, content)) return "variable-3";
[163] Fix | Delete
return style;
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
function imported(state, typename) {
[169] Fix | Delete
if (/[a-z]/.test(typename.charAt(0)))
[170] Fix | Delete
return false;
[171] Fix | Delete
var len = state.importedtypes.length;
[172] Fix | Delete
for (var i = 0; i<len; i++)
[173] Fix | Delete
if(state.importedtypes[i]==typename) return true;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
function registerimport(importname) {
[177] Fix | Delete
var state = cx.state;
[178] Fix | Delete
for (var t = state.importedtypes; t; t = t.next)
[179] Fix | Delete
if(t.name == importname) return;
[180] Fix | Delete
state.importedtypes = { name: importname, next: state.importedtypes };
[181] Fix | Delete
}
[182] Fix | Delete
// Combinator utils
[183] Fix | Delete
[184] Fix | Delete
var cx = {state: null, column: null, marked: null, cc: null};
[185] Fix | Delete
function pass() {
[186] Fix | Delete
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
[187] Fix | Delete
}
[188] Fix | Delete
function cont() {
[189] Fix | Delete
pass.apply(null, arguments);
[190] Fix | Delete
return true;
[191] Fix | Delete
}
[192] Fix | Delete
function inList(name, list) {
[193] Fix | Delete
for (var v = list; v; v = v.next)
[194] Fix | Delete
if (v.name == name) return true;
[195] Fix | Delete
return false;
[196] Fix | Delete
}
[197] Fix | Delete
function register(varname) {
[198] Fix | Delete
var state = cx.state;
[199] Fix | Delete
if (state.context) {
[200] Fix | Delete
cx.marked = "def";
[201] Fix | Delete
if (inList(varname, state.localVars)) return;
[202] Fix | Delete
state.localVars = {name: varname, next: state.localVars};
[203] Fix | Delete
} else if (state.globalVars) {
[204] Fix | Delete
if (inList(varname, state.globalVars)) return;
[205] Fix | Delete
state.globalVars = {name: varname, next: state.globalVars};
[206] Fix | Delete
}
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// Combinators
[210] Fix | Delete
[211] Fix | Delete
var defaultVars = {name: "this", next: null};
[212] Fix | Delete
function pushcontext() {
[213] Fix | Delete
if (!cx.state.context) cx.state.localVars = defaultVars;
[214] Fix | Delete
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
[215] Fix | Delete
}
[216] Fix | Delete
function popcontext() {
[217] Fix | Delete
cx.state.localVars = cx.state.context.vars;
[218] Fix | Delete
cx.state.context = cx.state.context.prev;
[219] Fix | Delete
}
[220] Fix | Delete
popcontext.lex = true;
[221] Fix | Delete
function pushlex(type, info) {
[222] Fix | Delete
var result = function() {
[223] Fix | Delete
var state = cx.state;
[224] Fix | Delete
state.lexical = new HaxeLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
[225] Fix | Delete
};
[226] Fix | Delete
result.lex = true;
[227] Fix | Delete
return result;
[228] Fix | Delete
}
[229] Fix | Delete
function poplex() {
[230] Fix | Delete
var state = cx.state;
[231] Fix | Delete
if (state.lexical.prev) {
[232] Fix | Delete
if (state.lexical.type == ")")
[233] Fix | Delete
state.indented = state.lexical.indented;
[234] Fix | Delete
state.lexical = state.lexical.prev;
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
poplex.lex = true;
[238] Fix | Delete
[239] Fix | Delete
function expect(wanted) {
[240] Fix | Delete
function f(type) {
[241] Fix | Delete
if (type == wanted) return cont();
[242] Fix | Delete
else if (wanted == ";") return pass();
[243] Fix | Delete
else return cont(f);
[244] Fix | Delete
}
[245] Fix | Delete
return f;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
function statement(type) {
[249] Fix | Delete
if (type == "@") return cont(metadef);
[250] Fix | Delete
if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
[251] Fix | Delete
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
[252] Fix | Delete
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
[253] Fix | Delete
if (type == "{") return cont(pushlex("}"), pushcontext, block, poplex, popcontext);
[254] Fix | Delete
if (type == ";") return cont();
[255] Fix | Delete
if (type == "attribute") return cont(maybeattribute);
[256] Fix | Delete
if (type == "function") return cont(functiondef);
[257] Fix | Delete
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
[258] Fix | Delete
poplex, statement, poplex);
[259] Fix | Delete
if (type == "variable") return cont(pushlex("stat"), maybelabel);
[260] Fix | Delete
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
[261] Fix | Delete
block, poplex, poplex);
[262] Fix | Delete
if (type == "case") return cont(expression, expect(":"));
[263] Fix | Delete
if (type == "default") return cont(expect(":"));
[264] Fix | Delete
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
[265] Fix | Delete
statement, poplex, popcontext);
[266] Fix | Delete
if (type == "import") return cont(importdef, expect(";"));
[267] Fix | Delete
if (type == "typedef") return cont(typedef);
[268] Fix | Delete
return pass(pushlex("stat"), expression, expect(";"), poplex);
[269] Fix | Delete
}
[270] Fix | Delete
function expression(type) {
[271] Fix | Delete
if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
[272] Fix | Delete
if (type == "type" ) return cont(maybeoperator);
[273] Fix | Delete
if (type == "function") return cont(functiondef);
[274] Fix | Delete
if (type == "keyword c") return cont(maybeexpression);
[275] Fix | Delete
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
[276] Fix | Delete
if (type == "operator") return cont(expression);
[277] Fix | Delete
if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
[278] Fix | Delete
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
[279] Fix | Delete
return cont();
[280] Fix | Delete
}
[281] Fix | Delete
function maybeexpression(type) {
[282] Fix | Delete
if (type.match(/[;\}\)\],]/)) return pass();
[283] Fix | Delete
return pass(expression);
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
function maybeoperator(type, value) {
[287] Fix | Delete
if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
[288] Fix | Delete
if (type == "operator" || type == ":") return cont(expression);
[289] Fix | Delete
if (type == ";") return;
[290] Fix | Delete
if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
[291] Fix | Delete
if (type == ".") return cont(property, maybeoperator);
[292] Fix | Delete
if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
function maybeattribute(type) {
[296] Fix | Delete
if (type == "attribute") return cont(maybeattribute);
[297] Fix | Delete
if (type == "function") return cont(functiondef);
[298] Fix | Delete
if (type == "var") return cont(vardef1);
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
function metadef(type) {
[302] Fix | Delete
if(type == ":") return cont(metadef);
[303] Fix | Delete
if(type == "variable") return cont(metadef);
[304] Fix | Delete
if(type == "(") return cont(pushlex(")"), commasep(metaargs, ")"), poplex, statement);
[305] Fix | Delete
}
[306] Fix | Delete
function metaargs(type) {
[307] Fix | Delete
if(type == "variable") return cont();
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
function importdef (type, value) {
[311] Fix | Delete
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
[312] Fix | Delete
else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
function typedef (type, value)
[316] Fix | Delete
{
[317] Fix | Delete
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
[318] Fix | Delete
else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
function maybelabel(type) {
[322] Fix | Delete
if (type == ":") return cont(poplex, statement);
[323] Fix | Delete
return pass(maybeoperator, expect(";"), poplex);
[324] Fix | Delete
}
[325] Fix | Delete
function property(type) {
[326] Fix | Delete
if (type == "variable") {cx.marked = "property"; return cont();}
[327] Fix | Delete
}
[328] Fix | Delete
function objprop(type) {
[329] Fix | Delete
if (type == "variable") cx.marked = "property";
[330] Fix | Delete
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
[331] Fix | Delete
}
[332] Fix | Delete
function commasep(what, end) {
[333] Fix | Delete
function proceed(type) {
[334] Fix | Delete
if (type == ",") return cont(what, proceed);
[335] Fix | Delete
if (type == end) return cont();
[336] Fix | Delete
return cont(expect(end));
[337] Fix | Delete
}
[338] Fix | Delete
return function(type) {
[339] Fix | Delete
if (type == end) return cont();
[340] Fix | Delete
else return pass(what, proceed);
[341] Fix | Delete
};
[342] Fix | Delete
}
[343] Fix | Delete
function block(type) {
[344] Fix | Delete
if (type == "}") return cont();
[345] Fix | Delete
return pass(statement, block);
[346] Fix | Delete
}
[347] Fix | Delete
function vardef1(type, value) {
[348] Fix | Delete
if (type == "variable"){register(value); return cont(typeuse, vardef2);}
[349] Fix | Delete
return cont();
[350] Fix | Delete
}
[351] Fix | Delete
function vardef2(type, value) {
[352] Fix | Delete
if (value == "=") return cont(expression, vardef2);
[353] Fix | Delete
if (type == ",") return cont(vardef1);
[354] Fix | Delete
}
[355] Fix | Delete
function forspec1(type, value) {
[356] Fix | Delete
if (type == "variable") {
[357] Fix | Delete
register(value);
[358] Fix | Delete
return cont(forin, expression)
[359] Fix | Delete
} else {
[360] Fix | Delete
return pass()
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
function forin(_type, value) {
[364] Fix | Delete
if (value == "in") return cont();
[365] Fix | Delete
}
[366] Fix | Delete
function functiondef(type, value) {
[367] Fix | Delete
//function names starting with upper-case letters are recognised as types, so cludging them together here.
[368] Fix | Delete
if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
[369] Fix | Delete
if (value == "new") return cont(functiondef);
[370] Fix | Delete
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
[371] Fix | Delete
}
[372] Fix | Delete
function typeuse(type) {
[373] Fix | Delete
if(type == ":") return cont(typestring);
[374] Fix | Delete
}
[375] Fix | Delete
function typestring(type) {
[376] Fix | Delete
if(type == "type") return cont();
[377] Fix | Delete
if(type == "variable") return cont();
[378] Fix | Delete
if(type == "{") return cont(pushlex("}"), commasep(typeprop, "}"), poplex);
[379] Fix | Delete
}
[380] Fix | Delete
function typeprop(type) {
[381] Fix | Delete
if(type == "variable") return cont(typeuse);
[382] Fix | Delete
}
[383] Fix | Delete
function funarg(type, value) {
[384] Fix | Delete
if (type == "variable") {register(value); return cont(typeuse);}
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
// Interface
[388] Fix | Delete
return {
[389] Fix | Delete
startState: function(basecolumn) {
[390] Fix | Delete
var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
[391] Fix | Delete
var state = {
[392] Fix | Delete
tokenize: haxeTokenBase,
[393] Fix | Delete
reAllowed: true,
[394] Fix | Delete
kwAllowed: true,
[395] Fix | Delete
cc: [],
[396] Fix | Delete
lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
[397] Fix | Delete
localVars: parserConfig.localVars,
[398] Fix | Delete
importedtypes: defaulttypes,
[399] Fix | Delete
context: parserConfig.localVars && {vars: parserConfig.localVars},
[400] Fix | Delete
indented: 0
[401] Fix | Delete
};
[402] Fix | Delete
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
[403] Fix | Delete
state.globalVars = parserConfig.globalVars;
[404] Fix | Delete
return state;
[405] Fix | Delete
},
[406] Fix | Delete
[407] Fix | Delete
token: function(stream, state) {
[408] Fix | Delete
if (stream.sol()) {
[409] Fix | Delete
if (!state.lexical.hasOwnProperty("align"))
[410] Fix | Delete
state.lexical.align = false;
[411] Fix | Delete
state.indented = stream.indentation();
[412] Fix | Delete
}
[413] Fix | Delete
if (stream.eatSpace()) return null;
[414] Fix | Delete
var style = state.tokenize(stream, state);
[415] Fix | Delete
if (type == "comment") return style;
[416] Fix | Delete
state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
[417] Fix | Delete
state.kwAllowed = type != '.';
[418] Fix | Delete
return parseHaxe(state, style, type, content, stream);
[419] Fix | Delete
},
[420] Fix | Delete
[421] Fix | Delete
indent: function(state, textAfter) {
[422] Fix | Delete
if (state.tokenize != haxeTokenBase) return 0;
[423] Fix | Delete
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
[424] Fix | Delete
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
[425] Fix | Delete
var type = lexical.type, closing = firstChar == type;
[426] Fix | Delete
if (type == "vardef") return lexical.indented + 4;
[427] Fix | Delete
else if (type == "form" && firstChar == "{") return lexical.indented;
[428] Fix | Delete
else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
[429] Fix | Delete
else if (lexical.info == "switch" && !closing)
[430] Fix | Delete
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
[431] Fix | Delete
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
[432] Fix | Delete
else return lexical.indented + (closing ? 0 : indentUnit);
[433] Fix | Delete
},
[434] Fix | Delete
[435] Fix | Delete
electricChars: "{}",
[436] Fix | Delete
blockCommentStart: "/*",
[437] Fix | Delete
blockCommentEnd: "*/",
[438] Fix | Delete
lineComment: "//"
[439] Fix | Delete
};
[440] Fix | Delete
});
[441] Fix | Delete
[442] Fix | Delete
CodeMirror.defineMIME("text/x-haxe", "haxe");
[443] Fix | Delete
[444] Fix | Delete
CodeMirror.defineMode("hxml", function () {
[445] Fix | Delete
[446] Fix | Delete
return {
[447] Fix | Delete
startState: function () {
[448] Fix | Delete
return {
[449] Fix | Delete
define: false,
[450] Fix | Delete
inString: false
[451] Fix | Delete
};
[452] Fix | Delete
},
[453] Fix | Delete
token: function (stream, state) {
[454] Fix | Delete
var ch = stream.peek();
[455] Fix | Delete
var sol = stream.sol();
[456] Fix | Delete
[457] Fix | Delete
///* comments */
[458] Fix | Delete
if (ch == "#") {
[459] Fix | Delete
stream.skipToEnd();
[460] Fix | Delete
return "comment";
[461] Fix | Delete
}
[462] Fix | Delete
if (sol && ch == "-") {
[463] Fix | Delete
var style = "variable-2";
[464] Fix | Delete
[465] Fix | Delete
stream.eat(/-/);
[466] Fix | Delete
[467] Fix | Delete
if (stream.peek() == "-") {
[468] Fix | Delete
stream.eat(/-/);
[469] Fix | Delete
style = "keyword a";
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
if (stream.peek() == "D") {
[473] Fix | Delete
stream.eat(/[D]/);
[474] Fix | Delete
style = "keyword c";
[475] Fix | Delete
state.define = true;
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
stream.eatWhile(/[A-Z]/i);
[479] Fix | Delete
return style;
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
var ch = stream.peek();
[483] Fix | Delete
[484] Fix | Delete
if (state.inString == false && ch == "'") {
[485] Fix | Delete
state.inString = true;
[486] Fix | Delete
ch = stream.next();
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
if (state.inString == true) {
[490] Fix | Delete
if (stream.skipTo("'")) {
[491] Fix | Delete
[492] Fix | Delete
} else {
[493] Fix | Delete
stream.skipToEnd();
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
if (stream.peek() == "'") {
[497] Fix | Delete
stream.next();
[498] Fix | Delete
state.inString = false;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function