don't merge tokens (Includes coding style cleanups)

fix #355
This commit is contained in:
Fabian Jakobs 2011-08-01 15:01:50 +02:00
commit 1c5fb5b75a
28 changed files with 835 additions and 883 deletions

View file

@ -31,7 +31,6 @@
<option value="java">Java</option>
<option value="csharp">C#</option>
<option value="c_cpp">C++</option>
<option value="svg">SVG</option>
<option value="clojure">Clojure</option>
<option value="ocaml">OCaml</option>
<option value="textile">Textile</option>
@ -221,9 +220,7 @@
for (var i=0; i<items.length; i++) {
alert(items[i] + "juhu");
} // Real Tab.
}
// A magic character: >> ぁ <<
</script>
}</script>
<script type="text/editor" id="csstext">.text-layer {
font-family: Monaco, "Courier New", monospace;
@ -302,8 +299,7 @@ for i in sys.argv[1:]:
print repr(i), "not a numeric value"
else:
celsius=(fahrenheit-32)*5.0/9.0
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))
</script>
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))</script>
<script type="text/editor" id="phptext"><?php
@ -674,8 +670,7 @@ th.join()
assert counter.get() == 12
</script>
<script type="text/editor" id="scala">
//http://www.scala-lang.org/node/227
<script type="text/editor" id="scala">//http://www.scala-lang.org/node/227
/* Defines a new method 'sort' for array objects */
object implicits extends Application {
implicit def arrayWrapper[A : ClassManifest](x: Array[A]) =
@ -686,8 +681,7 @@ object implicits extends Application {
}
val x = Array(2, 3, 1, 4)
println("x = "+ x.sort((x: Int, y: Int) => x < y))
}
</script>
}</script>
<input id="cockpitInput" type="text"/>
<script type="text/javascript">

View file

@ -384,17 +384,10 @@ var Text = function(parentEl) {
var screenColumn = 0;
var self = this;
function addToken(token, value) {
screenColumn = self.$renderToken(
stringBuilder, screenColumn, token, value
);
}
if (!splits || splits.length == 0) {
if (!splits || splits.length == 0)
splitChars = Number.MAX_VALUE;
} else {
else
splitChars = splits[0];
}
if (!onlyContents) {
stringBuilder.push("<div class='ace_line' style='height:",
@ -408,11 +401,17 @@ var Text = function(parentEl) {
var value = token.value;
if (chars + value.length < splitChars) {
addToken(token, value);
screenColumn = self.$renderToken(
stringBuilder, screenColumn, token, value
);
chars += value.length;
} else {
}
else {
while (chars + value.length >= splitChars) {
addToken(token, value.substring(0, splitChars - chars));
screenColumn = self.$renderToken(
stringBuilder, screenColumn,
token, value.substring(0, splitChars - chars)
);
value = value.substring(splitChars - chars);
chars = splitChars;
@ -430,17 +429,18 @@ var Text = function(parentEl) {
}
if (value.length != 0) {
chars += value.length;
addToken(token, value);
screenColumn = self.$renderToken(
stringBuilder, screenColumn, token, value
);
}
}
}
if (this.showInvisibles) {
if (lastRow !== this.session.getLength() - 1) {
if (lastRow !== this.session.getLength() - 1)
stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
} else {
else
stringBuilder.push("<span class='ace_invisible'>" + this.EOF_CHAR + "</span>");
}
}
stringBuilder.push("</div>");
};

View file

@ -67,96 +67,102 @@ var c_cppHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant", // <CONSTANT>
regex : "<[a-zA-Z0-9.]+>"
}, {
}, {
token : "keyword", // pre-compiler directivs
regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
}, {
token : function(value) {
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"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
token : function(value) {
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"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]
};

View file

@ -49,78 +49,78 @@ var ClojureHighlightRules = function() {
var builtinFunctions = lang.arrayToMap(
('* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' +
'*command-line-args* *compile-files* *compile-path* *e *err* *file* ' +
'*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' +
'*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' +
'*read-eval* *source-path* *use-context-classloader* ' +
'*warn-on-reflection* + - -> -&gt; ->> -&gt;&gt; .. / < &lt; <= &lt;= = ' +
'== > &gt; >= &gt;= accessor aclone ' +
'add-classpath add-watch agent agent-errors aget alength alias all-ns ' +
'alter alter-meta! alter-var-root amap ancestors and apply areduce ' +
'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? ' +
'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-shift-right bit-test bit-xor boolean boolean-array booleans ' +
'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' +
'char-escape-string char-name-string char? chars chunk chunk-append ' +
'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' +
'class class? clear-agent-errors clojure-version coll? comment commute ' +
'comp comparator compare compare-and-set! compile complement concat cond ' +
'condp conj conj! cons constantly construct-proxy contains? count ' +
'counted? create-ns create-struct cycle dec decimal? declare definline ' +
'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' +
'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' +
'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' +
'double-array doubles drop drop-last drop-while empty empty? ensure ' +
'enumeration-seq eval even? every? false? ffirst file-seq filter find ' +
'find-doc find-ns find-var first float float-array float? floats flush ' +
'fn fn? fnext for force format future future-call future-cancel ' +
'future-cancelled? future-done? future? gen-class gen-interface gensym ' +
'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 ' +
'in-ns inc init-proxy instance? int int-array integer? interleave intern ' +
'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 ' +
'list* list? load load-file load-reader load-string loaded-libs locking ' +
'long long-array longs loop macroexpand macroexpand-1 make-array ' +
'make-hierarchy map map? mapcat max max-key memfn memoize merge ' +
'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= ' +
'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? ' +
'or parents partial partition pcalls peek persistent! pmap pop pop! ' +
'pop-thread-bindings pos? pr pr-str prefer-method prefers ' +
'primitives-classnames print print-ctor print-doc print-dup print-method ' +
'print-namespace-doc print-simple print-special-doc print-str printf ' +
'println println-str prn prn-str promise proxy proxy-call-with-super ' +
'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' +
'rand rand-int range ratio? rational? rationalize re-find re-groups ' +
'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 ' +
'refer refer-clojure release-pending-sends rem remove remove-method ' +
'remove-ns remove-watch repeat repeatedly replace replicate require ' +
'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' +
'rsubseq second select-keys send send-off seq seq? seque sequence ' +
'sequential? set set-validator! set? short short-array shorts ' +
'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' +
'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' +
'split-at split-with str stream? string? struct struct-map subs subseq ' +
'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 ' +
'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' +
'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' +
'unchecked-remainder unchecked-subtract underive unquote ' +
'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 ' +
'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 ' +
'zero? zipmap ').split(" ")
'*command-line-args* *compile-files* *compile-path* *e *err* *file* ' +
'*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' +
'*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' +
'*read-eval* *source-path* *use-context-classloader* ' +
'*warn-on-reflection* + - -> -&gt; ->> -&gt;&gt; .. / < &lt; <= &lt;= = ' +
'== > &gt; >= &gt;= accessor aclone ' +
'add-classpath add-watch agent agent-errors aget alength alias all-ns ' +
'alter alter-meta! alter-var-root amap ancestors and apply areduce ' +
'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? ' +
'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-shift-right bit-test bit-xor boolean boolean-array booleans ' +
'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' +
'char-escape-string char-name-string char? chars chunk chunk-append ' +
'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' +
'class class? clear-agent-errors clojure-version coll? comment commute ' +
'comp comparator compare compare-and-set! compile complement concat cond ' +
'condp conj conj! cons constantly construct-proxy contains? count ' +
'counted? create-ns create-struct cycle dec decimal? declare definline ' +
'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' +
'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' +
'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' +
'double-array doubles drop drop-last drop-while empty empty? ensure ' +
'enumeration-seq eval even? every? false? ffirst file-seq filter find ' +
'find-doc find-ns find-var first float float-array float? floats flush ' +
'fn fn? fnext for force format future future-call future-cancel ' +
'future-cancelled? future-done? future? gen-class gen-interface gensym ' +
'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 ' +
'in-ns inc init-proxy instance? int int-array integer? interleave intern ' +
'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 ' +
'list* list? load load-file load-reader load-string loaded-libs locking ' +
'long long-array longs loop macroexpand macroexpand-1 make-array ' +
'make-hierarchy map map? mapcat max max-key memfn memoize merge ' +
'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= ' +
'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? ' +
'or parents partial partition pcalls peek persistent! pmap pop pop! ' +
'pop-thread-bindings pos? pr pr-str prefer-method prefers ' +
'primitives-classnames print print-ctor print-doc print-dup print-method ' +
'print-namespace-doc print-simple print-special-doc print-str printf ' +
'println println-str prn prn-str promise proxy proxy-call-with-super ' +
'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' +
'rand rand-int range ratio? rational? rationalize re-find re-groups ' +
'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 ' +
'refer refer-clojure release-pending-sends rem remove remove-method ' +
'remove-ns remove-watch repeat repeatedly replace replicate require ' +
'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' +
'rsubseq second select-keys send send-off seq seq? seque sequence ' +
'sequential? set set-validator! set? short short-array shorts ' +
'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' +
'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' +
'split-at split-with str stream? string? struct struct-map subs subseq ' +
'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 ' +
'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' +
'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' +
'unchecked-remainder unchecked-subtract underive unquote ' +
'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 ' +
'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 ' +
'zero? zipmap ').split(" ")
);
var keywords = lang.arrayToMap(
('def do fn if let loop monitor-enter monitor-exit new quote recur set! ' +
'throw try var').split(" ")
'throw try var').split(" ")
);
var buildinConstants = lang.arrayToMap(
@ -133,98 +133,82 @@ var ClojureHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : ";.*$"
}, {
{
token : "comment",
regex : ";.*$"
}, {
token : "comment", // multi line comment
regex : "^\=begin$",
next : "comment"
},
{
token : "keyword", //parens
regex : "[\\(|\\)]"
},
{
token : "keyword", //lists
regex : "[\\'\\(]"
},
{
token : "keyword", //vectors
regex : "[\\[|\\]]"
},
{
token : "keyword", //sets and maps
regex : "[\\{|\\}|\\#\\{|\\#\\}]"
},
{
}, {
token : "keyword", //parens
regex : "[\\(|\\)]"
}, {
token : "keyword", //lists
regex : "[\\'\\(]"
}, {
token : "keyword", //vectors
regex : "[\\[|\\]]"
}, {
token : "keyword", //sets and maps
regex : "[\\{|\\}|\\#\\{|\\#\\}]"
}, {
token : "keyword", // ampersands
regex : '[\\&]'
},
{
}, {
token : "keyword", // metadata
regex : '[\\#\\^\\{]'
},
{
}, {
token : "keyword", // anonymous fn syntactic sugar
regex : '[\\%]'
},
{
}, {
token : "keyword", // deref reader macro
regex : '[@]'
},
{
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
},
{
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
},
{
token : "constant.language",
regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
},
{
token : function(value) {
if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language",
regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
},
{
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
},
{
}, {
token : "string", // symbol
regex : "[:](?:[a-zA-Z]|\d)+"
},
{
token : "string.regexp", //Regular Expressions
regex : '/#"(?:\.|(\\\")|[^\""\n])*"/g'
}
}, {
token : "string.regexp", //Regular Expressions
regex : '/#"(?:\.|(\\\")|[^\""\n])*"/g'
}
],
"comment" : [
{
{
token : "comment", // closing comment
regex : "^\=end$",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};
};

View file

@ -37,146 +37,158 @@
define(function(require, exports, module) {
require("pilot/oop").inherits(
CoffeeHighlightRules,
require("ace/mode/text_highlight_rules").TextHighlightRules);
require("pilot/oop").inherits(CoffeeHighlightRules,
require("ace/mode/text_highlight_rules").TextHighlightRules);
function CoffeeHighlightRules() {
var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"
, keywordend = "(?![$\\w]|\\s*:)"
, stringfill = {token: "string", regex: ".+"}
;
this.$rules =
{ start:
[ { token: "identifier"
, regex: "(?:@|(?:\\.|::)\\s*)" + identifier
}
, { token: "keyword"
, regex: "(?:t(?:h(?:is|row|en)|ry|ypeof)|s(?:uper|witch)|return|b(?:reak|y)|c(?:ontinue|atch|lass)|i(?:n(?:stanceof)?|s(?:nt)?|f)|e(?:lse|xtends)|f(?:or (?:own)?|inally|unction)|wh(?:ile|en)|n(?:ew|ot?)|d(?:e(?:lete|bugger)|o)|loop|o(?:ff?|[rn])|un(?:less|til)|and|yes)" + keywordend
}
, { token: "constant.language"
, regex: "(?:true|false|null|undefined)" + keywordend
}
, { token: "invalid.illegal"
, regex: "(?:c(?:ase|onst)|default|function|v(?:ar|oid)|with|e(?:num|xport)|i(?:mplements|nterface)|let|p(?:ackage|r(?:ivate|otected)|ublic)|static|yield|__(?:hasProp|extends|slice|bind|indexOf))" + keywordend
}
, { token: "language.support.class"
, regex: "(?:Array|Boolean|Date|Function|Number|Object|R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|TypeError|URIError)" + keywordend
}
, { token: "language.support.function"
, regex: "(?:Math|JSON|is(?:NaN|Finite)|parse(?:Int|Float)|encodeURI(?:Component)?|decodeURI(?:Component)?)" + keywordend
}
, { token: "identifier"
, regex: identifier
}
, { token: "constant.numeric"
, regex: "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
}
, { token: "string"
, regex: "'''"
, next : "qdoc"
}
, { token: "string"
, regex: '"""'
, next : "qqdoc"
}
, { token: "string"
, regex: "'"
, next : "qstring"
}
, { token: "string"
, regex: '"'
, next : "qqstring"
}
, { token: "string"
, regex: "`"
, next : "js"
}
, { token: "string.regex"
, regex: "///"
, next : "heregex"
}
, { token: "string.regex"
, regex: "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
}
, { token: "comment"
, regex: "###(?!#)"
, next : "comment"
}
, { token: "comment"
, regex: "#.*"
}
, { token: "lparen"
, regex: "[({[]"
}
, { token: "rparen"
, regex: "[\\]})]"
}
, { token: "keyword.operator"
, regex: "\\S+"
}
, { token: "text"
, regex: "\\s+"
}
]
, qdoc:
[ { token: "string"
, regex: ".*?'''"
, next : "start"
}
, stringfill
]
, qqdoc:
[ { token: "string"
, regex: '.*?"""'
, next : "start"
}
, stringfill
]
, qstring:
[ { token: "string"
, regex: "[^\\\\']*(?:\\\\.[^\\\\']*)*'"
, next : "start"
}
, stringfill
]
, qqstring:
[ { token: "string"
, regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"'
, next : "start"
}
, stringfill
]
, js:
[ { token: "string"
, regex: "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`"
, next : "start"
}
, stringfill
]
, heregex:
[ { token: "string.regex"
, regex: '.*?///[imgy]{0,4}'
, next : "start"
}
, { token: "comment.regex"
, regex: "\\s+(?:#.*)?"
}
, { token: "string.regex"
, regex: "\\S+"
}
]
, comment:
[ { token: "comment"
, regex: '.*?###'
, next : "start"
}
, { token: "comment"
, regex: ".+"
}
]
};
}
function CoffeeHighlightRules() {
var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
var keywordend = "(?![$\\w]|\\s*:)";
var stringfill = {
token : "string",
merge : true,
regex : ".+"
};
this.$rules = {
start : [
{
token : "identifier",
regex : "(?:@|(?:\\.|::)\\s*)" + identifier
}, {
token : "keyword",
regex : "(?:t(?:h(?:is|row|en)|ry|ypeof)|s(?:uper|witch)|return|b(?:reak|y)|c(?:ontinue|atch|lass)|i(?:n(?:stanceof)?|s(?:nt)?|f)|e(?:lse|xtends)|f(?:or (?:own)?|inally|unction)|wh(?:ile|en)|n(?:ew|ot?)|d(?:e(?:lete|bugger)|o)|loop|o(?:ff?|[rn])|un(?:less|til)|and|yes)"
+ keywordend
}, {
token : "constant.language",
regex : "(?:true|false|null|undefined)" + keywordend
}, {
token : "invalid.illegal",
regex : "(?:c(?:ase|onst)|default|function|v(?:ar|oid)|with|e(?:num|xport)|i(?:mplements|nterface)|let|p(?:ackage|r(?:ivate|otected)|ublic)|static|yield|__(?:hasProp|extends|slice|bind|indexOf))"
+ keywordend
}, {
token : "language.support.class",
regex : "(?:Array|Boolean|Date|Function|Number|Object|R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|TypeError|URIError)"
+ keywordend
}, {
token : "language.support.function",
regex : "(?:Math|JSON|is(?:NaN|Finite)|parse(?:Int|Float)|encodeURI(?:Component)?|decodeURI(?:Component)?)"
+ keywordend
}, {
token : "identifier",
regex : identifier
}, {
token : "constant.numeric",
regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
}, {
token : "string",
merge : true,
regex : "'''",
next : "qdoc"
}, {
token : "string",
merge : true,
regex : '"""',
next : "qqdoc"
}, {
token : "string",
merge : true,
regex : "'",
next : "qstring"
}, {
token : "string",
merge : true,
regex : '"',
next : "qqstring"
}, {
token : "string",
merge : true,
regex : "`",
next : "js"
}, {
token : "string.regex",
merge : true,
regex : "///",
next : "heregex"
}, {
token : "string.regex",
regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
}, {
token : "comment",
merge : true,
regex : "###(?!#)",
next : "comment"
}, {
token : "comment",
regex : "#.*"
}, {
token : "lparen",
regex : "[({[]"
}, {
token : "rparen",
regex : "[\\]})]"
}, {
token : "keyword.operator",
regex : "\\S+"
}, {
token : "text",
regex : "\\s+"
}],
qdoc : [{
token : "string",
regex : ".*?'''",
next : "start"
}, stringfill],
qqdoc : [{
token : "string",
regex : '.*?"""',
next : "start"
}, stringfill],
qstring : [{
token : "string",
regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'",
next : "start"
}, stringfill],
qqstring : [{
token : "string",
regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
next : "start"
}, stringfill],
js : [{
token : "string",
merge : true,
regex : "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",
next : "start"
}, stringfill],
heregex : [{
token : "string.regex",
regex : '.*?///[imgy]{0,4}',
next : "start"
}, {
token : "comment.regex",
regex : "\\s+(?:#.*)?"
}, {
token : "string.regex",
merge : true,
regex : "\\S+"
}],
comment : [{
token : "comment",
regex : '.*?###',
next : "start"
}, {
token : "comment",
merge : true,
regex : ".+"
}]
};
}
exports.CoffeeHighlightRules = CoffeeHighlightRules;
exports.CoffeeHighlightRules = CoffeeHighlightRules;
});

View file

@ -8,7 +8,7 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
var CSharpHighlightRules = function() {
var keywords = lang.arrayToMap(
("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("|")
("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("|")
);
var buildinConstants = lang.arrayToMap(
@ -21,94 +21,72 @@ var CSharpHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
merge : true,
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};

View file

@ -125,6 +125,7 @@ var CssHighlightRules = function() {
var base_ruleset = [
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "ruleset_comment"
},{
@ -212,66 +213,56 @@ var CssHighlightRules = function() {
}
];
var ruleset = lang.copyArray( base_ruleset );
ruleset.unshift(
{
var ruleset = lang.copyArray(base_ruleset);
ruleset.unshift({
token : "rparen",
regex : "\}",
regex : "\\}",
next: "start"
}
);
});
var media_ruleset = lang.copyArray( base_ruleset );
media_ruleset.unshift(
{
media_ruleset.unshift({
token : "rparen",
regex : "\}",
regex : "\\}",
next: "media"
}
);
});
var base_comment = [
{
var base_comment = [{
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
];
}];
var comment = lang.copyArray( base_comment );
comment.unshift(
{
var comment = lang.copyArray(base_comment);
comment.unshift({
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}
);
});
var media_comment = lang.copyArray( base_comment );
media_comment.unshift(
{
var media_comment = lang.copyArray(base_comment);
media_comment.unshift({
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "media"
}
);
});
var ruleset_comment = lang.copyArray( base_comment );
ruleset_comment.unshift(
{
var ruleset_comment = lang.copyArray(base_comment);
ruleset_comment.unshift({
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "ruleset"
}
);
});
this.$rules = {
"start" : [ {
"start" : [{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
token: "lparen",
regex: "{",
regex: "\\{",
next: "ruleset"
}, {
token: "string",
@ -293,15 +284,16 @@ var CssHighlightRules = function() {
"media" : [ {
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "media_comment"
}, {
token: "lparen",
regex: "{",
regex: "\\{",
next: "media_ruleset"
},{
token: "string",
regex: "}",
regex: "\\}",
next: "start"
},{
token: "keyword",

View file

@ -46,6 +46,9 @@ var CssMode = require("ace/mode/css").Mode;
var assert = require("ace/test/assertions");
module.exports = {
name: "CSS",
setUp : function() {
this.mode = new CssMode();
},

View file

@ -45,6 +45,9 @@ var CssMode = require("ace/mode/css").Mode;
var assert = require("ace/test/assertions");
module.exports = {
name: "CSS Tokenizer",
setUp : function() {
this.tokenizer = new CssMode().getTokenizer();
},

View file

@ -48,15 +48,19 @@ var DocCommentHighlightRules = function() {
regex : "@[\\w\\d_]+" // TODO: fix email addresses
}, {
token : "comment.doc",
merge : true,
regex : "\\s+"
}, {
token : "comment.doc",
merge : true,
regex : "TODO"
}, {
token : "comment.doc",
merge : true,
regex : "[^@\\*]+"
}, {
token : "comment.doc",
merge : true,
regex : "."
}]
};
@ -69,14 +73,16 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
this.getStartRule = function(start) {
return {
token : "comment.doc", // doc comment
merge : true,
regex : "\\/\\*(?=\\*)",
next: start
next : start
};
};
this.getEndRule = function (start) {
return {
token : "comment.doc", // closing comment
merge : true,
regex : "\\*\\/",
next : start
};

View file

@ -8,16 +8,16 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
var GroovyHighlightRules = function() {
var keywords = lang.arrayToMap(
("assert|with|abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" +
"char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" +
"def|float|native|super|while").split("|")
("assert|with|abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" +
"char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" +
"def|float|native|super|while").split("|")
);
var buildinConstants = lang.arrayToMap(
@ -59,98 +59,76 @@ var GroovyHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};

View file

@ -54,6 +54,7 @@ var HtmlHighlightRules = function() {
regex : '".*?"'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*$',
next : state + "-qqstring"
}, {
@ -61,6 +62,7 @@ var HtmlHighlightRules = function() {
regex : "'.*?'"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*$",
next : state + "-qstring"
}]
@ -69,10 +71,12 @@ var HtmlHighlightRules = function() {
function multiLineString(quote, state) {
return [{
token : "string",
merge : true,
regex : ".*" + quote,
next : state
}, {
token : "string",
merge : true,
regex : '.+'
}]
}
@ -80,6 +84,7 @@ var HtmlHighlightRules = function() {
this.$rules = {
start : [ {
token : "text",
merge : true,
regex : "<\\!\\[CDATA\\[",
next : "cdata"
}, {
@ -87,6 +92,7 @@ var HtmlHighlightRules = function() {
regex : "<\\?.*?\\?>"
}, {
token : "comment",
merge : true,
regex : "<\\!--",
next : "comment"
}, {
@ -158,9 +164,11 @@ var HtmlHighlightRules = function() {
next : "start"
}, {
token : "text",
merge : true,
regex : "\\s+"
}, {
token : "text",
merge : true,
regex : ".+"
} ],
@ -170,6 +178,7 @@ var HtmlHighlightRules = function() {
next : "start"
}, {
token : "comment",
merge : true,
regex : ".+"
} ]
};
@ -194,4 +203,4 @@ var HtmlHighlightRules = function() {
oop.inherits(HtmlHighlightRules, TextHighlightRules);
exports.HtmlHighlightRules = HtmlHighlightRules;
});
});

View file

@ -9,16 +9,16 @@ var JavaHighlightRules = function() {
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap(
("abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" +
"char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|")
("abstract|continue|for|new|switch|" +
"assert|default|goto|package|synchronized|" +
"boolean|do|if|private|this|" +
"break|double|implements|protected|throw|" +
"byte|else|import|public|throws|" +
"case|enum|instanceof|return|transient|" +
"catch|extends|int|short|try|" +
"char|final|interface|static|void|" +
"class|finally|long|strictfp|volatile|" +
"const|float|native|super|while").split("|")
);
var buildinConstants = lang.arrayToMap(
@ -60,98 +60,76 @@ var JavaHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};

View file

@ -80,6 +80,7 @@ var JavaScriptHighlightRules = function() {
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
@ -87,6 +88,7 @@ var JavaScriptHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*\\\\$',
next : "qqstring"
}, {
@ -94,6 +96,7 @@ var JavaScriptHighlightRules = function() {
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*\\\\$",
next : "qstring"
}, {
@ -157,7 +160,7 @@ var JavaScriptHighlightRules = function() {
token : "text",
regex : "\\s+"
}, {
// immediately return to the start mode without mathcing
// immediately return to the start mode without matching
// anything
token: "empty",
regex: "",
@ -171,6 +174,7 @@ var JavaScriptHighlightRules = function() {
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
@ -181,6 +185,7 @@ var JavaScriptHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
],
@ -191,6 +196,7 @@ var JavaScriptHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]

View file

@ -45,6 +45,9 @@ var JavaScriptMode = require("ace/mode/javascript").Mode;
var assert = require("ace/test/assertions");
module.exports = {
name: "JavaScript Tokenizer",
setUp : function() {
this.tokenizer = new JavaScriptMode().getTokenizer();
},
@ -91,10 +94,14 @@ module.exports = {
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
assert.equal(3, tokens.length);
assert.equal(7, tokens.length);
assert.equal("lparen", tokens[0].type);
assert.equal("text", tokens[1].type);
assert.equal("rparen", tokens[2].type);
assert.equal("lparen", tokens[1].type);
assert.equal("lparen", tokens[2].type);
assert.equal("text", tokens[3].type);
assert.equal("rparen", tokens[4].type);
assert.equal("rparen", tokens[5].type);
assert.equal("rparen", tokens[6].type);
},
"test for last rule in ruleset to catch capturing group bugs" : function() {

View file

@ -237,9 +237,8 @@ var OcamlHighlightRules = function() {
"Int32|Int64|LargeFile|Lazy|Lexing|List|ListLabels|Make|Map|Marshal|" +
"MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" +
"Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" +
"Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak")
.split("|"));
"Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak"
).split("|"));
var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
var octInteger = "(?:0[oO]?[0-7]+)";
@ -262,6 +261,7 @@ var OcamlHighlightRules = function() {
},
{
token : "comment",
merge : true,
regex : '\\(\\*.*',
next : "comment"
},
@ -275,6 +275,7 @@ var OcamlHighlightRules = function() {
},
{
token : "string", // " string
merge : true,
regex : '"',
next : "qstring"
},
@ -328,6 +329,7 @@ var OcamlHighlightRules = function() {
},
{
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
@ -339,6 +341,7 @@ var OcamlHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]

View file

@ -93,6 +93,7 @@ var PerlHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*\\\\$',
next : "qqstring"
}, {
@ -100,6 +101,7 @@ var PerlHighlightRules = function() {
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*\\\\$",
next : "qstring"
}, {
@ -141,6 +143,7 @@ var PerlHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
],
@ -151,6 +154,7 @@ var PerlHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]

View file

@ -921,6 +921,7 @@ var PhpHighlightRules = function() {
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
@ -931,6 +932,7 @@ var PhpHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*\\\\$',
next : "qqstring"
}, {
@ -938,6 +940,7 @@ var PhpHighlightRules = function() {
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*\\\\$",
next : "qstring"
}, {
@ -1018,6 +1021,7 @@ var PhpHighlightRules = function() {
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
@ -1028,6 +1032,7 @@ var PhpHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
],
@ -1038,6 +1043,7 @@ var PhpHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]

View file

@ -96,6 +96,7 @@ var PythonHighlightRules = function() {
regex : strPre + '"{3}(?:[^\\\\]|\\\\.)*?"{3}'
}, {
token : "string", // multi line """ string start
merge : true,
regex : strPre + '"{3}.*$',
next : "qqstring"
}, {
@ -106,6 +107,7 @@ var PythonHighlightRules = function() {
regex : strPre + "'{3}(?:[^\\\\]|\\\\.)*?'{3}"
}, {
token : "string", // multi line ''' string start
merge : true,
regex : strPre + "'{3}.*$",
next : "qstring"
}, {
@ -158,14 +160,16 @@ var PythonHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring" : [ {
token : "string", // multi line ''' string end
token : "string", // multi line ''' string end
regex : "(?:[^\\\\]|\\\\.)*?'{3}",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ]
};

View file

@ -98,89 +98,91 @@ var RubyHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "#.*$"
}, {
{
token : "comment",
regex : "#.*$"
}, {
token : "comment", // multi line comment
merge : true,
regex : "^\=begin$",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
}, {
token : "string", // backtick string
regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
}, {
}, {
token : "text", // namespaces aren't symbols
regex : "::"
}, {
}, {
token : "variable.instancce", // instance variable
regex : "@{1,2}(?:[a-zA-Z_]|\d)+"
}, {
}, {
token : "variable.class", // class name
regex : "[A-Z](?:[a-zA-Z_]|\d)+"
}, {
}, {
token : "string", // symbol
regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "self")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
{
token : "comment", // closing comment
regex : "^\=end$",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};
};

View file

@ -46,6 +46,9 @@ var RubyMode = require("ace/mode/ruby").Mode;
var assert = require("ace/test/assertions");
module.exports = {
name: "Ruby Tokenizer",
setUp : function() {
this.tokenizer = new RubyMode().getTokenizer();
},

View file

@ -9,7 +9,7 @@ var ScalaHighlightRules = function() {
// taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
var keywords = lang.arrayToMap(
(
(
"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|" +
"override|package|private|protected|sealed|super|this|trait|type|val|var|with"
@ -60,98 +60,76 @@ var ScalaHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment",
regex : "\\/\\/.*$"
},
new DocCommentHighlightRules().getStartRule("doc-start"),
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
token : "comment", // multi line comment
regex : "\\/\\*\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords.hasOwnProperty(value))
return "keyword";
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : function(value) {
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 identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
else if (buildinConstants.hasOwnProperty(value))
return "constant.language";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
}
],
"qqstring" : [
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
}
],
"qstring" : [
{
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
}
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};

View file

@ -42,11 +42,11 @@ var lang = require("pilot/lang");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var ScssHighlightRules = function() {
var properties = lang.arrayToMap( (function () {
var properties = lang.arrayToMap( (function () {
var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|");
var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|");
var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" +
"background-size|binding|border-bottom-colors|border-left-colors|" +
"border-right-colors|border-top-colors|border-end|border-end-color|" +
@ -97,20 +97,20 @@ var ScssHighlightRules = function() {
//All prefixProperties will get the browserPrefix in
//the begning by join the prefixProperties array with the value of browserPrefix
for (var i=0, ln=browserPrefix.length; i<ln; i++) {
Array.prototype.push.apply(
ret,
(( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
);
Array.prototype.push.apply(
ret,
(( browserPrefix[i] + prefixProperties.join("|" + browserPrefix[i]) ).split("|"))
);
}
//Add also prefixProperties and properties without any browser prefix
Array.prototype.push.apply(ret, prefixProperties);
Array.prototype.push.apply(ret, properties);
return ret;
})() );
return ret;
})() );
var functions = lang.arrayToMap(
@ -151,19 +151,19 @@ var ScssHighlightRules = function() {
);
var keywords = lang.arrayToMap(
("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
("@mixin|@extend|@include|@import|@media|@debug|@warn|@if|@for|@each|@while|@else|@font-face|@-webkit-keyframes|if|and|!default|module|def|end|declare").split("|")
)
var tags = lang.arrayToMap(
("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
"big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
"command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
"figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
"header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
"link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
"option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
"small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
"textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
("a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdo|" +
"big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|" +
"command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|" +
"figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|" +
"header|hgroup|hr|html|i|iframe|img|input|ins|keygen|kbd|label|legend|li|" +
"link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|" +
"option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|" +
"small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|" +
"textarea|tfoot|th|thead|time|title|tr|tt|u|ul|var|video|wbr|xmp").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead.
@ -197,6 +197,7 @@ var ScssHighlightRules = function() {
},
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment"
}, {
@ -204,6 +205,7 @@ var ScssHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*\\\\$',
next : "qqstring"
}, {
@ -211,6 +213,7 @@ var ScssHighlightRules = function() {
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*\\\\$",
next : "qstring"
}, {
@ -272,8 +275,8 @@ var ScssHighlightRules = function() {
regex : numRe
}, {
token : function(value) {
if (properties.hasOwnProperty(value.toLowerCase()))
return "support.type";
if (properties.hasOwnProperty(value.toLowerCase()))
return "support.type";
if (keywords.hasOwnProperty(value))
return "keyword";
else if (constants.hasOwnProperty(value))
@ -283,9 +286,9 @@ var ScssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase()))
return "support.constant.color";
else if (tags.hasOwnProperty(value.toLowerCase()))
return "variable.language";
return "variable.language";
else
return "text";
return "text";
},
regex : "\\-?[@a-zA-Z_][@a-zA-Z0-9_\\-]*"
}, {
@ -324,6 +327,7 @@ var ScssHighlightRules = function() {
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
@ -334,6 +338,7 @@ var ScssHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
],
@ -344,11 +349,11 @@ var ScssHighlightRules = function() {
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
}
]
};
};
oop.inherits(ScssHighlightRules, TextHighlightRules);

View file

@ -45,13 +45,13 @@ var TextHighlightRules = function() {
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [ {
"start" : [{
token : "empty_line",
regex : '^$'
}, {
token : "text",
regex : ".+"
} ]
}]
};
};

View file

@ -40,23 +40,7 @@ define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var TextileHighlightRules = function()
{
/*
var phraseModifiers = lang.arrayToMap(
("_|*|__|**|??|-|+|^|%|@").split("|")
);
var blockModifiers = lang.arrayToMap(
("h1|h2|h3|h4|h5|h6|bq|p|bc|pre").split("|")
);
*/
/*
var punctuation = lang.arrayToMap(
("-|--|(tm)|(r)|(c)").split("|")
);
*/
var TextileHighlightRules = function() {
this.$rules = {
"start" : [
{

View file

@ -46,7 +46,7 @@ var XmlHighlightRules = function() {
// regexps are ordered -> the first match is used
this.$rules = {
start : [ {
start : [{
token : "text",
regex : "<\\!\\[CDATA\\[",
next : "cdata"
@ -55,6 +55,7 @@ var XmlHighlightRules = function() {
regex : "<\\?.*?\\?>"
}, {
token : "comment",
merge : true,
regex : "<\\!--",
next : "comment"
}, {
@ -67,9 +68,9 @@ var XmlHighlightRules = function() {
}, {
token : "text",
regex : "[^<]+"
} ],
}],
tag : [ {
tag : [{
token : "text",
regex : ">",
next : "start"
@ -84,6 +85,7 @@ var XmlHighlightRules = function() {
regex : '".*?"'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*$',
next : "qqstring"
}, {
@ -91,6 +93,7 @@ var XmlHighlightRules = function() {
regex : "'.*?'"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*$",
next : "qstring"
}],
@ -101,6 +104,7 @@ var XmlHighlightRules = function() {
next : "tag"
}, {
token : "string",
merge : true,
regex : '.+'
}],
@ -110,10 +114,11 @@ var XmlHighlightRules = function() {
next : "tag"
}, {
token : "string",
merge : true,
regex : '.+'
}],
cdata : [ {
cdata : [{
token : "text",
regex : "\\]\\]>",
next : "start"
@ -123,16 +128,17 @@ var XmlHighlightRules = function() {
}, {
token : "text",
regex : "(?:[^\\]]|\\](?!\\]>))+"
} ],
}],
comment : [ {
comment : [{
token : "comment",
regex : ".*?-->",
next : "start"
}, {
token : "comment",
merge : true,
regex : ".+"
} ]
}]
};
};

View file

@ -45,12 +45,14 @@ var XmlMode = require("ace/mode/xml").Mode;
var assert = require("ace/test/assertions");
module.exports = {
name: "XML Tokenizer",
setUp : function() {
this.tokenizer = new XmlMode().getTokenizer();
},
"test: tokenize1" : function() {
var line = "<Juhu>//Juhu Kinners</Kinners>";
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;

View file

@ -69,7 +69,6 @@ var Tokenizer = function(rules) {
}
this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", "g");
}
};
@ -93,11 +92,12 @@ var Tokenizer = function(rules) {
while (match = re.exec(line)) {
var type = "text";
var rule = null;
var value = [match[0]];
for ( var i = 0; i < match.length-2; i++) {
for (var i = 0; i < match.length-2; i++) {
if (match[i + 1] !== undefined) {
var rule = state[mapping[i].rule];
rule = state[mapping[i].rule];
if (mapping[i].len > 1) {
value = match.slice(i+2, i+1+mapping[i].len);
@ -128,9 +128,10 @@ var Tokenizer = function(rules) {
value = [value.join("")];
type = [type];
}
for (var i = 0; i < value.length; i++) {
if (token.type !== type[i]) {
if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
token.value += value[i];
} else {
if (token.type) {
tokens.push(token);
}
@ -139,8 +140,6 @@ var Tokenizer = function(rules) {
type: type[i],
value: value[i]
}
} else {
token.value += value[i];
}
}
}