codemirror-rails 2.2.1 → 2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/README.md +8 -0
  2. data/codemirror-rails.gemspec +1 -1
  3. data/lib/codemirror/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/codemirror.js +842 -422
  5. data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +2 -2
  6. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +722 -32
  7. data/vendor/assets/javascripts/codemirror/modes/clike.js +31 -9
  8. data/vendor/assets/javascripts/codemirror/modes/clojure.js +14 -14
  9. data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +59 -37
  10. data/vendor/assets/javascripts/codemirror/modes/css.js +1 -1
  11. data/vendor/assets/javascripts/codemirror/modes/diff.js +24 -5
  12. data/vendor/assets/javascripts/codemirror/modes/ecl.js +203 -0
  13. data/vendor/assets/javascripts/codemirror/modes/erlang.js +251 -0
  14. data/vendor/assets/javascripts/codemirror/modes/gfm.js +40 -4
  15. data/vendor/assets/javascripts/codemirror/modes/go.js +170 -0
  16. data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +1 -1
  17. data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +4 -2
  18. data/vendor/assets/javascripts/codemirror/modes/javascript.js +10 -9
  19. data/vendor/assets/javascripts/codemirror/modes/less.js +232 -0
  20. data/vendor/assets/javascripts/codemirror/modes/markdown.js +52 -49
  21. data/vendor/assets/javascripts/codemirror/modes/mysql.js +188 -0
  22. data/vendor/assets/javascripts/codemirror/modes/pascal.js +2 -46
  23. data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
  24. data/vendor/assets/javascripts/codemirror/modes/php.js +55 -25
  25. data/vendor/assets/javascripts/codemirror/modes/pig.js +172 -0
  26. data/vendor/assets/javascripts/codemirror/modes/properties.js +63 -0
  27. data/vendor/assets/javascripts/codemirror/modes/python.js +37 -32
  28. data/vendor/assets/javascripts/codemirror/modes/rpm-spec.js +1 -1
  29. data/vendor/assets/javascripts/codemirror/modes/rst.js +1 -1
  30. data/vendor/assets/javascripts/codemirror/modes/ruby.js +14 -14
  31. data/vendor/assets/javascripts/codemirror/modes/rust.js +36 -15
  32. data/vendor/assets/javascripts/codemirror/modes/scheme.js +74 -46
  33. data/vendor/assets/javascripts/codemirror/modes/shell.js +103 -0
  34. data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +16 -16
  35. data/vendor/assets/javascripts/codemirror/modes/smarty.js +148 -0
  36. data/vendor/assets/javascripts/codemirror/modes/stex.js +21 -6
  37. data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +55 -45
  38. data/vendor/assets/javascripts/codemirror/modes/tiki.js +316 -0
  39. data/vendor/assets/javascripts/codemirror/modes/vbscript.js +26 -0
  40. data/vendor/assets/javascripts/codemirror/modes/verilog.js +194 -0
  41. data/vendor/assets/javascripts/codemirror/modes/xml.js +89 -16
  42. data/vendor/assets/javascripts/codemirror/modes/xmlpure.js +5 -0
  43. data/vendor/assets/javascripts/codemirror/modes/xquery.js +448 -0
  44. data/vendor/assets/javascripts/codemirror/utils/closetag.js +146 -0
  45. data/vendor/assets/javascripts/codemirror/utils/dialog.js +63 -0
  46. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +196 -0
  47. data/vendor/assets/javascripts/codemirror/utils/formatting.js +297 -0
  48. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +134 -0
  49. data/vendor/assets/javascripts/codemirror/utils/loadmode.js +51 -0
  50. data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +44 -0
  51. data/vendor/assets/javascripts/codemirror/utils/multiplex.js +72 -0
  52. data/vendor/assets/javascripts/codemirror/{overlay.js → utils/overlay.js} +3 -2
  53. data/vendor/assets/javascripts/codemirror/utils/pig-hint.js +123 -0
  54. data/vendor/assets/javascripts/codemirror/utils/runmode.js +49 -0
  55. data/vendor/assets/javascripts/codemirror/utils/search.js +118 -0
  56. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +117 -0
  57. data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +72 -0
  58. data/vendor/assets/stylesheets/codemirror.css +69 -5
  59. data/vendor/assets/stylesheets/codemirror/modes/tiddlywiki.css +14 -21
  60. data/vendor/assets/stylesheets/codemirror/modes/tiki.css +26 -0
  61. data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +81 -0
  62. data/vendor/assets/stylesheets/codemirror/themes/blackboard.css +25 -0
  63. data/vendor/assets/stylesheets/codemirror/themes/cobalt.css +1 -1
  64. data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +1 -1
  65. data/vendor/assets/stylesheets/codemirror/themes/elegant.css +2 -2
  66. data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +21 -0
  67. data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +44 -0
  68. data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -1
  69. data/vendor/assets/stylesheets/codemirror/themes/neat.css +3 -3
  70. data/vendor/assets/stylesheets/codemirror/themes/night.css +1 -1
  71. data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -2
  72. data/vendor/assets/stylesheets/codemirror/themes/vibrant-ink.css +27 -0
  73. data/vendor/assets/stylesheets/codemirror/themes/xq-dark.css +46 -0
  74. data/vendor/assets/stylesheets/codemirror/utils/dialog.css +23 -0
  75. data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +16 -0
  76. metadata +41 -10
  77. data/vendor/assets/javascripts/codemirror/runmode.js +0 -27
  78. data/vendor/assets/stylesheets/codemirror/modes/clike.css +0 -7
  79. data/vendor/assets/stylesheets/codemirror/modes/markdown.css +0 -10
  80. data/vendor/assets/stylesheets/codemirror/modes/rst.css +0 -75
  81. data/vendor/assets/stylesheets/codemirror/themes/default.css +0 -19
@@ -0,0 +1,316 @@
1
+ CodeMirror.defineMode('tiki', function(config, parserConfig) {
2
+ function inBlock(style, terminator, returnTokenizer) {
3
+ return function(stream, state) {
4
+ while (!stream.eol()) {
5
+ if (stream.match(terminator)) {
6
+ state.tokenize = inText;
7
+ break;
8
+ }
9
+ stream.next();
10
+ }
11
+
12
+ if (returnTokenizer) state.tokenize = returnTokenizer;
13
+
14
+ return style;
15
+ };
16
+ }
17
+
18
+ function inLine(style, terminator) {
19
+ return function(stream, state) {
20
+ while(!stream.eol()) {
21
+ stream.next()
22
+ }
23
+ state.tokenize = inText;
24
+ return style;
25
+ };
26
+ }
27
+
28
+ function inText(stream, state) {
29
+ function chain(parser) {
30
+ state.tokenize = parser;
31
+ return parser(stream, state);
32
+ }
33
+
34
+ var sol = stream.sol();
35
+ var ch = stream.next();
36
+
37
+ //non start of line
38
+ switch (ch) { //switch is generally much faster than if, so it is used here
39
+ case "{": //plugin
40
+ type = stream.eat("/") ? "closeTag" : "openTag";
41
+ stream.eatSpace();
42
+ tagName = "";
43
+ var c;
44
+ while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
45
+ state.tokenize = inPlugin;
46
+ return "tag";
47
+ break;
48
+ case "_": //bold
49
+ if (stream.eat("_")) {
50
+ return chain(inBlock("strong", "__", inText));
51
+ }
52
+ break;
53
+ case "'": //italics
54
+ if (stream.eat("'")) {
55
+ // Italic text
56
+ return chain(inBlock("em", "''", inText));
57
+ }
58
+ break;
59
+ case "(":// Wiki Link
60
+ if (stream.eat("(")) {
61
+ return chain(inBlock("variable-2", "))", inText));
62
+ }
63
+ break;
64
+ case "[":// Weblink
65
+ return chain(inBlock("variable-3", "]", inText));
66
+ break;
67
+ case "|": //table
68
+ if (stream.eat("|")) {
69
+ return chain(inBlock("comment", "||"));
70
+ }
71
+ break;
72
+ case "-":
73
+ if (stream.eat("=")) {//titleBar
74
+ return chain(inBlock("header string", "=-", inText));
75
+ } else if (stream.eat("-")) {//deleted
76
+ return chain(inBlock("error tw-deleted", "--", inText));
77
+ }
78
+ break;
79
+ case "=": //underline
80
+ if (stream.match("==")) {
81
+ return chain(inBlock("tw-underline", "===", inText));
82
+ }
83
+ break;
84
+ case ":":
85
+ if (stream.eat(":")) {
86
+ return chain(inBlock("comment", "::"));
87
+ }
88
+ break;
89
+ case "^": //box
90
+ return chain(inBlock("tw-box", "^"));
91
+ break;
92
+ case "~": //np
93
+ if (stream.match("np~")) {
94
+ return chain(inBlock("meta", "~/np~"));
95
+ }
96
+ break;
97
+ }
98
+
99
+ //start of line types
100
+ if (sol) {
101
+ switch (ch) {
102
+ case "!": //header at start of line
103
+ if (stream.match('!!!!!')) {
104
+ return chain(inLine("header string"));
105
+ } else if (stream.match('!!!!')) {
106
+ return chain(inLine("header string"));
107
+ } else if (stream.match('!!!')) {
108
+ return chain(inLine("header string"));
109
+ } else if (stream.match('!!')) {
110
+ return chain(inLine("header string"));
111
+ } else {
112
+ return chain(inLine("header string"));
113
+ }
114
+ break;
115
+ case "*": //unordered list line item, or <li /> at start of line
116
+ case "#": //ordered list line item, or <li /> at start of line
117
+ case "+": //ordered list line item, or <li /> at start of line
118
+ return chain(inLine("tw-listitem bracket"));
119
+ break;
120
+ }
121
+ }
122
+
123
+ //stream.eatWhile(/[&{]/); was eating up plugins, turned off to act less like html and more like tiki
124
+ return null;
125
+ }
126
+
127
+ var indentUnit = config.indentUnit;
128
+
129
+ // Return variables for tokenizers
130
+ var pluginName, type;
131
+ function inPlugin(stream, state) {
132
+ var ch = stream.next();
133
+ var peek = stream.peek();
134
+
135
+ if (ch == "}") {
136
+ state.tokenize = inText;
137
+ //type = ch == ")" ? "endPlugin" : "selfclosePlugin"; inPlugin
138
+ return "tag";
139
+ } else if (ch == "(" || ch == ")") {
140
+ return "bracket";
141
+ } else if (ch == "=") {
142
+ type = "equals";
143
+
144
+ if (peek == ">") {
145
+ ch = stream.next();
146
+ peek = stream.peek();
147
+ }
148
+
149
+ //here we detect values directly after equal character with no quotes
150
+ if (!/[\'\"]/.test(peek)) {
151
+ state.tokenize = inAttributeNoQuote();
152
+ }
153
+ //end detect values
154
+
155
+ return "operator";
156
+ } else if (/[\'\"]/.test(ch)) {
157
+ state.tokenize = inAttribute(ch);
158
+ return state.tokenize(stream, state);
159
+ } else {
160
+ stream.eatWhile(/[^\s\u00a0=\"\'\/?]/);
161
+ return "keyword";
162
+ }
163
+ }
164
+
165
+ function inAttribute(quote) {
166
+ return function(stream, state) {
167
+ while (!stream.eol()) {
168
+ if (stream.next() == quote) {
169
+ state.tokenize = inPlugin;
170
+ break;
171
+ }
172
+ }
173
+ return "string";
174
+ };
175
+ }
176
+
177
+ function inAttributeNoQuote() {
178
+ return function(stream, state) {
179
+ while (!stream.eol()) {
180
+ var ch = stream.next();
181
+ var peek = stream.peek();
182
+ if (ch == " " || ch == "," || /[ )}]/.test(peek)) {
183
+ state.tokenize = inPlugin;
184
+ break;
185
+ }
186
+ }
187
+ return "string";
188
+ };
189
+ }
190
+
191
+ var curState, setStyle;
192
+ function pass() {
193
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
194
+ }
195
+
196
+ function cont() {
197
+ pass.apply(null, arguments);
198
+ return true;
199
+ }
200
+
201
+ function pushContext(pluginName, startOfLine) {
202
+ var noIndent = curState.context && curState.context.noIndent;
203
+ curState.context = {
204
+ prev: curState.context,
205
+ pluginName: pluginName,
206
+ indent: curState.indented,
207
+ startOfLine: startOfLine,
208
+ noIndent: noIndent
209
+ };
210
+ }
211
+
212
+ function popContext() {
213
+ if (curState.context) curState.context = curState.context.prev;
214
+ }
215
+
216
+ function element(type) {
217
+ if (type == "openPlugin") {curState.pluginName = pluginName; return cont(attributes, endplugin(curState.startOfLine));}
218
+ else if (type == "closePlugin") {
219
+ var err = false;
220
+ if (curState.context) {
221
+ err = curState.context.pluginName != pluginName;
222
+ popContext();
223
+ } else {
224
+ err = true;
225
+ }
226
+ if (err) setStyle = "error";
227
+ return cont(endcloseplugin(err));
228
+ }
229
+ else if (type == "string") {
230
+ if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
231
+ if (curState.tokenize == inText) popContext();
232
+ return cont();
233
+ }
234
+ else return cont();
235
+ }
236
+
237
+ function endplugin(startOfLine) {
238
+ return function(type) {
239
+ if (
240
+ type == "selfclosePlugin" ||
241
+ type == "endPlugin"
242
+ )
243
+ return cont();
244
+ if (type == "endPlugin") {pushContext(curState.pluginName, startOfLine); return cont();}
245
+ return cont();
246
+ };
247
+ }
248
+
249
+ function endcloseplugin(err) {
250
+ return function(type) {
251
+ if (err) setStyle = "error";
252
+ if (type == "endPlugin") return cont();
253
+ return pass();
254
+ }
255
+ }
256
+
257
+ function attributes(type) {
258
+ if (type == "keyword") {setStyle = "attribute"; return cont(attributes);}
259
+ if (type == "equals") return cont(attvalue, attributes);
260
+ return pass();
261
+ }
262
+ function attvalue(type) {
263
+ if (type == "keyword") {setStyle = "string"; return cont();}
264
+ if (type == "string") return cont(attvaluemaybe);
265
+ return pass();
266
+ }
267
+ function attvaluemaybe(type) {
268
+ if (type == "string") return cont(attvaluemaybe);
269
+ else return pass();
270
+ }
271
+ return {
272
+ startState: function() {
273
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, pluginName: null, context: null};
274
+ },
275
+ token: function(stream, state) {
276
+ if (stream.sol()) {
277
+ state.startOfLine = true;
278
+ state.indented = stream.indentation();
279
+ }
280
+ if (stream.eatSpace()) return null;
281
+
282
+ setStyle = type = pluginName = null;
283
+ var style = state.tokenize(stream, state);
284
+ if ((style || type) && style != "comment") {
285
+ curState = state;
286
+ while (true) {
287
+ var comb = state.cc.pop() || element;
288
+ if (comb(type || style)) break;
289
+ }
290
+ }
291
+ state.startOfLine = false;
292
+ return setStyle || style;
293
+ },
294
+ indent: function(state, textAfter) {
295
+ var context = state.context;
296
+ if (context && context.noIndent) return 0;
297
+ if (context && /^{\//.test(textAfter))
298
+ context = context.prev;
299
+ while (context && !context.startOfLine)
300
+ context = context.prev;
301
+ if (context) return context.indent + indentUnit;
302
+ else return 0;
303
+ },
304
+ compareStates: function(a, b) {
305
+ if (a.indented != b.indented || a.pluginName != b.pluginName) return false;
306
+ for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
307
+ if (!ca || !cb) return ca == cb;
308
+ if (ca.pluginName != cb.pluginName) return false;
309
+ }
310
+ },
311
+ electricChars: "/"
312
+ };
313
+ });
314
+
315
+ //I figure, why not
316
+ CodeMirror.defineMIME("text/tiki", "tiki");
@@ -0,0 +1,26 @@
1
+ CodeMirror.defineMode("vbscript", function() {
2
+ var regexVBScriptKeyword = /^(?:Call|Case|CDate|Clear|CInt|CLng|Const|CStr|Description|Dim|Do|Each|Else|ElseIf|End|Err|Error|Exit|False|For|Function|If|LCase|Loop|LTrim|Next|Nothing|Now|Number|On|Preserve|Quit|ReDim|Resume|RTrim|Select|Set|Sub|Then|To|Trim|True|UBound|UCase|Until|VbCr|VbCrLf|VbLf|VbTab)$/im;
3
+
4
+ return {
5
+ token: function(stream) {
6
+ if (stream.eatSpace()) return null;
7
+ var ch = stream.next();
8
+ if (ch == "'") {
9
+ stream.skipToEnd();
10
+ return "comment";
11
+ }
12
+ if (ch == '"') {
13
+ stream.skipTo('"');
14
+ return "string";
15
+ }
16
+
17
+ if (/\w/.test(ch)) {
18
+ stream.eatWhile(/\w/);
19
+ if (regexVBScriptKeyword.test(stream.current())) return "keyword";
20
+ }
21
+ return null;
22
+ }
23
+ };
24
+ });
25
+
26
+ CodeMirror.defineMIME("text/vbscript", "vbscript");
@@ -0,0 +1,194 @@
1
+ CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords || {},
4
+ blockKeywords = parserConfig.blockKeywords || {},
5
+ atoms = parserConfig.atoms || {},
6
+ hooks = parserConfig.hooks || {},
7
+ multiLineStrings = parserConfig.multiLineStrings;
8
+ var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
9
+
10
+ var curPunc;
11
+
12
+ function tokenBase(stream, state) {
13
+ var ch = stream.next();
14
+ if (hooks[ch]) {
15
+ var result = hooks[ch](stream, state);
16
+ if (result !== false) return result;
17
+ }
18
+ if (ch == '"') {
19
+ state.tokenize = tokenString(ch);
20
+ return state.tokenize(stream, state);
21
+ }
22
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
+ curPunc = ch;
24
+ return null
25
+ }
26
+ if (/[\d']/.test(ch)) {
27
+ stream.eatWhile(/[\w\.']/);
28
+ return "number";
29
+ }
30
+ if (ch == "/") {
31
+ if (stream.eat("*")) {
32
+ state.tokenize = tokenComment;
33
+ return tokenComment(stream, state);
34
+ }
35
+ if (stream.eat("/")) {
36
+ stream.skipToEnd();
37
+ return "comment";
38
+ }
39
+ }
40
+ if (isOperatorChar.test(ch)) {
41
+ stream.eatWhile(isOperatorChar);
42
+ return "operator";
43
+ }
44
+ stream.eatWhile(/[\w\$_]/);
45
+ var cur = stream.current();
46
+ if (keywords.propertyIsEnumerable(cur)) {
47
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
+ return "keyword";
49
+ }
50
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
51
+ return "word";
52
+ }
53
+
54
+ function tokenString(quote) {
55
+ return function(stream, state) {
56
+ var escaped = false, next, end = false;
57
+ while ((next = stream.next()) != null) {
58
+ if (next == quote && !escaped) {end = true; break;}
59
+ escaped = !escaped && next == "\\";
60
+ }
61
+ if (end || !(escaped || multiLineStrings))
62
+ state.tokenize = tokenBase;
63
+ return "string";
64
+ };
65
+ }
66
+
67
+ function tokenComment(stream, state) {
68
+ var maybeEnd = false, ch;
69
+ while (ch = stream.next()) {
70
+ if (ch == "/" && maybeEnd) {
71
+ state.tokenize = tokenBase;
72
+ break;
73
+ }
74
+ maybeEnd = (ch == "*");
75
+ }
76
+ return "comment";
77
+ }
78
+
79
+ function Context(indented, column, type, align, prev) {
80
+ this.indented = indented;
81
+ this.column = column;
82
+ this.type = type;
83
+ this.align = align;
84
+ this.prev = prev;
85
+ }
86
+ function pushContext(state, col, type) {
87
+ return state.context = new Context(state.indented, col, type, null, state.context);
88
+ }
89
+ function popContext(state) {
90
+ var t = state.context.type;
91
+ if (t == ")" || t == "]" || t == "}")
92
+ state.indented = state.context.indented;
93
+ return state.context = state.context.prev;
94
+ }
95
+
96
+ // Interface
97
+
98
+ return {
99
+ startState: function(basecolumn) {
100
+ return {
101
+ tokenize: null,
102
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
103
+ indented: 0,
104
+ startOfLine: true
105
+ };
106
+ },
107
+
108
+ token: function(stream, state) {
109
+ var ctx = state.context;
110
+ if (stream.sol()) {
111
+ if (ctx.align == null) ctx.align = false;
112
+ state.indented = stream.indentation();
113
+ state.startOfLine = true;
114
+ }
115
+ if (stream.eatSpace()) return null;
116
+ curPunc = null;
117
+ var style = (state.tokenize || tokenBase)(stream, state);
118
+ if (style == "comment" || style == "meta") return style;
119
+ if (ctx.align == null) ctx.align = true;
120
+
121
+ if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
122
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
123
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
124
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
125
+ else if (curPunc == "}") {
126
+ while (ctx.type == "statement") ctx = popContext(state);
127
+ if (ctx.type == "}") ctx = popContext(state);
128
+ while (ctx.type == "statement") ctx = popContext(state);
129
+ }
130
+ else if (curPunc == ctx.type) popContext(state);
131
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
132
+ pushContext(state, stream.column(), "statement");
133
+ state.startOfLine = false;
134
+ return style;
135
+ },
136
+
137
+ indent: function(state, textAfter) {
138
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
140
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
141
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
142
+ else return ctx.indented + (closing ? 0 : indentUnit);
143
+ },
144
+
145
+ electricChars: "{}"
146
+ };
147
+ });
148
+
149
+ (function() {
150
+ function words(str) {
151
+ var obj = {}, words = str.split(" ");
152
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
153
+ return obj;
154
+ }
155
+
156
+ var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " +
157
+ "deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " +
158
+ "endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " +
159
+ "highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " +
160
+ "macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " +
161
+ "posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " +
162
+ "reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " +
163
+ "strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " +
164
+ "unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor";
165
+
166
+ var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " +
167
+ "endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " +
168
+ "macromodule module primitive repeat specify table task while";
169
+
170
+ function metaHook(stream, state) {
171
+ stream.eatWhile(/[\w\$_]/);
172
+ return "meta";
173
+ }
174
+
175
+ // C#-style strings where "" escapes a quote.
176
+ function tokenAtString(stream, state) {
177
+ var next;
178
+ while ((next = stream.next()) != null) {
179
+ if (next == '"' && !stream.eat('"')) {
180
+ state.tokenize = null;
181
+ break;
182
+ }
183
+ }
184
+ return "string";
185
+ }
186
+
187
+ CodeMirror.defineMIME("text/x-verilog", {
188
+ name: "verilog",
189
+ keywords: words(verilogKeywords),
190
+ blockKeywords: words(verilogBlockKeywords),
191
+ atoms: words("null"),
192
+ hooks: {"`": metaHook, "$": metaHook}
193
+ });
194
+ }());