misc: update highlighters and indenters
[nit.git] / misc / syntaxhighlighter / shBrushNit.js
1 /* This file is part of NIT ( http://www.nitlanguage.org ).
2
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6
7 * http://www.apache.org/licenses/LICENSE-2.0
8
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 * Nit Brush for SyntaxHighlighter
16 * see http://alexgorbatchev.com/SyntaxHighlighter
17 */
18
19 ;(function()
20 {
21 // CommonJS
22 typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
23
24 function Brush()
25 {
26 var keywords = 'abort abstract and as assert break class continue do else end catch enum extern false for fun' +
27 'if import in init interface intrude is isa isset label loop module new null nullable not' +
28 'once or protected private redef return self super then type true universal var' +
29 'when while writable';
30 var builtins = 'exit sys args get_time getc getcwd gets print printn';
31
32 this.regexList = [
33 { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
34 { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
35 { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
36 { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // types
37 { regex: /[A-Z][A-Za-z0-9_]*/g, css: 'color2' }, // classes
38 { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
39 { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color3' } // builtins
40 ];
41 this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
42 };
43
44 Brush.prototype = new SyntaxHighlighter.Highlighter();
45 Brush.aliases = ['nit'];
46
47 SyntaxHighlighter.brushes.Nit = Brush;
48
49 // CommonJS
50 typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
51 })();
52