Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/vhdl
File: vhdl.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
// Originally written by Alf Nielsen, re-written by Michael Zhou
[3] Fix | Delete
(function(mod) {
[4] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[5] Fix | Delete
mod(require("../../lib/codemirror"));
[6] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[7] Fix | Delete
define(["../../lib/codemirror"], mod);
[8] Fix | Delete
else // Plain browser env
[9] Fix | Delete
mod(CodeMirror);
[10] Fix | Delete
})(function(CodeMirror) {
[11] Fix | Delete
"use strict";
[12] Fix | Delete
[13] Fix | Delete
function words(str) {
[14] Fix | Delete
var obj = {}, words = str.split(",");
[15] Fix | Delete
for (var i = 0; i < words.length; ++i) {
[16] Fix | Delete
var allCaps = words[i].toUpperCase();
[17] Fix | Delete
var firstCap = words[i].charAt(0).toUpperCase() + words[i].slice(1);
[18] Fix | Delete
obj[words[i]] = true;
[19] Fix | Delete
obj[allCaps] = true;
[20] Fix | Delete
obj[firstCap] = true;
[21] Fix | Delete
}
[22] Fix | Delete
return obj;
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
function metaHook(stream) {
[26] Fix | Delete
stream.eatWhile(/[\w\$_]/);
[27] Fix | Delete
return "meta";
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
CodeMirror.defineMode("vhdl", function(config, parserConfig) {
[31] Fix | Delete
var indentUnit = config.indentUnit,
[32] Fix | Delete
atoms = parserConfig.atoms || words("null"),
[33] Fix | Delete
hooks = parserConfig.hooks || {"`": metaHook, "$": metaHook},
[34] Fix | Delete
multiLineStrings = parserConfig.multiLineStrings;
[35] Fix | Delete
[36] Fix | Delete
var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," +
[37] Fix | Delete
"body,buffer,bus,case,component,configuration,constant,disconnect,downto,else,elsif,end,end block,end case," +
[38] Fix | Delete
"end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for," +
[39] Fix | Delete
"function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage," +
[40] Fix | Delete
"literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map," +
[41] Fix | Delete
"postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal," +
[42] Fix | Delete
"sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor");
[43] Fix | Delete
[44] Fix | Delete
var blockKeywords = words("architecture,entity,begin,case,port,else,elsif,end,for,function,if");
[45] Fix | Delete
[46] Fix | Delete
var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
[47] Fix | Delete
var curPunc;
[48] Fix | Delete
[49] Fix | Delete
function tokenBase(stream, state) {
[50] Fix | Delete
var ch = stream.next();
[51] Fix | Delete
if (hooks[ch]) {
[52] Fix | Delete
var result = hooks[ch](stream, state);
[53] Fix | Delete
if (result !== false) return result;
[54] Fix | Delete
}
[55] Fix | Delete
if (ch == '"') {
[56] Fix | Delete
state.tokenize = tokenString2(ch);
[57] Fix | Delete
return state.tokenize(stream, state);
[58] Fix | Delete
}
[59] Fix | Delete
if (ch == "'") {
[60] Fix | Delete
state.tokenize = tokenString(ch);
[61] Fix | Delete
return state.tokenize(stream, state);
[62] Fix | Delete
}
[63] Fix | Delete
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
[64] Fix | Delete
curPunc = ch;
[65] Fix | Delete
return null;
[66] Fix | Delete
}
[67] Fix | Delete
if (/[\d']/.test(ch)) {
[68] Fix | Delete
stream.eatWhile(/[\w\.']/);
[69] Fix | Delete
return "number";
[70] Fix | Delete
}
[71] Fix | Delete
if (ch == "-") {
[72] Fix | Delete
if (stream.eat("-")) {
[73] Fix | Delete
stream.skipToEnd();
[74] Fix | Delete
return "comment";
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
if (isOperatorChar.test(ch)) {
[78] Fix | Delete
stream.eatWhile(isOperatorChar);
[79] Fix | Delete
return "operator";
[80] Fix | Delete
}
[81] Fix | Delete
stream.eatWhile(/[\w\$_]/);
[82] Fix | Delete
var cur = stream.current();
[83] Fix | Delete
if (keywords.propertyIsEnumerable(cur.toLowerCase())) {
[84] Fix | Delete
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
[85] Fix | Delete
return "keyword";
[86] Fix | Delete
}
[87] Fix | Delete
if (atoms.propertyIsEnumerable(cur)) return "atom";
[88] Fix | Delete
return "variable";
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
function tokenString(quote) {
[92] Fix | Delete
return function(stream, state) {
[93] Fix | Delete
var escaped = false, next, end = false;
[94] Fix | Delete
while ((next = stream.next()) != null) {
[95] Fix | Delete
if (next == quote && !escaped) {end = true; break;}
[96] Fix | Delete
escaped = !escaped && next == "--";
[97] Fix | Delete
}
[98] Fix | Delete
if (end || !(escaped || multiLineStrings))
[99] Fix | Delete
state.tokenize = tokenBase;
[100] Fix | Delete
return "string";
[101] Fix | Delete
};
[102] Fix | Delete
}
[103] Fix | Delete
function tokenString2(quote) {
[104] Fix | Delete
return function(stream, state) {
[105] Fix | Delete
var escaped = false, next, end = false;
[106] Fix | Delete
while ((next = stream.next()) != null) {
[107] Fix | Delete
if (next == quote && !escaped) {end = true; break;}
[108] Fix | Delete
escaped = !escaped && next == "--";
[109] Fix | Delete
}
[110] Fix | Delete
if (end || !(escaped || multiLineStrings))
[111] Fix | Delete
state.tokenize = tokenBase;
[112] Fix | Delete
return "string-2";
[113] Fix | Delete
};
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
function Context(indented, column, type, align, prev) {
[117] Fix | Delete
this.indented = indented;
[118] Fix | Delete
this.column = column;
[119] Fix | Delete
this.type = type;
[120] Fix | Delete
this.align = align;
[121] Fix | Delete
this.prev = prev;
[122] Fix | Delete
}
[123] Fix | Delete
function pushContext(state, col, type) {
[124] Fix | Delete
return state.context = new Context(state.indented, col, type, null, state.context);
[125] Fix | Delete
}
[126] Fix | Delete
function popContext(state) {
[127] Fix | Delete
var t = state.context.type;
[128] Fix | Delete
if (t == ")" || t == "]" || t == "}")
[129] Fix | Delete
state.indented = state.context.indented;
[130] Fix | Delete
return state.context = state.context.prev;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
// Interface
[134] Fix | Delete
return {
[135] Fix | Delete
startState: function(basecolumn) {
[136] Fix | Delete
return {
[137] Fix | Delete
tokenize: null,
[138] Fix | Delete
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
[139] Fix | Delete
indented: 0,
[140] Fix | Delete
startOfLine: true
[141] Fix | Delete
};
[142] Fix | Delete
},
[143] Fix | Delete
[144] Fix | Delete
token: function(stream, state) {
[145] Fix | Delete
var ctx = state.context;
[146] Fix | Delete
if (stream.sol()) {
[147] Fix | Delete
if (ctx.align == null) ctx.align = false;
[148] Fix | Delete
state.indented = stream.indentation();
[149] Fix | Delete
state.startOfLine = true;
[150] Fix | Delete
}
[151] Fix | Delete
if (stream.eatSpace()) return null;
[152] Fix | Delete
curPunc = null;
[153] Fix | Delete
var style = (state.tokenize || tokenBase)(stream, state);
[154] Fix | Delete
if (style == "comment" || style == "meta") return style;
[155] Fix | Delete
if (ctx.align == null) ctx.align = true;
[156] Fix | Delete
[157] Fix | Delete
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
[158] Fix | Delete
else if (curPunc == "{") pushContext(state, stream.column(), "}");
[159] Fix | Delete
else if (curPunc == "[") pushContext(state, stream.column(), "]");
[160] Fix | Delete
else if (curPunc == "(") pushContext(state, stream.column(), ")");
[161] Fix | Delete
else if (curPunc == "}") {
[162] Fix | Delete
while (ctx.type == "statement") ctx = popContext(state);
[163] Fix | Delete
if (ctx.type == "}") ctx = popContext(state);
[164] Fix | Delete
while (ctx.type == "statement") ctx = popContext(state);
[165] Fix | Delete
}
[166] Fix | Delete
else if (curPunc == ctx.type) popContext(state);
[167] Fix | Delete
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
[168] Fix | Delete
pushContext(state, stream.column(), "statement");
[169] Fix | Delete
state.startOfLine = false;
[170] Fix | Delete
return style;
[171] Fix | Delete
},
[172] Fix | Delete
[173] Fix | Delete
indent: function(state, textAfter) {
[174] Fix | Delete
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
[175] Fix | Delete
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
[176] Fix | Delete
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
[177] Fix | Delete
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
[178] Fix | Delete
else return ctx.indented + (closing ? 0 : indentUnit);
[179] Fix | Delete
},
[180] Fix | Delete
[181] Fix | Delete
electricChars: "{}"
[182] Fix | Delete
};
[183] Fix | Delete
});
[184] Fix | Delete
[185] Fix | Delete
CodeMirror.defineMIME("text/x-vhdl", "vhdl");
[186] Fix | Delete
[187] Fix | Delete
});
[188] Fix | Delete
[189] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function