convert rest of the modes to new style

This commit is contained in:
nightwing 2012-08-31 19:21:47 +04:00
commit 43f966bd5f
25 changed files with 562 additions and 772 deletions

View file

@ -1060,7 +1060,7 @@
"text", "text",
"keyword", "keyword",
"text", "text",
"identifier", "variable.language",
"text", "text",
"identifier", "identifier",
"text", "text",

View file

@ -42,27 +42,32 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var c_cppHighlightRules = function() { var c_cppHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|" + "and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|" +
"asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|" + "asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|" +
"typeid|bitor|extern|protected|typename|bool|false|public|union|" + "typeid|bitor|extern|protected|typename|bool|false|public|union|" +
"break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|" + "break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|" +
"friend|return|virtual|char|goto|short|void|class|if|signed|volatile|" + "friend|return|virtual|char|goto|short|void|class|if|signed|volatile|" +
"compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|" + "compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|" +
"static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|" + "static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|" +
"switch|delete|new|template|do|not|this|for").split("|") "switch|delete|new|template|do|not|this|for"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = (
("NULL").split("|") "NULL"
); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": buildinConstants
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -107,16 +112,7 @@ var c_cppHighlightRules = function() {
token : "keyword", // pre-compiler directivs token : "keyword", // pre-compiler directivs
regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
@ -169,7 +165,7 @@ var c_cppHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
}; };

View file

@ -41,93 +41,94 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var ClojureHighlightRules = function() { var ClojureHighlightRules = function() {
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
('* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' + '* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' +
'*command-line-args* *compile-files* *compile-path* *e *err* *file* ' + '*command-line-args* *compile-files* *compile-path* *e *err* *file* ' +
'*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' + '*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' +
'*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' + '*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' +
'*read-eval* *source-path* *use-context-classloader* ' + '*read-eval* *source-path* *use-context-classloader* ' +
'*warn-on-reflection* + - -> -&gt; ->> -&gt;&gt; .. / < &lt; <= &lt;= = ' + '*warn-on-reflection* + - -> ->> .. / < <= = ' +
'== > &gt; >= &gt;= accessor aclone ' + '== > &gt; >= &gt;= accessor aclone ' +
'add-classpath add-watch agent agent-errors aget alength alias all-ns ' + 'add-classpath add-watch agent agent-errors aget alength alias all-ns ' +
'alter alter-meta! alter-var-root amap ancestors and apply areduce ' + 'alter alter-meta! alter-var-root amap ancestors and apply areduce ' +
'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' + 'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' +
'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' + 'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' +
'atom await await-for await1 bases bean bigdec bigint binding bit-and ' + 'atom await await-for await1 bases bean bigdec bigint binding bit-and ' +
'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' + 'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' +
'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' + 'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' +
'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' + 'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' +
'char-escape-string char-name-string char? chars chunk chunk-append ' + 'char-escape-string char-name-string char? chars chunk chunk-append ' +
'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' + 'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' +
'class class? clear-agent-errors clojure-version coll? comment commute ' + 'class class? clear-agent-errors clojure-version coll? comment commute ' +
'comp comparator compare compare-and-set! compile complement concat cond ' + 'comp comparator compare compare-and-set! compile complement concat cond ' +
'condp conj conj! cons constantly construct-proxy contains? count ' + 'condp conj conj! cons constantly construct-proxy contains? count ' +
'counted? create-ns create-struct cycle dec decimal? declare definline ' + 'counted? create-ns create-struct cycle dec decimal? declare definline ' +
'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' + 'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' +
'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' + 'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' +
'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' + 'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' +
'double-array doubles drop drop-last drop-while empty empty? ensure ' + 'double-array doubles drop drop-last drop-while empty empty? ensure ' +
'enumeration-seq eval even? every? false? ffirst file-seq filter find ' + 'enumeration-seq eval even? every? false? ffirst file-seq filter find ' +
'find-doc find-ns find-var first float float-array float? floats flush ' + 'find-doc find-ns find-var first float float-array float? floats flush ' +
'fn fn? fnext for force format future future-call future-cancel ' + 'fn fn? fnext for force format future future-call future-cancel ' +
'future-cancelled? future-done? future? gen-class gen-interface gensym ' + 'future-cancelled? future-done? future? gen-class gen-interface gensym ' +
'get get-in get-method get-proxy-class get-thread-bindings get-validator ' + 'get get-in get-method get-proxy-class get-thread-bindings get-validator ' +
'hash hash-map hash-set identical? identity if-let if-not ifn? import ' + 'hash hash-map hash-set identical? identity if-let if-not ifn? import ' +
'in-ns inc init-proxy instance? int int-array integer? interleave intern ' + 'in-ns inc init-proxy instance? int int-array integer? interleave intern ' +
'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' + 'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' +
'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' + 'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' +
'list* list? load load-file load-reader load-string loaded-libs locking ' + 'list* list? load load-file load-reader load-string loaded-libs locking ' +
'long long-array longs loop macroexpand macroexpand-1 make-array ' + 'long long-array longs loop macroexpand macroexpand-1 make-array ' +
'make-hierarchy map map? mapcat max max-key memfn memoize merge ' + 'make-hierarchy map map? mapcat max max-key memfn memoize merge ' +
'merge-with meta method-sig methods min min-key mod name namespace neg? ' + 'merge-with meta method-sig methods min min-key mod name namespace neg? ' +
'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' + 'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' +
'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' + 'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' +
'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' + 'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' +
'or parents partial partition pcalls peek persistent! pmap pop pop! ' + 'or parents partial partition pcalls peek persistent! pmap pop pop! ' +
'pop-thread-bindings pos? pr pr-str prefer-method prefers ' + 'pop-thread-bindings pos? pr pr-str prefer-method prefers ' +
'primitives-classnames print print-ctor print-doc print-dup print-method ' + 'primitives-classnames print print-ctor print-doc print-dup print-method ' +
'print-namespace-doc print-simple print-special-doc print-str printf ' + 'print-namespace-doc print-simple print-special-doc print-str printf ' +
'println println-str prn prn-str promise proxy proxy-call-with-super ' + 'println println-str prn prn-str promise proxy proxy-call-with-super ' +
'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' + 'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' +
'rand rand-int range ratio? rational? rationalize re-find re-groups ' + 'rand rand-int range ratio? rational? rationalize re-find re-groups ' +
're-matcher re-matches re-pattern re-seq read read-line read-string ' + 're-matcher re-matches re-pattern re-seq read read-line read-string ' +
'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' + 'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' +
'refer refer-clojure release-pending-sends rem remove remove-method ' + 'refer refer-clojure release-pending-sends rem remove remove-method ' +
'remove-ns remove-watch repeat repeatedly replace replicate require ' + 'remove-ns remove-watch repeat repeatedly replace replicate require ' +
'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' + 'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' +
'rsubseq second select-keys send send-off seq seq? seque sequence ' + 'rsubseq second select-keys send send-off seq seq? seque sequence ' +
'sequential? set set-validator! set? short short-array shorts ' + 'sequential? set set-validator! set? short short-array shorts ' +
'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' + 'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' +
'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' + 'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' +
'split-at split-with str stream? string? struct struct-map subs subseq ' + 'split-at split-with str stream? string? struct struct-map subs subseq ' +
'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' + 'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' +
'take-last take-nth take-while test the-ns time to-array to-array-2d ' + 'take-last take-nth take-while test the-ns time to-array to-array-2d ' +
'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' + 'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' +
'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' + 'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' +
'unchecked-remainder unchecked-subtract underive unquote ' + 'unchecked-remainder unchecked-subtract underive unquote ' +
'unquote-splicing update-in update-proxy use val vals var-get var-set ' + 'unquote-splicing update-in update-proxy use val vals var-get var-set ' +
'var? vary-meta vec vector vector? when when-first when-let when-not ' + 'var? vary-meta vec vector vector? when when-first when-let when-not ' +
'while with-bindings with-bindings* with-in-str with-loading-context ' + 'while with-bindings with-bindings* with-in-str with-loading-context ' +
'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' + 'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' +
'zero? zipmap ').split(" ") 'zero? zipmap'
); );
var keywords = lang.arrayToMap( var keywords = ('throw try var ' +
('def do fn if let loop monitor-enter monitor-exit new quote recur set! ' + 'def do fn if let loop monitor-enter monitor-exit new quote recur set!'
'throw try var').split(" ")
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = ("true false nil");
("true false nil").split(" ")
);
var keywordMapper = this.createKeywordMapper({
"keyword": keywords,
"constant.language": buildinConstants,
"support.function": builtinFunctions
}, "identifier", false, " ");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -175,16 +176,7 @@ var ClojureHighlightRules = function() {
token : "constant.language", token : "constant.language",
regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]' regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"

View file

@ -38,10 +38,9 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var lang = require("../lib/lang");
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
oop.inherits(CoffeeHighlightRules, TextHighlightRules); oop.inherits(CoffeeHighlightRules, TextHighlightRules);
function CoffeeHighlightRules() { function CoffeeHighlightRules() {
@ -52,34 +51,41 @@ define(function(require, exports, module) {
regex : ".+" regex : ".+"
}; };
var keywords = lang.arrayToMap(( var keywords = (
"this|throw|then|try|typeof|super|switch|return|break|by)|continue|" + "this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
"catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" + "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
"finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
"or|on|unless|until|and|yes").split("|") "or|on|unless|until|and|yes"
); );
var langConstant = lang.arrayToMap(( var langConstant = (
"true|false|null|undefined").split("|") "true|false|null|undefined"
); );
var illegal = lang.arrayToMap(( var illegal = (
"case|const|default|function|var|void|with|enum|export|implements|" + "case|const|default|function|var|void|with|enum|export|implements|" +
"interface|let|package|private|protected|public|static|yield|" + "interface|let|package|private|protected|public|static|yield|" +
"__hasProp|extends|slice|bind|indexOf").split("|") "__hasProp|extends|slice|bind|indexOf"
); );
var supportClass = lang.arrayToMap(( var supportClass = (
"Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" + "Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" +
"RangeError|String|SyntaxError|Error|EvalError|TypeError|URIError").split("|") "String|RangeError|SyntaxError|Error|EvalError|TypeError|URIError"
); );
var supportFunction = lang.arrayToMap(( var supportFunction = (
"Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" + "Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" +
"encodeURIComponent|decodeURI|decodeURIComponent|RangeError|String|" + "encodeURIComponent|decodeURI|decodeURIComponent|String|"
"SyntaxError|Error|EvalError|TypeError|URIError").split("|")
); );
var keywordMapper = this.createKeywordMapper({
"keyword": keywords,
"constant.language": langConstant,
"invalid.illegal": illegal,
"language.support.class": supportClass,
"language.support.function": supportFunction,
}, "identifier");
this.$rules = { this.$rules = {
start : [ start : [
{ {
@ -89,20 +95,7 @@ define(function(require, exports, module) {
token : "variable", token : "variable",
regex : "@(?:" + identifier + ")?" regex : "@(?:" + identifier + ")?"
}, { }, {
token: function(value) { token: keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (langConstant.hasOwnProperty(value))
return "constant.language";
else if (illegal.hasOwnProperty(value))
return "invalid.illegal";
else if (supportClass.hasOwnProperty(value))
return "language.support.class";
else if (supportFunction.hasOwnProperty(value))
return "language.support.function";
else
return "identifier";
},
regex : identifier regex : identifier
}, { }, {
token : "constant.numeric", token : "constant.numeric",
@ -164,40 +157,40 @@ define(function(require, exports, module) {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
}], }],
qdoc : [{ qdoc : [{
token : "string", token : "string",
regex : ".*?'''", regex : ".*?'''",
next : "start" next : "start"
}, stringfill], }, stringfill],
qqdoc : [{ qqdoc : [{
token : "string", token : "string",
regex : '.*?"""', regex : '.*?"""',
next : "start" next : "start"
}, stringfill], }, stringfill],
qstring : [{ qstring : [{
token : "string", token : "string",
regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'", regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'",
merge : true, merge : true,
next : "start" next : "start"
}, stringfill], }, stringfill],
qqstring : [{ qqstring : [{
token : "string", token : "string",
regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"', regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
merge : true, merge : true,
next : "start" next : "start"
}, stringfill], }, stringfill],
js : [{ js : [{
token : "string", token : "string",
merge : true, merge : true,
regex : "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`", regex : "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",
next : "start" next : "start"
}, stringfill], }, stringfill],
heregex : [{ heregex : [{
token : "string.regex", token : "string.regex",
regex : '.*?///[imgy]{0,4}', regex : '.*?///[imgy]{0,4}',
@ -210,7 +203,7 @@ define(function(require, exports, module) {
merge : true, merge : true,
regex : "\\S+" regex : "\\S+"
}], }],
comment : [{ comment : [{
token : "comment", token : "comment",
regex : '.*?###', regex : '.*?###',

View file

@ -2,20 +2,15 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var CSharpHighlightRules = function() { var CSharpHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({
var keywords = lang.arrayToMap( "variable.language": "this",
("abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic").split("|") "keyword": "abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic",
); "constant.language": "null|true|false"
}, "identifier");
var buildinConstants = lang.arrayToMap(
("null|true|false").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -51,16 +46,7 @@ var CSharpHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
@ -93,7 +79,7 @@ var CSharpHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
}; };

View file

@ -43,37 +43,21 @@ var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var CssHighlightRules = function() { var CssHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({
"support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index",
"support.function": "rgb|rgba|url|attr|counter|counters",
"support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero",
"support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow",
"support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace"
}, "text", true);
var properties = lang.arrayToMap(
("animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index").split("|")
);
var functions = lang.arrayToMap(
("rgb|rgba|url|attr|counter|counters").split("|")
);
var constants = lang.arrayToMap(
("absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|font-size|font|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero").split("|")
);
var colors = lang.arrayToMap(
("aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|" +
"purple|red|silver|teal|white|yellow").split("|")
);
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
var base_ruleset = [ var base_ruleset = [
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
@ -99,34 +83,15 @@ var CssHighlightRules = function() {
token : "constant.numeric", // hex3 color token : "constant.numeric", // hex3 color
regex : "#[a-f0-9]{3}" regex : "#[a-f0-9]{3}"
}, { }, {
token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
regex : pseudoElements regex : pseudoElements
}, { }, {
token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
regex : pseudoClasses regex : pseudoClasses
}, { }, {
token : function(value) { token : keywordMapper,
if (properties.hasOwnProperty(value.toLowerCase())) {
return "support.type";
}
else if (functions.hasOwnProperty(value.toLowerCase())) {
return "support.function";
}
else if (constants.hasOwnProperty(value.toLowerCase())) {
return "support.constant";
}
else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color";
}
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else {
return "text";
}
},
regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
} }
]; ];
var ruleset = lang.copyArray(base_ruleset); var ruleset = lang.copyArray(base_ruleset);

View file

@ -39,21 +39,20 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
var glslHighlightRules = function() { var glslHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("attribute|const|uniform|varying|break|continue|do|for|while|" + "attribute|const|uniform|varying|break|continue|do|for|while|" +
"if|else|in|out|inout|float|int|void|bool|true|false|" + "if|else|in|out|inout|float|int|void|bool|true|false|" +
"lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" + "lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" +
"mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" + "mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" +
"samplerCube|struct").split("|") "samplerCube|struct"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = (
("radians|degrees|sin|cos|tan|asin|acos|atan|pow|" + "radians|degrees|sin|cos|tan|asin|acos|atan|pow|" +
"exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" + "exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" +
"min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" + "min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" +
"normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" + "normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" +
@ -67,22 +66,19 @@ var glslHighlightRules = function() {
// The following two are only for MIME x-shader/x-vertex. // The following two are only for MIME x-shader/x-vertex.
"gl_Position|gl_PointSize|" + "gl_Position|gl_PointSize|" +
// The following five are only for MIME x-shader/x-fragment. // The following five are only for MIME x-shader/x-fragment.
"gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData").split("|") "gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData"
); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": buildinConstants
}, "identifier");
this.$rules = new c_cppHighlightRules().$rules; this.$rules = new c_cppHighlightRules().$rules;
this.$rules.start.forEach(function(rule) { this.$rules.start.forEach(function(rule) {
if (typeof rule.token == "function") if (typeof rule.token == "function")
rule.token = function(value) { rule.token = keywordMapper;
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
};
}) })
}; };

View file

@ -1,20 +1,22 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var GolangHighlightRules = function() { var GolangHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("true|else|false|break|case|return|goto|if|const|" + "true|else|false|break|case|return|goto|if|const|" +
"continue|struct|default|switch|for|" + "continue|struct|default|switch|for|" +
"func|import|package|chan|defer|fallthrough|go|interface|map|range" + "func|import|package|chan|defer|fallthrough|go|interface|map|range" +
"select|type|var").split("|") "select|type|var"
); );
var buildinConstants = ("nil|true|false|iota");
var buildinConstants = lang.arrayToMap( var keywordMapper = this.createKeywordMapper({
("nil|true|false|iota").split("|") "variable.language": "this",
); "keyword": keywords,
"constant.language": buildinConstants
}, "identifier");
this.$rules = { this.$rules = {
"start" : [ "start" : [
@ -57,16 +59,7 @@ define(function(require, exports, module) {
token : "keyword", // pre-compiler directivs token : "keyword", // pre-compiler directivs
regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
@ -119,9 +112,9 @@ define(function(require, exports, module) {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
} }
oop.inherits(GolangHighlightRules, TextHighlightRules); oop.inherits(GolangHighlightRules, TextHighlightRules);

View file

@ -2,31 +2,30 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var GroovyHighlightRules = function() { var GroovyHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("assert|with|abstract|continue|for|new|switch|" + "assert|with|abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" + "assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" + "boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" + "break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" + "byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" + "case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" + "catch|extends|int|short|try|" +
"char|final|interface|static|void|" + "char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" + "class|finally|long|strictfp|volatile|" +
"def|float|native|super|while").split("|") "def|float|native|super|while"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = (
("null|Infinity|NaN|undefined").split("|") "null|Infinity|NaN|undefined"
); );
var langClasses = lang.arrayToMap( var langClasses = (
("AbstractMethodError|AssertionError|ClassCircularityError|"+ "AbstractMethodError|AssertionError|ClassCircularityError|"+
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
"ExceptionInInitializerError|IllegalAccessError|"+ "ExceptionInInitializerError|IllegalAccessError|"+
"IllegalThreadStateException|InstantiationError|InternalError|"+ "IllegalThreadStateException|InstantiationError|InternalError|"+
@ -49,12 +48,18 @@ var GroovyHighlightRules = function() {
"ArrayStoreException|ClassCastException|LinkageError|"+ "ArrayStoreException|ClassCastException|LinkageError|"+
"NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
"Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
"Cloneable|Class|CharSequence|Comparable|String|Object").split("|") "Cloneable|Class|CharSequence|Comparable|String|Object"
);
var importClasses = lang.arrayToMap(
("").split("|")
); );
// TODO var importClasses = "";
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"support.function": langClasses,
"constant.language": buildinConstants
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -97,20 +102,7 @@ var GroovyHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (langClasses.hasOwnProperty(value))
return "support.function";
else if (importClasses.hasOwnProperty(value))
return "support.function";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
@ -172,7 +164,7 @@ var GroovyHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
}; };

View file

@ -2,20 +2,25 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var HaxeHighlightRules = function() { var HaxeHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std").split("|") "break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = (
("null|true|false").split("|") "null|true|false"
); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": buildinConstants
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -51,16 +56,7 @@ var HaxeHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"

View file

@ -2,15 +2,14 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var JavaHighlightRules = function() { var JavaHighlightRules = function() {
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap( var keywords = (
("abstract|continue|for|new|switch|" + "abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" + "assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" + "boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" + "break|double|implements|protected|throw|" +
@ -19,15 +18,14 @@ var JavaHighlightRules = function() {
"catch|extends|int|short|try|" + "catch|extends|int|short|try|" +
"char|final|interface|static|void|" + "char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" + "class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|") "const|float|native|super|while"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = ("null|Infinity|NaN|undefined");
("null|Infinity|NaN|undefined").split("|")
);
var langClasses = lang.arrayToMap(
("AbstractMethodError|AssertionError|ClassCircularityError|"+ var langClasses = (
"AbstractMethodError|AssertionError|ClassCircularityError|"+
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
"ExceptionInInitializerError|IllegalAccessError|"+ "ExceptionInInitializerError|IllegalAccessError|"+
"IllegalThreadStateException|InstantiationError|InternalError|"+ "IllegalThreadStateException|InstantiationError|InternalError|"+
@ -50,12 +48,17 @@ var JavaHighlightRules = function() {
"ArrayStoreException|ClassCastException|LinkageError|"+ "ArrayStoreException|ClassCastException|LinkageError|"+
"NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
"Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
"Cloneable|Class|CharSequence|Comparable|String|Object").split("|") "Cloneable|Class|CharSequence|Comparable|String|Object"
);
var importClasses = lang.arrayToMap(
("").split("|")
); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": buildinConstants,
"support.function": langClasses,
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -90,20 +93,7 @@ var JavaHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (langClasses.hasOwnProperty(value))
return "support.function";
else if (importClasses.hasOwnProperty(value))
return "support.function";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
@ -133,7 +123,7 @@ var JavaHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
}; };

View file

@ -41,157 +41,149 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
var lang = require("../lib/lang");
var xmlUtil = require("./xml_util"); var xmlUtil = require("./xml_util");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var LiquidHighlightRules = function() { var LiquidHighlightRules = function() {
// see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects // see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects
var functions = lang.arrayToMap( var functions = (
// Standard Filters // Standard Filters
("date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|" + "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|" +
"escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|" + "escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|" +
"truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split" "truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split"
).split("|")
); );
var keywords = lang.arrayToMap( var keywords = (
// Standard Tags // Standard Tags
("capture|endcapture|case|endcase|when|comment|endcomment|" + "capture|endcapture|case|endcase|when|comment|endcomment|" +
"cycle|for|endfor|in|reversed|if|endif|else|elsif|include|endinclude|unless|endunless|" + "cycle|for|endfor|in|reversed|if|endif|else|elsif|include|endinclude|unless|endunless|" +
// Commonly used tags // Commonly used tags
"style|text|image|widget|plugin|marker|endmarker|tablerow|endtablerow").split("|") "style|text|image|widget|plugin|marker|endmarker|tablerow|endtablerow"
); );
var builtinVariables = lang.arrayToMap( var builtinVariables = 'forloop|tablerowloop';
['forloop'] // "forloop\\.(length|index|index0|rindex|rindex0|first|last)|limit|offset|range" +
// ("forloop\\.(length|index|index0|rindex|rindex0|first|last)|limit|offset|range" +
// "tablerowloop\\.(length|index|index0|rindex|rindex0|first|last|col|col0|"+ // "tablerowloop\\.(length|index|index0|rindex|rindex0|first|last|col|col0|"+
// "col_first|col_last)").split("|") // "col_first|col_last)"
);
var definitions = lang.arrayToMap(("assign").split("|")); var definitions = ("assign");
var keywordMapper = this.createKeywordMapper({
"variable.language": builtinVariables,
"keyword": keywords,
"support.function": functions,
"keyword.definition": definitions
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
this.$rules = { this.$rules = {
start : [{ start : [{
token : "variable", token : "variable",
regex : "{%", regex : "{%",
next : "liquid_start" next : "liquid_start"
}, { }, {
token : "variable", token : "variable",
regex : "{{", regex : "{{",
next : "liquid_start" next : "liquid_start"
}, { }, {
token : "meta.tag", token : "meta.tag",
merge : true, merge : true,
regex : "<\\!\\[CDATA\\[", regex : "<\\!\\[CDATA\\[",
next : "cdata" next : "cdata"
}, { }, {
token : "xml_pe", token : "xml_pe",
regex : "<\\?.*?\\?>" regex : "<\\?.*?\\?>"
}, { }, {
token : "comment", token : "comment",
merge : true, merge : true,
regex : "<\\!--", regex : "<\\!--",
next : "comment" next : "comment"
}, { }, {
token : "meta.tag", token : "meta.tag",
regex : "<(?=\\s*script\\b)", regex : "<(?=\\s*script\\b)",
next : "script" next : "script"
}, { }, {
token : "meta.tag", token : "meta.tag",
regex : "<(?=\\s*style\\b)", regex : "<(?=\\s*style\\b)",
next : "style" next : "style"
}, { }, {
token : "meta.tag", // opening tag token : "meta.tag", // opening tag
regex : "<\\/?", regex : "<\\/?",
next : "tag" next : "tag"
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
}, { }, {
token : "text", token : "text",
regex : "[^<]+" regex : "[^<]+"
} ], } ],
cdata : [ { cdata : [ {
token : "text", token : "text",
regex : "\\]\\]>", regex : "\\]\\]>",
next : "start" next : "start"
}, { }, {
token : "text", token : "text",
merge : true, merge : true,
regex : "\\s+" regex : "\\s+"
}, { }, {
token : "text", token : "text",
merge : true, merge : true,
regex : ".+" regex : ".+"
} ], } ],
comment : [ { comment : [ {
token : "comment", token : "comment",
regex : ".*?-->", regex : ".*?-->",
next : "start" next : "start"
}, { }, {
token : "comment", token : "comment",
merge : true, merge : true,
regex : ".+" regex : ".+"
} ] , } ] ,
liquid_start : [{ liquid_start : [{
token: "variable", token: "variable",
regex: "}}", regex: "}}",
next: "start" next: "start"
}, { }, {
token: "variable", token: "variable",
regex: "%}", regex: "%}",
next: "start" next: "start"
}, { }, {
token : "string", // single line token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, { }, {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : "0[xX][0-9a-fA-F]+\\b"
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (functions.hasOwnProperty(value)) regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
return "support.function"; }, {
else if (keywords.hasOwnProperty(value)) token : "keyword.operator",
return "keyword"; regex : "\/|\\*|\\-|\\+|=|!=|\\?\\:"
else if (builtinVariables.hasOwnProperty(value)) }, {
return "variable.language"; token : "paren.lparen",
else if (definitions.hasOwnProperty(value)) regex : /[\[\({]/
return "keyword.definition"; }, {
else token : "paren.rparen",
return "identifier"; regex : /[\])}]/
}, }, {
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" token : "text",
}, { regex : "\\s+"
token : "keyword.operator", }]
regex : "\/|\\*|\\-|\\+|=|!=|\\?\\:"
}, {
token : "paren.lparen",
regex : /[\[\({]/
}, {
token : "paren.rparen",
regex : /[\])}]/
}, {
token : "text",
regex : "\\s+"
}]
}; };
xmlUtil.tag(this.$rules, "tag", "start"); xmlUtil.tag(this.$rules, "tag", "start");

View file

@ -41,22 +41,20 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var LuaHighlightRules = function() { var LuaHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("break|do|else|elseif|end|for|function|if|in|local|repeat|"+ "break|do|else|elseif|end|for|function|if|in|local|repeat|"+
"return|then|until|while|or|and|not").split("|") "return|then|until|while|or|and|not"
); );
var builtinConstants = lang.arrayToMap( var builtinConstants = ("true|false|nil|_G|_VERSION");
("true|false|nil|_G|_VERSION").split("|")
);
var builtinFunctions = lang.arrayToMap( var functions = (
("string|xpcall|package|tostring|print|os|unpack|require|"+ // builtinFunctions
"string|xpcall|package|tostring|print|os|unpack|require|"+
"getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+ "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+
"collectgarbage|getmetatable|module|rawset|math|debug|"+ "collectgarbage|getmetatable|module|rawset|math|debug|"+
"pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+ "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+
@ -75,25 +73,27 @@ var LuaHighlightRules = function() {
"gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+ "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+
"setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+ "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+
"foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+ "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+
"status|wrap|create|running").split("|") "status|wrap|create|running|"+
); // metatableMethods
"__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
var stdLibaries = lang.arrayToMap( "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber"
("string|package|os|io|math|debug|table|coroutine").split("|")
);
var metatableMethods = lang.arrayToMap(
("__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
"__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber").split("|")
); );
var futureReserved = lang.arrayToMap( var stdLibaries = ("string|package|os|io|math|debug|table|coroutine");
("").split("|")
); var futureReserved = "";
var deprecatedIn5152 = lang.arrayToMap( var deprecatedIn5152 = ("setn|foreach|foreachi|gcinfo|log10|maxn");
("setn|foreach|foreachi|gcinfo|log10|maxn").split("|")
); var keywordMapper = this.createKeywordMapper({
"keyword": keywords,
"support.function": functions,
"invalid.deprecated": deprecatedIn5152,
"constant.library": stdLibaries,
"constant.language": builtinConstants,
"invalid.illegal": futureReserved,
"variable.language": "this"
}, "identifier");
var strPre = ""; var strPre = "";
@ -105,13 +105,13 @@ var LuaHighlightRules = function() {
var intPart = "(?:\\d+)"; var intPart = "(?:\\d+)";
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
var floatNumber = "(?:" + pointFloat + ")"; var floatNumber = "(?:" + pointFloat + ")";
var comment_stack = [];
this.$rules = {
"start" :
var comment_stack = [];
this.$rules = {
"start" :
// bracketed comments // bracketed comments
[{ [{
token : "comment", // --[[ comment token : "comment", // --[[ comment
@ -132,7 +132,7 @@ var LuaHighlightRules = function() {
token : "comment", // --[====+[ comment token : "comment", // --[====+[ comment
regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
}, },
// multiline bracketed comments // multiline bracketed comments
{ {
token : "comment", // --[[ comment token : "comment", // --[[ comment
@ -169,20 +169,20 @@ var LuaHighlightRules = function() {
// you can never be too paranoid ;) // you can never be too paranoid ;)
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
comment_stack.push(match.length); comment_stack.push(match.length);
return "comment"; return "comment";
}, },
regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$', regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$',
merge : true, merge : true,
next : "qcomment5" next : "qcomment5"
}, },
// single line comments // single line comments
{ {
token : "comment", token : "comment",
regex : "\\-\\-.*$" regex : "\\-\\-.*$"
}, },
// bracketed strings // bracketed strings
{ {
token : "string", // [[ string token : "string", // [[ string
@ -203,7 +203,7 @@ var LuaHighlightRules = function() {
token : "string", // [====+[ string token : "string", // [====+[ string
regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
}, },
// multiline bracketed strings // multiline bracketed strings
{ {
token : "string", // [[ string token : "string", // [[ string
@ -236,14 +236,14 @@ var LuaHighlightRules = function() {
var pattern = /\[(\=+)\[/, match; var pattern = /\[(\=+)\[/, match;
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
comment_stack.push(match.length); comment_stack.push(match.length);
return "string"; return "string";
}, },
regex : strPre + '\\[\\={5}\\=*\\[.*$', regex : strPre + '\\[\\={5}\\=*\\[.*$',
merge : true, merge : true,
next : "qstring5" next : "qstring5"
}, },
{ {
token : "string", // " string token : "string", // " string
regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
@ -257,24 +257,7 @@ var LuaHighlightRules = function() {
token : "constant.numeric", // integer token : "constant.numeric", // integer
regex : integer + "\\b" regex : integer + "\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal";
else if (stdLibaries.hasOwnProperty(value))
return "constant.library";
else if (deprecatedIn5152.hasOwnProperty(value))
return "invalid.deprecated";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else if (metatableMethods.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
@ -289,7 +272,7 @@ var LuaHighlightRules = function() {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
} ], } ],
"qcomment": [ { "qcomment": [ {
token : "comment", token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
@ -336,7 +319,7 @@ var LuaHighlightRules = function() {
regex : '.+' regex : '.+'
} ], } ],
"qcomment5": [ { "qcomment5": [ {
token : function(value){ token : function(value){
// very hackish, mutates the qcomment5 field on the fly. // very hackish, mutates the qcomment5 field on the fly.
var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match; var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match;
rule.next = "start"; rule.next = "start";
@ -347,7 +330,7 @@ var LuaHighlightRules = function() {
rule.next = "qcomment5"; rule.next = "qcomment5";
} }
} }
return "comment"; return "comment";
}, },
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
@ -357,7 +340,7 @@ var LuaHighlightRules = function() {
merge : true, merge : true,
regex : '.+' regex : '.+'
} ], } ],
"qstring": [ { "qstring": [ {
token : "string", token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
@ -404,7 +387,7 @@ var LuaHighlightRules = function() {
regex : '.+' regex : '.+'
} ], } ],
"qstring5": [ { "qstring5": [ {
token : function(value){ token : function(value){
// very hackish, mutates the qstring5 field on the fly. // very hackish, mutates the qstring5 field on the fly.
var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match; var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match;
rule.next = "start"; rule.next = "start";
@ -415,7 +398,7 @@ var LuaHighlightRules = function() {
rule.next = "qstring5"; rule.next = "qstring5";
} }
} }
return "string"; return "string";
}, },
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
@ -425,7 +408,7 @@ var LuaHighlightRules = function() {
merge : true, merge : true,
regex : '.+' regex : '.+'
} ] } ]
}; };
} }

View file

@ -41,24 +41,21 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var OcamlHighlightRules = function() { var OcamlHighlightRules = function() {
var keywords = lang.arrayToMap(( var keywords = (
"and|as|assert|begin|class|constraint|do|done|downto|else|end|" + "and|as|assert|begin|class|constraint|do|done|downto|else|end|" +
"exception|external|for|fun|function|functor|if|in|include|" + "exception|external|for|fun|function|functor|if|in|include|" +
"inherit|initializer|lazy|let|match|method|module|mutable|new|" + "inherit|initializer|lazy|let|match|method|module|mutable|new|" +
"object|of|open|or|private|rec|sig|struct|then|to|try|type|val|" + "object|of|open|or|private|rec|sig|struct|then|to|try|type|val|" +
"virtual|when|while|with").split("|") "virtual|when|while|with"
); );
var builtinConstants = lang.arrayToMap( var builtinConstants = ("true|false");
("true|false").split("|")
);
var builtinFunctions = lang.arrayToMap(( var builtinFunctions = (
"abs|abs_big_int|abs_float|abs_num|abstract_tag|accept|access|acos|add|" + "abs|abs_big_int|abs_float|abs_num|abstract_tag|accept|access|acos|add|" +
"add_available_units|add_big_int|add_buffer|add_channel|add_char|" + "add_available_units|add_big_int|add_buffer|add_channel|add_char|" +
"add_initializer|add_int_big_int|add_interfaces|add_num|add_string|" + "add_initializer|add_int_big_int|add_interfaces|add_num|add_string|" +
@ -239,7 +236,14 @@ var OcamlHighlightRules = function() {
"MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" + "MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" +
"Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" + "Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" +
"Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak" "Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak"
).split("|")); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"constant.language": builtinConstants,
"support.function": builtinFunctions
}, "identifier");
var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
var octInteger = "(?:0[oO]?[0-7]+)"; var octInteger = "(?:0[oO]?[0-7]+)";
@ -293,16 +297,7 @@ var OcamlHighlightRules = function() {
regex : integer + "\\b" regex : integer + "\\b"
}, },
{ {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, },
{ {

View file

@ -39,22 +39,19 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PerlHighlightRules = function() { var PerlHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" +
"no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars").split("|") "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = ("ARGV|ENV|INC|SIG");
("ARGV|ENV|INC|SIG").split("|")
);
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" + "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" +
"gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" + "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" +
"getpeername|setpriority|getprotoent|setprotoent|getpriority|" + "getpeername|setpriority|getprotoent|setprotoent|getpriority|" +
"endprotoent|getservent|setservent|endservent|sethostent|socketpair|" + "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" +
@ -75,9 +72,15 @@ var PerlHighlightRules = function() {
"join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" + "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" +
"keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" + "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" +
"eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" + "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" +
"map|die|uc|lc|do").split("|") "map|die|uc|lc|do"
); );
var keywordMapper = this.createKeywordMapper({
"keyword": keywords,
"constant.language": buildinConstants,
"support.function": builtinFunctions
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -112,16 +115,7 @@ var PerlHighlightRules = function() {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",

View file

@ -32,10 +32,10 @@ var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules;
var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules;
var PgsqlHighlightRules = function() { var PgsqlHighlightRules = function() {
// Keywords, functions, operators last updated for pg 9.1. // Keywords, functions, operators last updated for pg 9.1.
var keywords = lang.arrayToMap( var keywords = (
("abort|absolute|abstime|access|aclitem|action|add|admin|after|aggregate|all|also|alter|always|" + "abort|absolute|abstime|access|aclitem|action|add|admin|after|aggregate|all|also|alter|always|" +
"analyse|analyze|and|any|anyarray|anyelement|anyenum|anynonarray|array|as|asc|assertion|" + "analyse|analyze|and|any|anyarray|anyelement|anyenum|anynonarray|array|as|asc|assertion|" +
"assignment|asymmetric|at|attribute|authorization|backward|before|begin|between|bigint|" + "assignment|asymmetric|at|attribute|authorization|backward|before|begin|between|bigint|" +
"binary|bit|bool|boolean|both|box|bpchar|by|bytea|cache|called|cascade|cascaded|case|cast|" + "binary|bit|bool|boolean|both|box|bpchar|by|bytea|cache|called|cascade|cascaded|case|cast|" +
@ -74,12 +74,12 @@ var PgsqlHighlightRules = function() {
"unlogged|until|update|user|using|uuid|vacuum|valid|validate|validator|value|values|varbit|" + "unlogged|until|update|user|using|uuid|vacuum|valid|validate|validator|value|values|varbit|" +
"varchar|variadic|varying|verbose|version|view|void|volatile|when|where|whitespace|window|" + "varchar|variadic|varying|verbose|version|view|void|volatile|when|where|whitespace|window|" +
"with|without|work|wrapper|write|xid|xml|xmlattributes|xmlconcat|xmlelement|xmlexists|" + "with|without|work|wrapper|write|xid|xml|xmlattributes|xmlconcat|xmlelement|xmlexists|" +
"xmlforest|xmlparse|xmlpi|xmlroot|xmlserialize|year|yes|zone").split("|") "xmlforest|xmlparse|xmlpi|xmlroot|xmlserialize|year|yes|zone"
); );
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("RI_FKey_cascade_del|RI_FKey_cascade_upd|RI_FKey_check_ins|RI_FKey_check_upd|" + "RI_FKey_cascade_del|RI_FKey_cascade_upd|RI_FKey_check_ins|RI_FKey_check_upd|" +
"RI_FKey_noaction_del|RI_FKey_noaction_upd|RI_FKey_restrict_del|RI_FKey_restrict_upd|" + "RI_FKey_noaction_del|RI_FKey_noaction_upd|RI_FKey_restrict_del|RI_FKey_restrict_upd|" +
"RI_FKey_setdefault_del|RI_FKey_setdefault_upd|RI_FKey_setnull_del|" + "RI_FKey_setdefault_del|RI_FKey_setdefault_upd|RI_FKey_setnull_del|" +
"RI_FKey_setnull_upd|abbrev|abs|abstime|abstimeeq|abstimege|abstimegt|abstimein|abstimele|" + "RI_FKey_setnull_upd|abbrev|abs|abstime|abstimeeq|abstimege|abstimegt|abstimein|abstimele|" +
@ -392,9 +392,15 @@ var PgsqlHighlightRules = function() {
"win866_to_mic|win866_to_win1251|win_to_utf8|xideq|xideqint4|xidin|xidout|xidrecv|xidsend|" + "win866_to_mic|win866_to_win1251|win_to_utf8|xideq|xideqint4|xidin|xidout|xidrecv|xidsend|" +
"xml|xml_in|xml_is_well_formed|xml_is_well_formed_content|xml_is_well_formed_document|" + "xml|xml_in|xml_is_well_formed|xml_is_well_formed_content|xml_is_well_formed_document|" +
"xml_out|xml_recv|xml_send|xmlagg|xmlcomment|xmlconcat2|xmlexists|xmlvalidate|xpath|" + "xml_out|xml_recv|xml_send|xmlagg|xmlcomment|xmlconcat2|xmlexists|xmlvalidate|xpath|" +
"xpath_exists").split("|") "xpath_exists"
); );
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
}, "identifier", true);
var sqlRules = [ var sqlRules = [
{ {
token : "string", // single line string -- assume dollar strings if multi-line for now token : "string", // single line string -- assume dollar strings if multi-line for now
@ -406,16 +412,7 @@ var PgsqlHighlightRules = function() {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { }, {
token : function(value) { token : keywordMapper,
value = value.toLowerCase();
if (keywords.hasOwnProperty(value)) {
return "keyword";
} else if (builtinFunctions.hasOwnProperty(value)) {
return "support.function";
} else {
return "identifier";
}
},
regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers
}, { }, {
token : "keyword.operator", token : "keyword.operator",
@ -434,14 +431,14 @@ var PgsqlHighlightRules = function() {
regex : "\\s+" regex : "\\s+"
} }
]; ];
this.$rules = { this.$rules = {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "--.*$" regex : "--.*$"
}, },
DocCommentHighlightRules.getStartRule("doc-start"), DocCommentHighlightRules.getStartRule("doc-start"),
{ {
token : "comment", // multi-line comment token : "comment", // multi-line comment
@ -457,7 +454,7 @@ var PgsqlHighlightRules = function() {
regex : "^\\\\[\\S]+.*$" regex : "^\\\\[\\S]+.*$"
} }
], ],
"statement" : [ "statement" : [
{ {
token : "comment", token : "comment",
@ -489,7 +486,7 @@ var PgsqlHighlightRules = function() {
next : "dollarStatementString" next : "dollarStatementString"
} }
].concat(sqlRules), ].concat(sqlRules),
"dollarSql" : [ "dollarSql" : [
{ {
token : "comment", token : "comment",
@ -509,7 +506,7 @@ var PgsqlHighlightRules = function() {
next : "dollarSqlString" next : "dollarSqlString"
} }
].concat(sqlRules), ].concat(sqlRules),
"comment" : [ "comment" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
@ -521,7 +518,7 @@ var PgsqlHighlightRules = function() {
regex : ".+" regex : ".+"
} }
], ],
"commentStatement" : [ "commentStatement" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
@ -533,7 +530,7 @@ var PgsqlHighlightRules = function() {
regex : ".+" regex : ".+"
} }
], ],
"commentDollarSql" : [ "commentDollarSql" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
@ -545,7 +542,7 @@ var PgsqlHighlightRules = function() {
regex : ".+" regex : ".+"
} }
], ],
"dollarStatementString" : [ "dollarStatementString" : [
{ {
token : "string", // closing dollarstring token : "string", // closing dollarstring
@ -557,7 +554,7 @@ var PgsqlHighlightRules = function() {
regex : ".+" regex : ".+"
} }
], ],
"dollarSqlString" : [ "dollarSqlString" : [
{ {
token : "string", // closing dollarstring token : "string", // closing dollarstring
@ -570,7 +567,7 @@ var PgsqlHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
this.embedRules(PerlHighlightRules, "perl-", [{token : "string", regex : "\\$perl\\$", next : "statement"}]); this.embedRules(PerlHighlightRules, "perl-", [{token : "string", regex : "\\$perl\\$", next : "statement"}]);
this.embedRules(PythonHighlightRules, "python-", [{token : "string", regex : "\\$python\\$", next : "statement"}]); this.embedRules(PythonHighlightRules, "python-", [{token : "string", regex : "\\$python\\$", next : "statement"}]);

View file

@ -2,18 +2,17 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PowershellHighlightRules = function() { var PowershellHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("function|if|else|elseif|switch|while|default|for|do|until|break|continue|" + "function|if|else|elseif|switch|while|default|for|do|until|break|continue|" +
"foreach|return|filter|in|trap|throw|param|begin|process|end").split("|") "foreach|return|filter|in|trap|throw|param|begin|process|end"
); );
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" + "Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" +
"Set-Location|Get-ChildItem|Clear-Item|Get-Command|Measure-Command|Trace-Command|" + "Set-Location|Get-ChildItem|Clear-Item|Get-Command|Measure-Command|Trace-Command|" +
"Add-Computer|Checkpoint-Computer|Remove-Computer|Restart-Computer|Restore-Computer|Stop-Computer|" + "Add-Computer|Checkpoint-Computer|Remove-Computer|Restart-Computer|Restore-Computer|Stop-Computer|" +
"Reset-ComputerMachinePassword|Test-ComputerSecureChannel|Add-Content|Get-Content|Set-Content|Clear-Content|" + "Reset-ComputerMachinePassword|Test-ComputerSecureChannel|Add-Content|Get-Content|Set-Content|Clear-Content|" +
@ -53,12 +52,18 @@ var PowershellHighlightRules = function() {
"Write-Output|Write-Progress|Write-Verbose|Write-Warning|Set-WmiInstance|Invoke-WmiMethod|" + "Write-Output|Write-Progress|Write-Verbose|Write-Warning|Set-WmiInstance|Invoke-WmiMethod|" +
"Get-WmiObject|Remove-WmiObject|Connect-WSMan|Disconnect-WSMan|Test-WSMan|Invoke-WSManAction|" + "Get-WmiObject|Remove-WmiObject|Connect-WSMan|Disconnect-WSMan|Test-WSMan|Invoke-WSManAction|" +
"Disable-WSManCredSSP|Enable-WSManCredSSP|Get-WSManCredSSP|New-WSManInstance|Get-WSManInstance|Set-WSManInstance|" + "Disable-WSManCredSSP|Enable-WSManCredSSP|Get-WSManCredSSP|New-WSManInstance|Get-WSManInstance|Set-WSManInstance|" +
"Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption").split("|")); "Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords
}, "identifier");
var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" + var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" +
"ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" + "ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" +
"is|isnot|as|" + "is|isnot|as|" +
"and|or|band|bor|not"; "and|or|band|bor|not";
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -90,14 +95,7 @@ var PowershellHighlightRules = function() {
token : "variable.instance", token : "variable.instance",
regex : "[$][a-zA-Z][a-zA-Z0-9_]*\\b" regex : "[$][a-zA-Z][a-zA-Z0-9_]*\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"

View file

@ -43,35 +43,39 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PythonHighlightRules = function() { var PythonHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" +
"finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" +
"raise|return|try|while|with|yield").split("|") "raise|return|try|while|with|yield"
); );
var builtinConstants = lang.arrayToMap( var builtinConstants = (
("True|False|None|NotImplemented|Ellipsis|__debug__").split("|") "True|False|None|NotImplemented|Ellipsis|__debug__"
); );
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" +
"eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" +
"binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" +
"float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" +
"chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" +
"cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" +
"__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" +
"buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern").split("|") "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern"
); );
var futureReserved = lang.arrayToMap( //var futureReserved = "";
("").split("|") var keywordMapper = this.createKeywordMapper({
); "invalid.deprecated": "debugger",
"support.function": builtinFunctions,
//"invalid.illegal": futureReserved,
"constant.language": builtinConstants,
"keyword": keywords
}, "identifier");
var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?";
@ -127,20 +131,7 @@ var PythonHighlightRules = function() {
token : "constant.numeric", // integer token : "constant.numeric", // integer
regex : integer + "\\b" regex : integer + "\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",

View file

@ -40,14 +40,13 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var RubyHighlightRules = function() { var RubyHighlightRules = function() {
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" + "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
"assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" + "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
"assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" + "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
"assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" + "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
"assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" + "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
@ -75,25 +74,33 @@ var RubyHighlightRules = function() {
"filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
"translate|localize|extract_locale_from_tld|t|l|caches_page|expire_page|caches_action|expire_action|" + "translate|localize|extract_locale_from_tld|t|l|caches_page|expire_page|caches_action|expire_action|" +
"cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
"has_many|has_one|belongs_to|has_and_belongs_to_many").split("|") "has_many|has_one|belongs_to|has_and_belongs_to_many"
); );
var keywords = lang.arrayToMap( var keywords = (
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
"__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
"redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|") "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield"
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = (
("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
"RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|") "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING"
); );
var builtinVariables = lang.arrayToMap( var builtinVariables = (
("\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" + "\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" +
"$!|root_url|flash|session|cookies|params|request|response|logger").split("|") "$!|root_url|flash|session|cookies|params|request|response|logger|self"
); );
var keywordMapper = this.createKeywordMapper({
"keyword": keywords,
"constant.language": buildinConstants,
"variable.language": builtinVariables,
"support.function": builtinFunctions,
"invalid.deprecated": "debugger" // TODO is this a remnant from js mode?
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -141,22 +148,7 @@ var RubyHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "self")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinVariables.hasOwnProperty(value))
return "variable.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"

View file

@ -47,14 +47,11 @@ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocComme
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var scadHighlightRules = function() { var scadHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({
var keywords = lang.arrayToMap( "variable.language": "this",
("module|if|else|for").split("|") "keyword": "module|if|else|for",
); "constant.language": "NULL",
}, "identifier");
var buildinConstants = lang.arrayToMap(
("NULL").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -97,17 +94,8 @@ var scadHighlightRules = function() {
}, { }, {
token : "keyword", // pre-compiler directivs token : "keyword", // pre-compiler directivs
regex : "(?:use|include)" regex : "(?:use|include)"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",

View file

@ -2,27 +2,22 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var ScalaHighlightRules = function() { var ScalaHighlightRules = function() {
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap( var keywords = (
(
"case|default|do|else|for|if|match|while|throw|return|try|catch|finally|yield|" + "case|default|do|else|for|if|match|while|throw|return|try|catch|finally|yield|" +
"abstract|class|def|extends|final|forSome|implicit|implicits|import|lazy|new|object|" + "abstract|class|def|extends|final|forSome|implicit|implicits|import|lazy|new|object|" +
"override|package|private|protected|sealed|super|this|trait|type|val|var|with" "override|package|private|protected|sealed|super|this|trait|type|val|var|with"
).split("|")
); );
var buildinConstants = lang.arrayToMap( var buildinConstants = ("true|false");
("true|false").split("|")
); var langClasses = (
"AbstractMethodError|AssertionError|ClassCircularityError|"+
var langClasses = lang.arrayToMap(
("AbstractMethodError|AssertionError|ClassCircularityError|"+
"ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
"ExceptionInInitializerError|IllegalAccessError|"+ "ExceptionInInitializerError|IllegalAccessError|"+
"IllegalThreadStateException|InstantiationError|InternalError|"+ "IllegalThreadStateException|InstantiationError|InternalError|"+
@ -49,13 +44,17 @@ var ScalaHighlightRules = function() {
"Cloneable|Class|CharSequence|Comparable|String|Object|" + "Cloneable|Class|CharSequence|Comparable|String|Object|" +
"Unit|Any|AnyVal|AnyRef|Null|ScalaObject|Singleton|Seq|Iterable|List|" + "Unit|Any|AnyVal|AnyRef|Null|ScalaObject|Singleton|Seq|Iterable|List|" +
"Option|Array|Char|Byte|Short|Int|Long|Nothing" "Option|Array|Char|Byte|Short|Int|Long|Nothing"
).split("|")
);
var importClasses = lang.arrayToMap(
("").split("|")
); );
var keywordMapper = this.createKeywordMapper({
"variable.language": "this",
"keyword": keywords,
"support.function": langClasses,
"constant.language": buildinConstants
}, "identifier");
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -95,20 +94,7 @@ var ScalaHighlightRules = function() {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (langClasses.hasOwnProperty(value))
return "support.function";
else if (importClasses.hasOwnProperty(value))
return "support.function";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences // TODO: Unicode escape sequences
// TODO: Unicode identifiers // TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
@ -168,7 +154,7 @@ var ScalaHighlightRules = function() {
} }
] ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
}; };

View file

@ -41,21 +41,19 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var ShHighlightRules = function() { var ShHighlightRules = function() {
var reservedKeywords = lang.arrayToMap( var reservedKeywords = (
('!|{|}|case|do|done|elif|else|'+ '!|{|}|case|do|done|elif|else|'+
'esac|fi|for|if|in|then|until|while|'+ 'esac|fi|for|if|in|then|until|while|'+
'&|;|export|local|read|typeset|unset|'+ '&|;|export|local|read|typeset|unset|'+
'elif|select|set' 'elif|select|set'
).split('|')
); );
var languageConstructs = lang.arrayToMap( var languageConstructs = (
('[|]|alias|bg|bind|break|builtin|'+ '[|]|alias|bg|bind|break|builtin|'+
'cd|command|compgen|complete|continue|'+ 'cd|command|compgen|complete|continue|'+
'dirs|disown|echo|enable|eval|exec|'+ 'dirs|disown|echo|enable|eval|exec|'+
'exit|fc|fg|getopts|hash|help|history|'+ 'exit|fc|fg|getopts|hash|help|history|'+
@ -63,9 +61,14 @@ var ShHighlightRules = function() {
'pwd|return|set|shift|shopt|source|'+ 'pwd|return|set|shift|shopt|source|'+
'suspend|test|times|trap|type|ulimit|'+ 'suspend|test|times|trap|type|ulimit|'+
'umask|unalias|wait' 'umask|unalias|wait'
).split('|')
); );
var keywordMapper = this.createKeywordMapper({
"keyword": reservedKeywords,
"constant.language": languageConstructs,
"invalid.deprecated": "debugger"
}, "identifier");
var integer = "(?:(?:[1-9]\\d*)|(?:0))"; var integer = "(?:(?:[1-9]\\d*)|(?:0))";
// var integer = "(?:" + decimalInteger + ")"; // var integer = "(?:" + decimalInteger + ")";
@ -112,16 +115,7 @@ var ShHighlightRules = function() {
token : "constant.numeric", // integer token : "constant.numeric", // integer
regex : integer + "\\b" regex : integer + "\\b"
}, { }, {
token : function(value) { token : keywordMapper,
if (reservedKeywords.hasOwnProperty(value))
return "keyword";
else if (languageConstructs.hasOwnProperty(value))
return "constant.language";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",

View file

@ -22,24 +22,29 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SqlHighlightRules = function() { var SqlHighlightRules = function() {
var keywords = lang.arrayToMap( var keywords = (
("select|from|where|and|or|group|by|order|limit|offset|having|as|case|" + "select|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
"when|else|end|type|left|right|join|on|outer|desc|asc").split("|") "when|else|end|type|left|right|join|on|outer|desc|asc"
); );
var builtinConstants = lang.arrayToMap( var builtinConstants = (
("true|false|null").split("|") "true|false|null"
); );
var builtinFunctions = lang.arrayToMap( var builtinFunctions = (
("count|min|max|avg|sum|rank|now|coalesce").split("|") "count|min|max|avg|sum|rank|now|coalesce"
); );
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants
}, "identifier", true);
this.$rules = { this.$rules = {
"start" : [ { "start" : [ {
token : "comment", token : "comment",
@ -54,17 +59,7 @@ var SqlHighlightRules = function() {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { }, {
token : function(value) { token : keywordMapper,
value = value.toLowerCase();
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",

View file

@ -39,15 +39,12 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var TclHighlightRules = function() { var TclHighlightRules = function() {
var builtinFunctions = lang.arrayToMap( //TODO var builtinFunctions = "";
("").split("|")
);
this.$rules = { this.$rules = {
"start" : [ "start" : [
{ {
@ -86,12 +83,7 @@ var TclHighlightRules = function() {
token : "support.function", token : "support.function",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::" regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::"
}, { }, {
token : function(value) { token : "identifier",
if (builtinFunctions.hasOwnProperty(value))
return "keyword";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "paren.lparen", token : "paren.lparen",

View file

@ -38,15 +38,14 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var XQueryHighlightRules = function() { var XQueryHighlightRules = function() {
var keywords = lang.arrayToMap( var keywordMapper = this.createKeywordMapper({
("after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning").split("|") keyword: "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning"
); }, "identifier");
// regexp must not have capturing parentheses // regexp must not have capturing parentheses
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -89,12 +88,7 @@ var XQueryHighlightRules = function() {
token: "support.function", token: "support.function",
regex: "\\w[\\w+_\\-:]+(?=\\()" regex: "\\w[\\w+_\\-:]+(?=\\()"
}, { }, {
token : function(value) { token : keywordMapper,
if (keywords[value])
return "keyword";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token: "keyword.operator", token: "keyword.operator",