1 define(function(require
, exports
, module
) {
4 var oop
= require("../lib/oop");
5 var DocCommentHighlightRules
= require("./doc_comment_highlight_rules").DocCommentHighlightRules
;
6 var TextHighlightRules
= require("./text_highlight_rules").TextHighlightRules
;
8 var NitHighlightRules
= function() {
11 "package|module|import|class|abstract|interface|universal|enum|end|fun|" +
12 "type|init|redef|is|do|readable|writable|var|intern|extern|protected|private|" +
13 "intrude|if|then|else|while|loop|for|in|and|or|not|implies|return|continue|" +
14 "break|abort|assert|new|isa|once|super|self|true|false|null|as|nullable|isset|label|__debug__"
17 var keywordMapper
= this.createKeywordMapper({
19 "variable.language": "self",
20 "constant.language": "null|true|false"
23 // regexp must not have capturing parentheses. Use (?:) instead.
24 // regexps are ordered -> the first match is used
32 token
: "support.class",
33 regex
: /[A
-Z
]{1}[a
-z
]+/
35 DocCommentHighlightRules
.getStartRule("doc-start"),
37 token
: "string.regexp",
38 regex
: "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
40 token
: "string", // character
41 regex
: /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
43 token : "string
", start : '"', end : '"|$', next: [
44 {token: "constant
.language
.escape
", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n
])/},
45 {token
: "invalid", regex
: /\\./}
48 token
: "string", start
: '@"', end
: '"', next
:[
49 {token
: "constant.language.escape", regex
: '""'}
52 token
: "constant.numeric", // hex
53 regex
: "0[xX][0-9a-fA-F]+\\b"
55 token
: "constant.numeric", // float
56 regex
: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
58 token
: "constant.language.boolean",
59 regex
: "(?:true|false)\\b"
61 token
: keywordMapper
,
62 regex
: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
64 token
: "keyword.operator",
65 regex
: "@|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\::|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
68 regex
: "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
70 token
: "punctuation.operator",
71 regex
: "\\?|\\:|\\,|\\;|\\."
73 token
: "paren.lparen",
76 token
: "paren.rparen",
84 this.embedRules(DocCommentHighlightRules
, "doc-",
85 [ DocCommentHighlightRules
.getEndRule("start") ]);
86 this.normalizeRules();
89 oop
.inherits(NitHighlightRules
, TextHighlightRules
);
91 exports
.NitHighlightRules
= NitHighlightRules
;