Merge pull request #1249 from ajaxorg/highlighting/2.0

Highlighting 2.0 (continuation)
This commit is contained in:
Harutyun Amirjanyan 2013-02-17 03:19:28 -08:00
commit 83be0083bb
50 changed files with 1181 additions and 648 deletions

View file

@ -100,6 +100,7 @@ var docs = {
"docs/objectivec.m": {name: "Objective-C"}, "docs/objectivec.m": {name: "Objective-C"},
"docs/ocaml.ml": "OCaml", "docs/ocaml.ml": "OCaml",
"docs/OpenSCAD.scad": "OpenSCAD", "docs/OpenSCAD.scad": "OpenSCAD",
"docs/pascal.pas": "Pascal",
"docs/perl.pl": "Perl", "docs/perl.pl": "Perl",
"docs/pgsql.pgsql": {name: "pgSQL", wrapped: true}, "docs/pgsql.pgsql": {name: "pgSQL", wrapped: true},
"docs/php.php": "PHP", "docs/php.php": "PHP",
@ -113,6 +114,7 @@ var docs = {
"docs/abap.abap": "SAP - ABAP", "docs/abap.abap": "SAP - ABAP",
"docs/scala.scala": "Scala", "docs/scala.scala": "Scala",
"docs/scss.scss": "SCSS", "docs/scss.scss": "SCSS",
"docs/sass.sass": "SASS",
"docs/sh.sh": "SH", "docs/sh.sh": "SH",
"docs/stylus.styl": "Stylus", "docs/stylus.styl": "Stylus",
"docs/sql.sql": {name: "SQL", wrapped: true}, "docs/sql.sql": {name: "SQL", wrapped: true},

View file

@ -0,0 +1,48 @@
(*****************************************************************************
* A simple bubble sort program. Reads integers, one per line, and prints *
* them out in sorted order. Blows up if there are more than 49. *
*****************************************************************************)
PROGRAM Sort(input, output);
CONST
(* Max array size. *)
MaxElts = 50;
TYPE
(* Type of the element array. *)
IntArrType = ARRAY [1..MaxElts] OF Integer;
VAR
(* Indexes, exchange temp, array size. *)
i, j, tmp, size: integer;
(* Array of ints *)
arr: IntArrType;
(* Read in the integers. *)
PROCEDURE ReadArr(VAR size: Integer; VAR a: IntArrType);
BEGIN
size := 1;
WHILE NOT eof DO BEGIN
readln(a[size]);
IF NOT eof THEN
size := size + 1
END
END;
BEGIN
(* Read *)
ReadArr(size, arr);
(* Sort using bubble sort. *)
FOR i := size - 1 DOWNTO 1 DO
FOR j := 1 TO i DO
IF arr[j] > arr[j + 1] THEN BEGIN
tmp := arr[j];
arr[j] := arr[j + 1];
arr[j + 1] := tmp;
END;
(* Print. *)
FOR i := 1 TO size DO
writeln(arr[i])
END.

View file

@ -0,0 +1,39 @@
// sass ace mode;
@import url(http://fonts.googleapis.com/css?family=Ace:700)
html, body
:background-color #ace
text-align: center
height: 100%
/*;*********;
;comment ;
;*********;
.toggle
$size: 14px
:background url(http://subtlepatterns.com/patterns/dark_stripes.png)
border-radius: 8px
height: $size
&:before
$radius: $size * 0.845
$glow: $size * 0.125
box-shadow: 0 0 $glow $glow / 2 #fff
border-radius: $radius
&:active
~ .button
box-shadow: 0 15px 25px -4px rgba(0,0,0,0.4)
~ .label
font-size: 40px
color: rgba(0,0,0,0.45)
&:checked
~ .button
box-shadow: 0 15px 25px -4px #ace
~ .label
font-size: 40px
color: #c9c9c9

View file

@ -72,6 +72,7 @@ var modesByName = {
markdown: ["Markdown" , "md|markdown"], markdown: ["Markdown" , "md|markdown"],
objectivec: ["Objective-C" , "m"], objectivec: ["Objective-C" , "m"],
ocaml: ["OCaml" , "ml|mli"], ocaml: ["OCaml" , "ml|mli"],
pascal: ["Pascal" , "pas|p"],
perl: ["Perl" , "pl|pm"], perl: ["Perl" , "pl|pm"],
pgsql: ["pgSQL" , "pgsql"], pgsql: ["pgSQL" , "pgsql"],
php: ["PHP" , "php|phtml"], php: ["PHP" , "php|phtml"],
@ -83,7 +84,8 @@ var modesByName = {
ruby: ["Ruby" , "ru|gemspec|rake|rb"], ruby: ["Ruby" , "ru|gemspec|rake|rb"],
scad: ["OpenSCAD" , "scad"], scad: ["OpenSCAD" , "scad"],
scala: ["Scala" , "scala"], scala: ["Scala" , "scala"],
scss: ["SCSS" , "scss|sass"], scss: ["SCSS" , "scss"],
sass: ["SASS" , "sass"],
sh: ["SH" , "sh|bash|bat"], sh: ["SH" , "sh|bash|bat"],
sql: ["SQL" , "sql"], sql: ["SQL" , "sql"],
stylus: ["Stylus" , "styl|stylus"], stylus: ["Stylus" , "styl|stylus"],

View file

@ -40,6 +40,10 @@ var Renderer = require("ace/virtual_renderer").VirtualRenderer;
var Editor = require("ace/editor").Editor; var Editor = require("ace/editor").Editor;
var MultiSelect = require("ace/multi_select").MultiSelect; var MultiSelect = require("ace/multi_select").MultiSelect;
exports.createEditor = function(el) {
return new Editor(new Renderer(el));
}
exports.createSplitEditor = function(el) { exports.createSplitEditor = function(el) {
if (typeof(el) == "string") if (typeof(el) == "string")
el = document.getElementById(el); el = document.getElementById(el);
@ -54,8 +58,8 @@ exports.createSplitEditor = function(el) {
el.style.position = "relative"; el.style.position = "relative";
var split = {$container: el}; var split = {$container: el};
split.editor0 = split[0] = new Editor(new Renderer(e0, require("ace/theme/textmate"))); split.editor0 = split[0] = new Editor(new Renderer(e0));
split.editor1 = split[1] = new Editor(new Renderer(e1, require("ace/theme/textmate"))); split.editor1 = split[1] = new Editor(new Renderer(e1));
split.splitter = s; split.splitter = s;
MultiSelect(split.editor0); MultiSelect(split.editor0);

View file

@ -34,8 +34,6 @@ define(function(require, exports, module) {
var oop = require("./lib/oop"); var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter; var EventEmitter = require("./lib/event_emitter").EventEmitter;
// tokenizing lines longer than this makes editor very slow
var MAX_LINE_LENGTH = 5000;
/** /**
* *
@ -226,15 +224,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
var line = this.doc.getLine(row); var line = this.doc.getLine(row);
var state = this.states[row - 1]; var state = this.states[row - 1];
if (line.length > MAX_LINE_LENGTH) {
var overflow = {value: line.substr(MAX_LINE_LENGTH), type: "text"};
line = line.slice(0, MAX_LINE_LENGTH);
}
var data = this.tokenizer.getLineTokens(line, state, row); var data = this.tokenizer.getLineTokens(line, state, row);
if (overflow) {
data.tokens.push(overflow);
data.state = "start";
}
if (this.states[row] + "" !== data.state + "") { if (this.states[row] + "" !== data.state + "") {
this.states[row] = data.state; this.states[row] = data.state;

View file

@ -62,19 +62,19 @@ module.exports = {
doc.setMode("./mode/javascript") doc.setMode("./mode/javascript")
forceTokenize(doc) forceTokenize(doc)
testStates(doc, ["comment", "start", "start"]) testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
doc.remove(new Range(0,2,1,2)) doc.remove(new Range(0,2,1,2))
testStates(doc, [null, "start"]) testStates(doc, [null, "no_regex"])
forceTokenize(doc) forceTokenize(doc)
testStates(doc, ["comment", "comment"]) testStates(doc, ["comment_regex_allowed", "comment_regex_allowed"])
doc.insert({row:0, column:2}, "\n*/") doc.insert({row:0, column:2}, "\n*/")
testStates(doc, [undefined, undefined, "comment"]) testStates(doc, [undefined, undefined, "comment_regex_allowed"])
forceTokenize(doc) forceTokenize(doc)
testStates(doc, ["comment", "start", "start"]) testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
} }
}; };

View file

@ -310,7 +310,7 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
editor.modifyNumber(count || 1); editor.modifyNumber(count || 1);
} }
}, }
}; };
var inputBuffer = exports.inputBuffer = { var inputBuffer = exports.inputBuffer = {

View file

@ -12,8 +12,9 @@ test: # followed be only space is not a valid header
test: only space between #s is not a valid header test: only space between #s is not a valid header
# # # #
test links [Cloud9 IDE](http://www.c9.io/) # test links [Cloud9 IDE](http://www.c9.io/) #
* [demo](http://ajaxorg.github.com/ace/) * [demo](http://ajaxorg.github.com/ace/)
in lists in lists
in plain text <b>http://ace.ajaxorg.com<b> in plain text <b>http://ace.ajaxorg.com<b>

View file

@ -20,7 +20,9 @@
["punctuation.operator","."], ["punctuation.operator","."],
["identifier","WriteLine"], ["identifier","WriteLine"],
["paren.lparen","("], ["paren.lparen","("],
["string","\"Hello World\""], ["string.start","\""],
["string","Hello World"],
["string.end","\""],
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[

View file

@ -2,7 +2,7 @@
"start", "start",
["comment","//test: tokenize 'standard' functions"] ["comment","//test: tokenize 'standard' functions"]
],[ ],[
"start", "no_regex",
["identifier","string"], ["identifier","string"],
["punctuation.operator","."], ["punctuation.operator","."],
["support.function","charCodeAt"], ["support.function","charCodeAt"],
@ -28,7 +28,7 @@
["punctuation.operator",";"], ["punctuation.operator",";"],
["string","\";"] ["string","\";"]
],[ ],[
"start", "no_regex",
["identifier","test"], ["identifier","test"],
["punctuation.operator",":"], ["punctuation.operator",":"],
["text"," "], ["text"," "],
@ -36,15 +36,15 @@
["text"," "], ["text"," "],
["identifier","comment"] ["identifier","comment"]
],[ ],[
"start", "no_regex",
["comment.doc","/**tokenize doc comment with "], ["comment.doc","/**tokenize doc comment with "],
["comment.doc.tag","@tag"], ["comment.doc.tag","@tag"],
["comment.doc"," {}*/"] ["comment.doc"," {}*/"]
],[ ],[
"start", "no_regex",
["comment","//test: tokenize parens"] ["comment","//test: tokenize parens"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -58,34 +58,34 @@
"start", "start",
["comment","//test tokenize arithmetic expression which looks like a regexp"] ["comment","//test tokenize arithmetic expression which looks like a regexp"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","/"], ["keyword.operator","/"],
["identifier","b"], ["identifier","b"],
["keyword.operator","/"], ["keyword.operator","/"],
["identifier","c"] ["identifier","c"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","/="], ["keyword.operator","/="],
["identifier","b"], ["identifier","b"],
["keyword.operator","/"], ["keyword.operator","/"],
["identifier","c"] ["identifier","c"]
],[ ],[
"start", "no_regex",
["comment","//test tokenize reg exps"] ["comment","//test tokenize reg exps"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","="], ["keyword.operator","="],
["string.regexp","/b/g"] ["string.regexp","/b/g"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","+"], ["keyword.operator","+"],
["string.regexp","/b/g"] ["string.regexp","/b/g"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
@ -98,7 +98,7 @@
["constant.language.escape","+"], ["constant.language.escape","+"],
["string.regexp"," 1/b"] ["string.regexp"," 1/b"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","="], ["keyword.operator","="],
["string.regexp","/a/"], ["string.regexp","/a/"],
@ -107,7 +107,7 @@
["text"," "], ["text"," "],
["string.regexp","/a/"] ["string.regexp","/a/"]
],[ ],[
"start", "no_regex",
["keyword","case"], ["keyword","case"],
["text"," "], ["text"," "],
["string.regexp","/a/"], ["string.regexp","/a/"],
@ -117,31 +117,31 @@
["identifier","c"], ["identifier","c"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["comment","//test tokenize multi-line comment containing a single line comment"] ["comment","//test tokenize multi-line comment containing a single line comment"]
],[ ],[
"start", "no_regex",
["identifier","noRegex"] ["identifier","noRegex"]
],[ ],[
"start", "no_regex",
["comment","/* foo // bar */"] ["comment","/* foo // bar */"]
],[ ],[
"regex_allowed", "start",
["identifier","canBeRegex"], ["identifier","canBeRegex"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["comment","/* foo // bar */"] ["comment","/* foo // bar */"]
],[ ],[
"start", "start",
["comment","// test tokenize identifier with umlauts"] ["comment","// test tokenize identifier with umlauts"]
],[ ],[
"start", "no_regex",
["identifier","fu"], ["identifier","fu"],
["punctuation.operator","?"], ["punctuation.operator","?"],
["identifier","e"] ["identifier","e"]
],[ ],[
"start", "no_regex",
["comment","// test // is not a regexp"] ["comment","// test // is not a regexp"]
],[ ],[
"start", "start",
@ -152,12 +152,12 @@
"start", "start",
["comment","//test skipping escaped chars"] ["comment","//test skipping escaped chars"]
],[ ],[
"start", "no_regex",
["string","'Meh"], ["string","'Meh"],
["constant.language.escape","\\\\"], ["constant.language.escape","\\\\"],
["string","nNeh'"] ["string","nNeh'"]
],[ ],[
"start", "no_regex",
["storage.type","console"], ["storage.type","console"],
["punctuation.operator","."], ["punctuation.operator","."],
["support.function.firebug","log"], ["support.function.firebug","log"],
@ -169,10 +169,10 @@
"qqstring", "qqstring",
["string","\"test multiline\\"] ["string","\"test multiline\\"]
],[ ],[
"start", "no_regex",
["string"," strings\""] ["string"," strings\""]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","="], ["keyword.operator","="],
["text","'"] ["text","'"]
@ -182,16 +182,16 @@
["keyword.operator","="], ["keyword.operator","="],
["string","\"\\"] ["string","\"\\"]
],[ ],[
"start", "no_regex",
["string","still a string"] ["string","still a string"]
],[ ],[
"start", "no_regex",
["text"," "]
],[
"no_regex",
["text"," "] ["text"," "]
],[ ],[
"start", "start",
["text"," "]
],[
"regex_allowed",
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
["entity.name.function","foo"], ["entity.name.function","foo"],
@ -203,7 +203,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword","for"], ["keyword","for"],
["text"," "], ["text"," "],
@ -228,7 +228,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["support.function","alert"], ["support.function","alert"],
["paren.lparen","("], ["paren.lparen","("],
@ -245,18 +245,18 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"], ["paren.rparen","}"],
["text","\t"], ["text","\t"],
["comment","// Real Tab."] ["comment","// Real Tab."]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "no_regex",
["identifier","regexp"], ["identifier","regexp"],
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
@ -267,9 +267,9 @@
["text"," "], ["text"," "],
["comment","// ends here"] ["comment","// ends here"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "no_regex",
["identifier","r"], ["identifier","r"],
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
@ -316,7 +316,7 @@
["text"," "], ["text"," "],
["identifier","o"] ["identifier","o"]
],[ ],[
"start", "no_regex",
["identifier","a"], ["identifier","a"],
["keyword.operator","="], ["keyword.operator","="],
["string.regexp","/a/"], ["string.regexp","/a/"],
@ -331,16 +331,16 @@
["text"," "], ["text"," "],
["string.regexp","/ /"] ["string.regexp","/ /"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["comment.doc","/************************************/"] ["comment.doc","/************************************/"]
],[ ],[
"start", "no_regex",
["comment.doc","/** total mess, tricky to highlight**/"] ["comment.doc","/** total mess, tricky to highlight**/"]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
["paren.lparen","("], ["paren.lparen","("],
@ -355,10 +355,10 @@
"doc-start", "doc-start",
["comment.doc","\t * docComment"] ["comment.doc","\t * docComment"]
],[ ],[
"start", "no_regex",
["comment.doc","\t **/"] ["comment.doc","\t **/"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["identifier","r"], ["identifier","r"],
["text"," "], ["text"," "],
@ -369,7 +369,7 @@
["constant.language.escape","*"], ["constant.language.escape","*"],
["string.regexp","/"] ["string.regexp","/"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["identifier","g"], ["identifier","g"],
["text"," "], ["text"," "],
@ -401,7 +401,7 @@
["text"," "], ["text"," "],
["constant.numeric","0x25"] ["constant.numeric","0x25"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["identifier","t"], ["identifier","t"],
["text"," "], ["text"," "],
@ -414,10 +414,10 @@
["string","''"], ["string","''"],
["paren.rparen","]"] ["paren.rparen","]"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"regex_allowed", "start",
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
["paren.lparen","("], ["paren.lparen","("],
@ -425,50 +425,50 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text","\t"], ["text","\t"],
["comment","/* eee */"] ["comment","/* eee */"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"qqstring", "qqstring",
["string","\"s\\"] ["string","\"s\\"]
],[ ],[
"start", "no_regex",
["string","s"], ["string","s"],
["constant.language.escape","\\u7824"], ["constant.language.escape","\\u7824"],
["string","sss"], ["string","sss"],
["constant.language.escape","\\u"], ["constant.language.escape","\\u"],
["string","1\""] ["string","1\""]
],[ ],[
"start" "no_regex"
],[ ],[
"qstring", "qstring",
["string","'\\"] ["string","'\\"]
],[ ],[
"start", "no_regex",
["string","string'"] ["string","string'"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "no_regex",
["text","'"] ["text","'"]
],[ ],[
"start", "no_regex",
["identifier","string"], ["identifier","string"],
["text","'"] ["text","'"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "no_regex",
["string","\"trailing space"], ["string","\"trailing space"],
["constant.language.escape","\\ "], ["constant.language.escape","\\ "],
["string"," "] ["string"," "]
],[ ],[
"start", "no_regex",
["string","\" \""], ["string","\" \""],
["text"," "], ["text"," "],
["keyword.operator","/"], ["keyword.operator","/"],
@ -480,7 +480,7 @@
["keyword.operator","/"], ["keyword.operator","/"],
["identifier","g"] ["identifier","g"]
],[ ],[
"start" "no_regex"
],[ ],[
"doc-start", "doc-start",
["comment.doc","/**"] ["comment.doc","/**"]
@ -488,19 +488,19 @@
"doc-start", "doc-start",
["comment.doc"," *doc"] ["comment.doc"," *doc"]
],[ ],[
"start", "no_regex",
["comment.doc"," */"] ["comment.doc"," */"]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["identifier","a"], ["identifier","a"],
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text","\t"], ["text","\t"],
["string","'a'"], ["string","'a'"],
["punctuation.operator",":"], ["punctuation.operator",":"],
@ -508,7 +508,7 @@
["identifier","b"], ["identifier","b"],
["punctuation.operator",","] ["punctuation.operator",","]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["string","'g'"], ["string","'g'"],
["text",":"], ["text",":"],
@ -518,7 +518,7 @@
["variable.parameter","t"], ["variable.parameter","t"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["entity.name.function","gta"], ["entity.name.function","gta"],
["punctuation.operator",":"], ["punctuation.operator",":"],
@ -529,12 +529,12 @@
["variable.parameter","b"], ["variable.parameter","b"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"start" "no_regex"
],[ ],[
"function_arguments", "function_arguments",
["identifier","foo"], ["identifier","foo"],
@ -552,14 +552,14 @@
["variable.parameter","b"], ["variable.parameter","b"],
["punctuation.operator",","] ["punctuation.operator",","]
],[ ],[
"start", "no_regex",
["punctuation.operator"," "], ["punctuation.operator"," "],
["variable.parameter","c"], ["variable.parameter","c"],
["punctuation.operator",", "], ["punctuation.operator",", "],
["variable.parameter","d"], ["variable.parameter","d"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["storage.type","foo"], ["storage.type","foo"],
["punctuation.operator","."], ["punctuation.operator","."],
["entity.name.function","d"], ["entity.name.function","d"],
@ -572,7 +572,7 @@
["variable.parameter","b"], ["variable.parameter","b"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["storage.type","foo"], ["storage.type","foo"],
["punctuation.operator","."], ["punctuation.operator","."],
["entity.name.function","d"], ["entity.name.function","d"],
@ -588,5 +588,5 @@
["string","\"string\""], ["string","\"string\""],
["text"," "] ["text"," "]
],[ ],[
"start" "no_regex"
]] ]]

View file

@ -15,7 +15,7 @@
["meta.tag.tag-name.script","script"], ["meta.tag.tag-name.script","script"],
["meta.tag.r",">"] ["meta.tag.r",">"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -26,7 +26,7 @@
["string","\"abc\""], ["string","\"abc\""],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
@ -34,7 +34,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[

View file

@ -3,25 +3,29 @@
["text","test: header 1 "] ["text","test: header 1 "]
],[ ],[
"start", "start",
["markup.heading.1","#f"] ["markup.heading.1","#"],
["markup.heading","f"]
],[ ],[
"start", "start",
["text","test: header 2"] ["text","test: header 2"]
],[ ],[
"start", "start",
["markup.heading.2","## foo"] ["markup.heading.2","##"],
["markup.heading"," foo"]
],[ ],[
"start", "start",
["text","test: header ends with ' #'"] ["text","test: header ends with ' #'"]
],[ ],[
"start", "start",
["markup.heading.1","# # # "] ["markup.heading.1","#"],
["markup.heading"," # # "]
],[ ],[
"start", "start",
["text","test: header ends with '#'"] ["text","test: header ends with '#'"]
],[ ],[
"start", "start",
["markup.heading.1","#foo# "] ["markup.heading.1","#"],
["markup.heading","foo# "]
],[ ],[
"start", "start",
["text","test: 6+ #s is not a valid header"] ["text","test: 6+ #s is not a valid header"]
@ -41,13 +45,14 @@
"allowBlock" "allowBlock"
],[ ],[
"start", "start",
["text","test links "], ["markup.heading.1","#"],
["markup.heading"," test links "],
["text","["], ["text","["],
["string","Cloud9 IDE"], ["string","Cloud9 IDE"],
["text","]("], ["text","]("],
["markup.underline","http://www.c9.io/"], ["markup.underline","http://www.c9.io/"],
["text",")"], ["text",")"],
["text"," "] ["markup.heading"," #"]
],[ ],[
"listblock", "listblock",
["markup.list","* "], ["markup.list","* "],
@ -72,4 +77,8 @@
["meta.tag","<"], ["meta.tag","<"],
["meta.tag.tag-name","b"], ["meta.tag.tag-name","b"],
["meta.tag.r",">"] ["meta.tag.r",">"]
],[
"allowBlock"
],[
"start"
]] ]]

View file

@ -50,7 +50,7 @@
],[ ],[
"start" "start"
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["meta.tag","<"], ["meta.tag","<"],
["meta.tag.tag-name","script"], ["meta.tag.tag-name","script"],
@ -64,7 +64,7 @@
["identifier","CDATA"], ["identifier","CDATA"],
["paren.lparen","["] ["paren.lparen","["]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -75,7 +75,7 @@
["constant.numeric","0"], ["constant.numeric","0"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -86,7 +86,7 @@
["constant.numeric","1"], ["constant.numeric","1"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -97,28 +97,28 @@
["constant.numeric","100"], ["constant.numeric","100"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
["identifier","hickory"], ["identifier","hickory"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
["identifier","dickory"], ["identifier","dickory"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
["identifier","dock"], ["identifier","dock"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -127,7 +127,7 @@
],[ ],[
"js-start" "js-start"
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
@ -138,7 +138,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","hickory"], ["identifier","hickory"],
["text"," "], ["text"," "],
@ -156,7 +156,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dickory"], ["identifier","dickory"],
["text"," "], ["text"," "],
@ -174,7 +174,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dock"], ["identifier","dock"],
["text"," "], ["text"," "],
@ -194,18 +194,18 @@
],[ ],[
"js-start" "js-start"
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","ShowAndGrowElement"], ["identifier","ShowAndGrowElement"],
["paren.lparen","("], ["paren.lparen","("],
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["storage.type","function"], ["storage.type","function"],
["text"," "], ["text"," "],
@ -215,7 +215,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","timevalue"], ["identifier","timevalue"],
["text"," "], ["text"," "],
@ -228,7 +228,7 @@
["identifier","timer_increment"], ["identifier","timer_increment"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -240,7 +240,7 @@
["identifier","max_time"], ["identifier","max_time"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["keyword","return"], ["keyword","return"],
["punctuation.operator",";"] ["punctuation.operator",";"]
@ -249,7 +249,7 @@
["text"," "], ["text"," "],
["comment","// Scale the text string gradually until it is 20 times larger"] ["comment","// Scale the text string gradually until it is 20 times larger"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","scalefactor"], ["identifier","scalefactor"],
["text"," "], ["text"," "],
@ -270,7 +270,7 @@
],[ ],[
"js-start" "js-start"
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -284,7 +284,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","hickory"], ["identifier","hickory"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -297,7 +297,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","hickory"], ["identifier","hickory"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -327,13 +327,13 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"js-start" "js-no_regex"
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -355,7 +355,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dickory"], ["identifier","dickory"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -368,7 +368,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dickory"], ["identifier","dickory"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -395,11 +395,11 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -413,7 +413,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dock"], ["identifier","dock"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -426,7 +426,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-regex_allowed", "js-start",
["text"," "], ["text"," "],
["identifier","dock"], ["identifier","dock"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -455,17 +455,17 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"js-start" "js-no_regex"
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["comment","// Call ShowAndGrowElement again <timer_increment> milliseconds later."] ["comment","// Call ShowAndGrowElement again <timer_increment> milliseconds later."]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["identifier","setTimeout"], ["identifier","setTimeout"],
["paren.lparen","("], ["paren.lparen","("],
@ -475,11 +475,11 @@
["identifier","timer_increment"], ["identifier","timer_increment"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"js-start", "js-no_regex",
["text"," "], ["text"," "],
["variable.language","window"], ["variable.language","window"],
["punctuation.operator","."], ["punctuation.operator","."],

View file

@ -1,19 +1,19 @@
[[ [[
"regex_allowed", "start",
["keyword.operator.ts","class"], ["keyword.operator.ts","class"],
["text"," "], ["text"," "],
["identifier","Greeter"], ["identifier","Greeter"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text","\t"], ["text","\t"],
["variable.parameter.function.ts","greeting"], ["variable.parameter.function.ts","greeting"],
["text",": "], ["text",": "],
["variable.parameter.function.ts","string"], ["variable.parameter.function.ts","string"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text","\t"], ["text","\t"],
["keyword.operator.ts","constructor"], ["keyword.operator.ts","constructor"],
["text"," "], ["text"," "],
@ -25,7 +25,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text","\t\t"], ["text","\t\t"],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","greeting"], ["identifier","greeting"],
@ -35,19 +35,19 @@
["identifier","message"], ["identifier","message"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"regex_allowed", "start",
["text","\t"], ["text","\t"],
["entity.name.function.ts","greet"], ["identifier","greet"],
["paren.lparen","("], ["paren.lparen","("],
["paren.rparen",")"], ["paren.rparen",")"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text","\t\t"], ["text","\t\t"],
["keyword","return"], ["keyword","return"],
["text"," "], ["text"," "],
@ -59,17 +59,17 @@
["identifier","greeting"], ["identifier","greeting"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"], ["paren.rparen","}"],
["text"," "] ["text"," "]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
["identifier","greeter"], ["identifier","greeter"],
@ -86,7 +86,7 @@
],[ ],[
"start" "start"
],[ ],[
"start", "no_regex",
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
["identifier","button"], ["identifier","button"],
@ -100,7 +100,7 @@
["string","'button'"], ["string","'button'"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["identifier","button"], ["identifier","button"],
["punctuation.operator","."], ["punctuation.operator","."],
["identifier","innerText"], ["identifier","innerText"],
@ -109,7 +109,7 @@
["text"," "], ["text"," "],
["string","\"Say Hello\""] ["string","\"Say Hello\""]
],[ ],[
"regex_allowed", "start",
["storage.type","button"], ["storage.type","button"],
["punctuation.operator","."], ["punctuation.operator","."],
["entity.name.function","onclick"], ["entity.name.function","onclick"],
@ -122,7 +122,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"start", "no_regex",
["text","\t"], ["text","\t"],
["support.function","alert"], ["support.function","alert"],
["paren.lparen","("], ["paren.lparen","("],
@ -131,12 +131,12 @@
["paren.rparen",")"], ["paren.rparen",")"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "no_regex",
["variable.language","document"], ["variable.language","document"],
["punctuation.operator","."], ["punctuation.operator","."],
["identifier","body"], ["identifier","body"],
@ -146,20 +146,20 @@
["identifier","button"], ["identifier","button"],
["paren.rparen",")"] ["paren.rparen",")"]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["keyword.operator.ts","class"], ["keyword","class"],
["text"," "], ["text"," "],
["identifier","Snake"], ["identifier","Snake"],
["text"," "], ["text"," "],
["keyword.operator.ts","extends"], ["keyword","extends"],
["text"," "], ["text"," "],
["identifier","Animal"], ["identifier","Animal"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["entity.name.function.ts","move"], ["entity.name.function.ts","move"],
["paren.lparen","("], ["paren.lparen","("],
@ -167,7 +167,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["support.function","alert"], ["support.function","alert"],
["paren.lparen","("], ["paren.lparen","("],
@ -175,7 +175,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","super"], ["storage.type.variable.ts","super"],
["text","("], ["text","("],
@ -183,27 +183,27 @@
["text",")"], ["text",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["keyword.operator.ts","class"], ["keyword","class"],
["text"," "], ["text"," "],
["identifier","Horse"], ["identifier","Horse"],
["text"," "], ["text"," "],
["keyword.operator.ts","extends"], ["keyword","extends"],
["text"," "], ["text"," "],
["identifier","Animal"], ["identifier","Animal"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["entity.name.function.ts","move"], ["entity.name.function.ts","move"],
["paren.lparen","("], ["paren.lparen","("],
@ -211,7 +211,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["support.function","alert"], ["support.function","alert"],
["paren.lparen","("], ["paren.lparen","("],
@ -219,7 +219,7 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","super"], ["keyword.operator.ts","super"],
["punctuation.operator","."], ["punctuation.operator","."],
@ -229,22 +229,23 @@
["paren.rparen",")"], ["paren.rparen",")"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"start", "start",
["keyword.operator.ts","module"], ["identifier","module"],
["text"," "], ["text"," "],
["variable.parameter.function.ts","Sayings"], ["identifier","Sayings"],
["text"," {"] ["text"," "],
["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","export"], ["keyword.operator.ts","export"],
["text"," "], ["text"," "],
@ -254,14 +255,14 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["variable.parameter.function.ts","greeting"], ["variable.parameter.function.ts","greeting"],
["text",": "], ["text",": "],
["variable.parameter.function.ts","string"], ["variable.parameter.function.ts","string"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","constructor"], ["keyword.operator.ts","constructor"],
["text"," "], ["text"," "],
@ -273,7 +274,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","greeting"], ["identifier","greeting"],
@ -283,19 +284,19 @@
["identifier","message"], ["identifier","message"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["entity.name.function.ts","greet"], ["identifier","greet"],
["paren.lparen","("], ["paren.lparen","("],
["paren.rparen",")"], ["paren.rparen",")"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword","return"], ["keyword","return"],
["text"," "], ["text"," "],
@ -307,24 +308,25 @@
["identifier","greeting"], ["identifier","greeting"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "start",
["keyword.operator.ts","module"], ["identifier","module"],
["text"," "], ["text"," "],
["variable.parameter.function.ts","Mankala"], ["identifier","Mankala"],
["text"," {"] ["text"," "],
["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","export"], ["keyword.operator.ts","export"],
["text"," "], ["text"," "],
@ -334,7 +336,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword.operator.ts","public"],
["text"," "], ["text"," "],
@ -345,7 +347,7 @@
["constant.language.boolean","false"], ["constant.language.boolean","false"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword.operator.ts","public"],
["text"," "], ["text"," "],
@ -356,7 +358,7 @@
["constant.numeric","0"], ["constant.numeric","0"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword.operator.ts","public"],
["text"," "], ["text"," "],
@ -367,7 +369,7 @@
["constant.numeric","0"], ["constant.numeric","0"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword.operator.ts","public"],
["text"," "], ["text"," "],
@ -380,7 +382,7 @@
],[ ],[
"start" "start"
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword.operator.ts","public"],
["text"," "], ["text"," "],
@ -390,7 +392,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","turnContinues"], ["identifier","turnContinues"],
@ -400,7 +402,7 @@
["constant.language.boolean","false"], ["constant.language.boolean","false"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","seedStoredCount"], ["identifier","seedStoredCount"],
@ -410,7 +412,7 @@
["constant.numeric","0"], ["constant.numeric","0"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","capturedCount"], ["identifier","capturedCount"],
@ -420,7 +422,7 @@
["constant.numeric","0"], ["constant.numeric","0"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type.variable.ts","this."], ["storage.type.variable.ts","this."],
["identifier","spaceCaptured"], ["identifier","spaceCaptured"],
@ -430,23 +432,23 @@
["identifier","NoSpace"], ["identifier","NoSpace"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start" "no_regex"
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword.operator.ts","public"], ["keyword","public"],
["text"," "], ["text"," "],
["entity.name.function.ts","toString"], ["identifier","toString"],
["paren.lparen","("], ["paren.lparen","("],
["paren.rparen",")"], ["paren.rparen",")"],
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["storage.type","var"], ["storage.type","var"],
["text"," "], ["text"," "],
@ -457,7 +459,7 @@
["string","\"\""], ["string","\"\""],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -468,7 +470,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["identifier","stringBuilder"], ["identifier","stringBuilder"],
["text"," "], ["text"," "],
@ -477,11 +479,11 @@
["string","\" turn continues,\""], ["string","\" turn continues,\""],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["identifier","stringBuilder"], ["identifier","stringBuilder"],
["text"," "], ["text"," "],
@ -495,7 +497,7 @@
["identifier","seedStoredCount"], ["identifier","seedStoredCount"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword","if"], ["keyword","if"],
["text"," "], ["text"," "],
@ -510,7 +512,7 @@
["text"," "], ["text"," "],
["paren.lparen","{"] ["paren.lparen","{"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["identifier","stringBuilder"], ["identifier","stringBuilder"],
["text"," "], ["text"," "],
@ -533,25 +535,25 @@
["identifier","spaceCaptured"], ["identifier","spaceCaptured"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"regex_allowed", "start",
["text"," "], ["text"," "],
["keyword","return"], ["keyword","return"],
["text"," "], ["text"," "],
["identifier","stringBuilder"], ["identifier","stringBuilder"],
["punctuation.operator",";"] ["punctuation.operator",";"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["text"," "], ["text"," "],
["paren.rparen","}"] ["paren.rparen","}"]
],[ ],[
"start", "no_regex",
["paren.rparen","}"] ["paren.rparen","}"]
]] ]]

View file

@ -39,7 +39,7 @@ var TextMode = require("./text").Mode;
var oop = require("../lib/oop"); var oop = require("../lib/oop");
function Mode() { function Mode() {
this.$tokenizer = new Tokenizer(new Rules().getRules(), "i"); this.$tokenizer = new Tokenizer(new Rules().getRules());
this.foldingRules = new FoldMode(); this.foldingRules = new FoldMode();
} }

View file

@ -114,16 +114,17 @@ var AbapHighlightRules = function() {
{token : "keyword", regex : compoundKeywords}, {token : "keyword", regex : compoundKeywords},
{token : "variable.parameter", regex : /\w+-\w+(?:-\w+)*/}, {token : "variable.parameter", regex : /\w+-\w+(?:-\w+)*/},
{token : keywordMapper, regex : "\\b\\w+\\b"}, {token : keywordMapper, regex : "\\b\\w+\\b"},
{caseInsensitive: true}
], ],
"qstring" : [ "qstring" : [
{token : "constant.language.escape", regex : "''"}, {token : "constant.language.escape", regex : "''"},
{token : "string", regex : "'", next : "start"}, {token : "string", regex : "'", next : "start"},
{token : "string", regex : ".|\w+"} {defaultToken : "string"}
], ],
"string" : [ "string" : [
{token : "constant.language.escape", regex : "``"}, {token : "constant.language.escape", regex : "``"},
{token : "string", regex : "`", next : "start"}, {token : "string", regex : "`", next : "start"},
{token : "string", regex : ".|\w+"} {defaultToken : "string"}
] ]
} }
}; };

View file

@ -39,7 +39,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
var C9StyleFoldMode = require("./folding/c9search").FoldMode; var C9StyleFoldMode = require("./folding/c9search").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new C9SearchHighlightRules().getRules(), "i"); this.$tokenizer = new Tokenizer(new C9SearchHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.foldingRules = new C9StyleFoldMode(); this.foldingRules = new C9StyleFoldMode();
}; };

View file

@ -99,7 +99,7 @@ define(function(require, exports, module) {
token : "string", regex : "'''", next : [ token : "string", regex : "'''", next : [
{token : "string", regex : "'''", next : "start"}, {token : "string", regex : "'''", next : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"}, {defaultToken: "string"}
] ]
}, { }, {
stateName: "qqdoc", stateName: "qqdoc",
@ -115,21 +115,21 @@ define(function(require, exports, module) {
token : "string", regex : "'", next : [ token : "string", regex : "'", next : [
{token : "string", regex : "'", next : "start"}, {token : "string", regex : "'", next : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"}, {defaultToken: "string"}
] ]
}, { }, {
stateName: "qqstring", stateName: "qqstring",
token : "string.start", regex : '"', next : [ token : "string.start", regex : '"', next : [
{token : "string.end", regex : '"', next : "start"}, {token : "string.end", regex : '"', next : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"}, {defaultToken: "string"}
] ]
}, { }, {
stateName: "js", stateName: "js",
token : "string", regex : "`", next : [ token : "string", regex : "`", next : [
{token : "string", regex : "`", next : "start"}, {token : "string", regex : "`", next : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"}, {defaultToken: "string"}
] ]
}, { }, {
token : "string.regex", token : "string.regex",

View file

@ -30,11 +30,17 @@ var CSharpHighlightRules = function() {
token : "string.regexp", token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, { }, {
token : "string", // single line token : "string", // character
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
}, { }, {
token : "string", // single line token : "string", start : '"', end : '"|$', next: [
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
{token: "invalid", regex: /\\./}
]
}, {
token : "string", start : '@"', end : '"', next:[
{token: "constant.language.escape", 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"
@ -46,8 +52,6 @@ var CSharpHighlightRules = function() {
regex : "(?:true|false)\\b" regex : "(?:true|false)\\b"
}, { }, {
token : keywordMapper, token : keywordMapper,
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
@ -80,6 +84,7 @@ var CSharpHighlightRules = function() {
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);
this.normalizeRules();
}; };
oop.inherits(CSharpHighlightRules, TextHighlightRules); oop.inherits(CSharpHighlightRules, TextHighlightRules);

View file

@ -41,7 +41,7 @@ var CssBehaviour = require("./behaviour/css").CssBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CssBehaviour(); this.$behaviour = new CssBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();

View file

@ -89,9 +89,14 @@ var CssHighlightRules = function() {
}, { }, {
token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
regex : pseudoClasses regex : pseudoClasses
}, {
token : ["support.function", "string", "support.function"],
regex : "(url\\()(.*)(\\))"
}, { }, {
token : keywordMapper, token : keywordMapper,
regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
}, {
caseInsensitive: true
} }
]; ];
@ -160,6 +165,8 @@ var CssHighlightRules = function() {
},{ },{
token: "constant", token: "constant",
regex: "[a-z0-9-_]+" regex: "[a-z0-9-_]+"
},{
caseInsensitive: true
}], }],
"media" : [ { "media" : [ {
@ -186,6 +193,8 @@ var CssHighlightRules = function() {
},{ },{
token: "constant", token: "constant",
regex: "[a-z0-9-_]+" regex: "[a-z0-9-_]+"
},{
caseInsensitive: true
}], }],
"comment" : comment, "comment" : comment,

View file

@ -38,7 +38,7 @@ var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
var FoldMode = require("./folding/diff").FoldMode; var FoldMode = require("./folding/diff").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i"); this.$tokenizer = new Tokenizer(new HighlightRules().getRules());
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i"); this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);

View file

@ -92,7 +92,8 @@ var DiffHighlightRules = function() {
regex: "\\s*$", regex: "\\s*$",
token: "invalid" token: "invalid"
}, { }, {
defaultToken: "invisible" defaultToken: "invisible",
caseInsensitive: true
} }
] ]
}; };

View file

@ -91,13 +91,13 @@ oop.inherits(Mode, TextMode);
return indent; return indent;
} }
if (state == "start" || state == "regex_allowed") { if (state == "start" || state == "no_regex") {
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
if (match) { if (match) {
indent += tab; indent += tab;
} }
} else if (state == "doc-start") { } else if (state == "doc-start") {
if (endState == "start" || state == "regex_allowed") { if (endState == "start" || endState == "no_regex") {
return ""; return "";
} }
var match = line.match(/^\s*(\/?)\*/); var match = line.match(/^\s*(\/?)\*/);

View file

@ -83,7 +83,7 @@ var JavaScriptHighlightRules = function() {
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
this.$rules = { this.$rules = {
"start" : [ "no_regex" : [
{ {
token : "comment", token : "comment",
regex : /\/\/.*$/ regex : /\/\/.*$/
@ -165,7 +165,7 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "start"
}, { }, {
token : ["punctuation.operator", "support.function"], token : ["punctuation.operator", "support.function"],
regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
@ -184,22 +184,22 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/, regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
next : "regex_allowed" next : "start"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : /\?|\:|\,|\;|\./, regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "start"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : /[\[({]/, regex : /[\[({]/,
next : "regex_allowed" next : "start"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : /[\])}]/ regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : /\/=?/, regex : /\/=?/,
next : "regex_allowed" next : "start"
}, { }, {
token: "comment", token: "comment",
regex: /^#!.*$/ regex: /^#!.*$/
@ -207,7 +207,7 @@ var JavaScriptHighlightRules = function() {
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
// makes sure we don't mix up regexps with the divison operator // makes sure we don't mix up regexps with the divison operator
"regex_allowed": [ "start": [
DocCommentHighlightRules.getStartRule("doc-start"), DocCommentHighlightRules.getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
@ -215,20 +215,22 @@ var JavaScriptHighlightRules = function() {
next : "comment_regex_allowed" next : "comment_regex_allowed"
}, { }, {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : "\\/\\/.*$",
next : "start"
}, { }, {
token: "string.regexp", token: "string.regexp",
regex: "\\/", regex: "\\/",
next: "regex", next: "regex",
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+|^$",
next : "start"
}, { }, {
// immediately return to the start mode without matching // immediately return to the start mode without matching
// anything // anything
token: "empty", token: "empty",
regex: "", regex: "",
next: "start" next: "no_regex"
} }
], ],
"regex": [ "regex": [
@ -240,7 +242,7 @@ var JavaScriptHighlightRules = function() {
// flag // flag
token: "string.regexp", token: "string.regexp",
regex: "/\\w*", regex: "/\\w*",
next: "start", next: "no_regex",
}, { }, {
// invalid operators // invalid operators
token : "invalid", token : "invalid",
@ -259,7 +261,7 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token: "empty", token: "empty",
regex: "$", regex: "$",
next: "start" next: "no_regex"
}, { }, {
defaultToken: "string.regexp" defaultToken: "string.regexp"
} }
@ -278,7 +280,7 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token: "empty", token: "empty",
regex: "$", regex: "$",
next: "start" next: "no_regex"
}, { }, {
defaultToken: "string.regexp.charachterclass" defaultToken: "string.regexp.charachterclass"
} }
@ -296,15 +298,15 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token: "empty", token: "empty",
regex: "", regex: "",
next: "start" next: "no_regex"
} }
], ],
"comment_regex_allowed" : [ "comment_regex_allowed" : [
{token : "comment", regex : "\\*\\/", next : "regex_allowed"}, {token : "comment", regex : "\\*\\/", next : "start"},
{defaultToken : "comment"} {defaultToken : "comment"}
], ],
"comment" : [ "comment" : [
{token : "comment", regex : "\\*\\/", next : "start"}, {token : "comment", regex : "\\*\\/", next : "no_regex"},
{defaultToken : "comment"} {defaultToken : "comment"}
], ],
"qqstring" : [ "qqstring" : [
@ -318,7 +320,7 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : "string", token : "string",
regex : '"|$', regex : '"|$',
next : "start", next : "no_regex",
}, { }, {
defaultToken: "string" defaultToken: "string"
} }
@ -334,7 +336,7 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : "string", token : "string",
regex : "'|$", regex : "'|$",
next : "start", next : "no_regex",
}, { }, {
defaultToken: "string" defaultToken: "string"
} }
@ -342,7 +344,7 @@ var JavaScriptHighlightRules = function() {
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("no_regex") ]);
}; };
oop.inherits(JavaScriptHighlightRules, TextHighlightRules); oop.inherits(JavaScriptHighlightRules, TextHighlightRules);

View file

@ -115,7 +115,7 @@ module.exports = {
"test: no auto indent should add to existing indent" : function() { "test: no auto indent should add to existing indent" : function() {
assert.equal(" ", this.mode.getNextLineIndent("start", " if () {", " ")); assert.equal(" ", this.mode.getNextLineIndent("start", " if () {", " "));
assert.equal(" ", this.mode.getNextLineIndent("start", " cde", " ")); assert.equal(" ", this.mode.getNextLineIndent("start", " cde", " "));
assert.equal(" ", this.mode.getNextLineIndent("regex_allowed", "function foo(items) {", " ")); assert.equal(" ", this.mode.getNextLineIndent("start", "function foo(items) {", " "));
}, },
"test: special indent in doc comments" : function() { "test: special indent in doc comments" : function() {

View file

@ -40,7 +40,7 @@ var CssBehaviour = require("./behaviour/css").CssBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new LessHighlightRules().getRules(), "i"); this.$tokenizer = new Tokenizer(new LessHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CssBehaviour(); this.$behaviour = new CssBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();

View file

@ -247,6 +247,8 @@ var LessHighlightRules = function() {
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
}, {
caseInsensitive: true
} }
], ],
"comment" : [ "comment" : [

View file

@ -1,4 +1,4 @@
define('ace/mode/ls', function(require, exports, module){ define(function(require, exports, module){
var identifier, LiveScriptMode, keywordend, stringfill; var identifier, LiveScriptMode, keywordend, stringfill;
identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*'; identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
exports.Mode = LiveScriptMode = (function(superclass){ exports.Mode = LiveScriptMode = (function(superclass){

View file

@ -100,11 +100,12 @@ var MarkdownHighlightRules = function() {
}, { // h2 }, { // h2
token: "markup.heading.2", token: "markup.heading.2",
regex: "^\\-+(?=\\s*$)" regex: "^\\-+(?=\\s*$)"
}, { // header }, {
token : function(value) { token : function(value) {
return "markup.heading." + value.search(/[^#]/); return "markup.heading." + value.length;
}, },
regex : "^#{1,6}(?:[^ #].*| +.*(?:[^ #].*|[^ ]+.* +#+ *))$" regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
next : "header"
}, },
github_embed("(?:javascript|js)", "js-"), github_embed("(?:javascript|js)", "js-"),
github_embed("xml", "xml-"), github_embed("xml", "xml-"),
@ -130,6 +131,15 @@ var MarkdownHighlightRules = function() {
include : "basic" include : "basic"
}], }],
"header" : [{
regex: "$",
next : "start"
}, {
include: "basic"
}, {
defaultToken : "markup.heading"
} ],
"listblock-start" : [{ "listblock-start" : [{
token : "support.variable", token : "support.variable",
regex : /(?:\[[ x]\])?/, regex : /(?:\[[ x]\])?/,

62
lib/ace/mode/pascal.js Normal file
View file

@ -0,0 +1,62 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Contributor(s):
*
*
*
* ***** END LICENSE BLOCK ***** */
/*
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
*/
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var PascalHighlightRules = require("./pascal_highlight_rules").PascalHighlightRules;
// TODO: pick appropriate fold mode
var FoldMode = require("./folding/coffee").FoldMode;
var Mode = function() {
var highlighter = new PascalHighlightRules();
this.foldingRules = new FoldMode();
this.$tokenizer = new Tokenizer(highlighter.getRules());
};
oop.inherits(Mode, TextMode);
(function() {
// Extra logic goes here.
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,127 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/* THIS FILE WAS AUTOGENERATED FROM tool\tm bundles\pascal.tmbundle\Syntaxes\Pascal.plist (UUID: F42FA544-6B1C-11D9-9517-000D93589AF6) */
/****************************************************************
* IT MIGHT NOT BE PERFECT, PARTICULARLY: *
* IN DECIDING STATES TO TRANSITION TO, *
* IGNORING WHITESPACE, *
* IGNORING GROUPS WITH ?:, *
* EXTENDING EXISTING MODES, *
* GATHERING KEYWORDS, OR *
* DECIDING WHEN TO USE PUSH. *
* ...But it's a good start from an existing *.tmlanguage file. *
****************************************************************/
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PascalHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = { start:
[ { caseInsensitive: true,
token: 'keyword.control.pascal',
regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
{ caseInsensitive: true,
token:
[ 'variable.pascal', "text",
'storage.type.prototype.pascal',
'entity.name.function.prototype.pascal' ],
regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
{ token: 'keyword.operator',
regex: '[+\\-;,/*%]|:=|=' },
{ caseInsensitive: true,
token:
[ 'variable.pascal', "text",
'storage.type.function.pascal',
'entity.name.function.pascal' ],
regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
{ token: 'constant.numeric.pascal',
regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
{ token: 'punctuation.definition.comment.pascal',
regex: '--',
push:
[ { token: 'comment.line.double-dash.pascal.one',
regex: '$',
next: 'pop' },
{ defaultToken: 'comment.line.double-dash.pascal.one' } ] },
{ token: 'punctuation.definition.comment.pascal',
regex: '//',
push:
[ { token: 'comment.line.double-slash.pascal.two',
regex: '$',
next: 'pop' },
{ defaultToken: 'comment.line.double-slash.pascal.two' } ] },
{ token: 'punctuation.definition.comment.pascal',
regex: '\\(\\*',
push:
[ { token: 'punctuation.definition.comment.pascal',
regex: '\\*\\)',
next: 'pop' },
{ defaultToken: 'comment.block.pascal.one' } ] },
{ token: 'punctuation.definition.comment.pascal',
regex: '\\{',
push:
[ { token: 'punctuation.definition.comment.pascal',
regex: '\\}',
next: 'pop' },
{ defaultToken: 'comment.block.pascal.two' } ] },
{ token: 'punctuation.definition.string.begin.pascal',
regex: '"',
push:
[ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
{ token: 'punctuation.definition.string.end.pascal',
regex: '"',
next: 'pop' },
{ defaultToken: 'string.quoted.double.pascal' } ],
//Double quoted strings are an extension and (generally) support C-style escape sequences.
},
{ token: 'punctuation.definition.string.begin.pascal',
regex: '\'',
push:
[ { token: 'constant.character.escape.apostrophe.pascal',
regex: '\'\'' },
{ token: 'punctuation.definition.string.end.pascal',
regex: '\'',
next: 'pop' },
{ defaultToken: 'string.quoted.single.pascal' } ] } ] }
this.normalizeRules();
};
oop.inherits(PascalHighlightRules, TextHighlightRules);
exports.PascalHighlightRules = PascalHighlightRules;
});

View file

@ -899,11 +899,7 @@ var PhpLangHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /(?:#|\/\/)(?:[^?]|\?[^>])*/
},
{
token : "comment",
regex : "#.*$"
}, },
docComment.getStartRule("doc-start"), docComment.getStartRule("doc-start"),
{ {
@ -1058,8 +1054,8 @@ var PhpHighlightRules = function() {
for (var i in this.$rules) { for (var i in this.$rules) {
this.$rules[i].unshift({ this.$rules[i].unshift({
token : "support.php_tag", // php open tag token : "support.php_tag", // php open tag
regex : "<\\?(?:php|\\=)?", regex : "<\\?(?:php|=)?",
next : "php-start" push : "php-start"
}); });
} }
@ -1068,8 +1064,9 @@ var PhpHighlightRules = function() {
this.$rules["php-start"].unshift({ this.$rules["php-start"].unshift({
token : "support.php_tag", // php close tag token : "support.php_tag", // php close tag
regex : "\\?>", regex : "\\?>",
next : "start" next : "pop"
}); });
this.normalizeRules();
}; };
oop.inherits(PhpHighlightRules, HtmlHighlightRules); oop.inherits(PhpHighlightRules, HtmlHighlightRules);

View file

@ -174,11 +174,11 @@ var RubyHighlightRules = function() {
}, { }, {
stateName: "heredoc", stateName: "heredoc",
token : function(value, currentState, stack) { token : function(value, currentState, stack) {
var next = value[3] == '-' ? "heredoc" : "indentedHeredoc"; var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
var tokens = value.split(this.splitRegex); var tokens = value.split(this.splitRegex);
stack.push(next, tokens[3]); stack.push(next, tokens[3]);
return [ return [
{type:"constant", value: "<<"}, {type:"constant", value: tokens[1]},
{type:"string", value: tokens[2]}, {type:"string", value: tokens[2]},
{type:"support.class", value: tokens[3]}, {type:"support.class", value: tokens[3]},
{type:"string", value: tokens[4]} {type:"string", value: tokens[4]}

52
lib/ace/mode/sass.js Normal file
View file

@ -0,0 +1,52 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var SassHighlightRules = require("./sass_highlight_rules").SassHighlightRules;
var FoldMode = require("./folding/coffee").FoldMode;
var Mode = function() {
this.$tokenizer = new Tokenizer(new SassHighlightRules().getRules());
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,79 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var ScssHighlightRules = require("./scss_highlight_rules").ScssHighlightRules;
var SassHighlightRules = function() {
ScssHighlightRules.call(this);
var start = this.$rules.start;
if (start[1].token == "comment") {
start.splice(1, 1, {
token: function(value, currentState, stack) {
stack.unshift(this.next, value.length - 2, currentState);
return "comment";
},
regex: /^\s*\/\*/,
next: "comment"
}, {
token: "error.invalid",
regex: "/\\*|[{;}]"
}, {
token: "support.type",
regex: /^\s*:[\w\-]+\s/,
});
this.$rules.comment = [
{regex: /^\s*/, token: function(value, currentState, stack) {
if (value.length < stack[1]) {
stack.shift();
stack.shift();
this.next = stack.shift();
return "text";
} else {
stack[1] = value.length;
this.next = "";
return "comment";
}
}, next: "start"},
{defaultToken: "comment"}
]
}
};
oop.inherits(SassHighlightRules, ScssHighlightRules);
exports.SassHighlightRules = SassHighlightRules;
});

View file

@ -40,7 +40,7 @@ var CssBehaviour = require("./behaviour/css").CssBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new ScssHighlightRules().getRules(), "i"); this.$tokenizer = new Tokenizer(new ScssHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CssBehaviour(); this.$behaviour = new CssBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();

View file

@ -66,8 +66,8 @@ var ScssHighlightRules = function() {
"border-color|border-left-color|border-left-style|border-left-width|" + "border-color|border-left-color|border-left-style|border-left-width|" +
"border-left|border-right-color|border-right-style|border-right-width|" + "border-left|border-right-color|border-right-style|border-right-width|" +
"border-right|border-spacing|border-style|border-top-color|" + "border-right|border-spacing|border-style|border-top-color|" +
"border-top-style|border-top-width|border-top|border-width|border|" + "border-top-style|border-top-width|border-top|border-width|border|bottom|" +
"bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" + "box-shadow|box-sizing|caption-side|clear|clip|color|content|counter-increment|" +
"counter-reset|cue-after|cue-before|cue|cursor|direction|display|" + "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
"elevation|empty-cells|float|font-family|font-size-adjust|font-size|" + "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
"font-stretch|font-style|font-variant|font-weight|font|height|left|" + "font-stretch|font-style|font-variant|font-weight|font|height|left|" +
@ -204,6 +204,9 @@ var ScssHighlightRules = function() {
}, { }, {
token : "constant.numeric", token : "constant.numeric",
regex : numRe regex : numRe
}, {
token : ["support.function", "string", "support.function"],
regex : "(url\\()(.*)(\\))"
}, { }, {
token : function(value) { token : function(value) {
if (properties.hasOwnProperty(value.toLowerCase())) if (properties.hasOwnProperty(value.toLowerCase()))
@ -249,6 +252,8 @@ var ScssHighlightRules = function() {
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
}, {
caseInsensitive: true
} }
], ],
"comment" : [ "comment" : [

View file

@ -65,7 +65,7 @@ var Mode = function() {
}; };
this.getNextLineIndent = function(state, line, tab) { this.getNextLineIndent = function(state, line, tab) {
return ""; return this.$getIndent(line);
}; };
this.checkOutdent = function(state, line, input) { this.checkOutdent = function(state, line, input) {

View file

@ -43,8 +43,7 @@ var TextHighlightRules = function() {
token : "empty_line", token : "empty_line",
regex : '^$' regex : '^$'
}, { }, {
token : "text", defaultToken : "text"
regex : ".+"
}] }]
}; };
}; };
@ -96,35 +95,85 @@ var TextHighlightRules = function() {
return this.$embeds; return this.$embeds;
}; };
var pushState = function(currentState, stack) {
if (currentState != "start")
stack.unshift(this.nextState, currentState);
return this.nextState;
};
var popState = function(currentState, stack) {
if (stack[0] !== currentState)
return "start";
stack.shift();
return stack.shift();
};
this.normalizeRules = function() { this.normalizeRules = function() {
var id = 0; var id = 0;
for (var key in this.$rules) { var rules = this.$rules;
var state = this.$rules[key]; function processState(key) {
var state = rules[key];
state.processed = true;
for (var i = 0; i < state.length; i++) { for (var i = 0; i < state.length; i++) {
var rule = state[i]; var rule = state[i];
if (rule.next && Array.isArray(rule.next)) { if (!rule.regex && rule.start) {
var stateName = rule.stateName || ("state" + id++); rule.regex = rule.start;
this.$rules[stateName] = rule.next; if (!rule.next)
rule.next = stateName; rule.next = [];
rule.next.push({
defaultToken: rule.token
}, {
token: rule.token + ".end",
regex: rule.end || rule.start,
next: "pop"
});
rule.token = rule.token + ".start";
rule.push = true;
} }
var next = rule.next || rule.push;
if (next && Array.isArray(next)) {
var stateName = rule.stateName || (rule.token + id++);
rules[stateName] = next;
rule.next = stateName;
processState(stateName);
} else if (next == "pop") {
rule.next = popState;
}
if (rule.push) {
rule.nextState = rule.next || rule.push;
rule.next = pushState;
delete rule.push;
}
if (rule.rules) { if (rule.rules) {
for (var r in rule.rules) { for (var r in rule.rules) {
if (this.$rules[r]) { if (rules[r]) {
if (this.$rules[r].push) if (rules[r].push)
this.$rules[r].push.apply(this.$rules[r], rule.rules[r]); rules[r].push.apply(rules[r], rule.rules[r]);
} else { } else {
this.$rules[r] = rule.rules[r]; rules[r] = rule.rules[r];
} }
} }
} }
if (rule.include || typeof rule == "string") { if (rule.include || typeof rule == "string") {
var args = [i, 1].concat(this.$rules[rule.include || rule]); var includeName = rule.include || rule;
var toInsert = rules[includeName];
} else if (Array.isArray(rule))
toInsert = rule;
if (toInsert) {
var args = [i, 1].concat(toInsert);
if (rule.noEscape) if (rule.noEscape)
args = args.filter(function(x) {return !x.next;}); args = args.filter(function(x) {return !x.next;});
state.splice.apply(state, args); state.splice.apply(state, args);
// skip included rules since they are already processed
//i += args.length - 3;
i--;
toInsert = null
} }
} }
} };
Object.keys(rules).forEach(processState);
}; };
this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) { this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {

View file

@ -46,19 +46,19 @@ var SnippetHighlightRules = function() {
{regex: /\[/, token: "regex.start", next: "charClass"}, {regex: /\[/, token: "regex.start", next: "charClass"},
{regex: "/", token: "string.regex", next: "format"}, {regex: "/", token: "string.regex", next: "format"},
//{"default": "string.regex"}, //{"default": "string.regex"},
{"token": "string.regex", regex:"."}, {"token": "string.regex", regex:"."}
], ],
charClass : [ charClass : [
{regex: "\\.", token: "escape"}, {regex: "\\.", token: "escape"},
{regex: "\\]", token: "regex.end", next: "regexp"}, {regex: "\\]", token: "regex.end", next: "regexp"},
{"token": "string.regex", regex:"."}, {"token": "string.regex", regex:"."}
], ],
"format" : [ "format" : [
{regex: /\\[ulULE]/, token: "keyword"}, {regex: /\\[ulULE]/, token: "keyword"},
{regex: /\$\d+/, token: "variable"}, {regex: /\$\d+/, token: "variable"},
{regex: "/[gim]*:?", token: "string.regex", next: "start"}, {regex: "/[gim]*:?", token: "string.regex", next: "start"},
// {"default": "string"}, // {"default": "string"},
{"token": "string", regex:"."}, {"token": "string", regex:"."}
] ]
}; };
}; };

View file

@ -451,7 +451,7 @@ module.exports = {
assert.position(ranges[1].end, 0, 11); assert.position(ranges[1].end, 0, 11);
assert.position(ranges[0].start, 0, 0); assert.position(ranges[0].start, 0, 0);
assert.position(ranges[0].end, 0, 3); assert.position(ranges[0].end, 0, 3);
}, }
}; };
}); });

View file

@ -31,6 +31,8 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
// tokenizing lines longer than this makes editor very slow
var MAX_TOKEN_COUNT = 1000;
/** /**
* *
* *
@ -41,15 +43,10 @@ define(function(require, exports, module) {
/** /**
* Constructs a new tokenizer based on the given rules and flags. * Constructs a new tokenizer based on the given rules and flags.
* @param {Object} rules The highlighting rules * @param {Object} rules The highlighting rules
* @param {String} flag Any additional regular expression flags to pass (like "i" for case insensitive)
*
*
*
* *
* @constructor * @constructor
**/ **/
var Tokenizer = function(rules, flag) { var Tokenizer = function(rules) {
flag = flag ? "g" + flag : "g";
this.states = rules; this.states = rules;
this.regExps = {}; this.regExps = {};
@ -59,13 +56,17 @@ var Tokenizer = function(rules, flag) {
var ruleRegExps = []; var ruleRegExps = [];
var matchTotal = 0; var matchTotal = 0;
var mapping = this.matchMappings[key] = {defaultToken: "text"}; var mapping = this.matchMappings[key] = {defaultToken: "text"};
var flag = "g";
for (var i = 0; i < state.length; i++) { for (var i = 0; i < state.length; i++) {
var rule = state[i]; var rule = state[i];
if (rule.defaultToken) { if (rule.defaultToken)
mapping.defaultToken = rule.defaultToken; mapping.defaultToken = rule.defaultToken;
if (rule.caseInsensitive)
flag = "gi";
if (rule.regex == null)
continue; continue;
}
if (rule.regex instanceof RegExp) if (rule.regex instanceof RegExp)
rule.regex = rule.regex.toString().slice(1, -1); rule.regex = rule.regex.toString().slice(1, -1);
@ -110,12 +111,12 @@ var Tokenizer = function(rules, flag) {
this.$arrayTokens = function(str) { this.$arrayTokens = function(str) {
if (!str) if (!str)
return []; return [];
var values = str.split(this.splitRegex) var values = this.splitRegex.exec(str);
var tokens = []; var tokens = [];
var types = this.tokenArray; var types = this.tokenArray;
if (types.length != values.length - 2) { if (types.length != values.length - 1) {
if (window.console) if (window.console)
console.error(types.length , values.length - 2, str, this.splitRegex); console.error(types , values, str, this.splitRegex, this);
return [{type: "error.invalid", value: str}]; return [{type: "error.invalid", value: str}];
} }
for (var i = 0; i < types.length; i++) { for (var i = 0; i < types.length; i++) {
@ -138,8 +139,8 @@ var Tokenizer = function(rules, flag) {
}; };
this.createSplitterRegexp = function(src, flag) { this.createSplitterRegexp = function(src, flag) {
src = src.replace(/\(\?=([^()]|\\.)*?\)$/, ""); src = src.replace(/\(\?=([^()]|\\.|\(([^()]|\\.)*?\))*\)(?=\)*$)/, "");
return new RegExp(src, flag); return new RegExp(src, (flag||"").replace("g", ""));
}; };
/** /**
@ -193,7 +194,11 @@ var Tokenizer = function(rules, flag) {
: rule.token; : rule.token;
if (rule.next) { if (rule.next) {
if (typeof rule.next == "string")
currentState = rule.next; currentState = rule.next;
else
currentState = rule.next(currentState, stack);
state = this.states[currentState]; state = this.states[currentState];
if (!state) { if (!state) {
window.console && console.error && console.error(currentState, "doesn't exist"); window.console && console.error && console.error(currentState, "doesn't exist");
@ -230,6 +235,12 @@ var Tokenizer = function(rules, flag) {
break; break;
lastIndex = index; lastIndex = index;
if (tokens.length > MAX_TOKEN_COUNT) {
token.value += line.substr(lastIndex);
currentState = "start"
break;
}
} }
if (token.type) if (token.type)

View file

@ -30,13 +30,15 @@
define(function(require, exports, module) { define(function(require, exports, module) {
// tokenizing lines longer than this makes editor very slow
var MAX_TOKEN_COUNT = 1000;
/* /*
* version of Tokenizer with additional logging * version of Tokenizer with additional logging
* and infinite loop checks * and infinite loop checks
* can be used for developing/testing new modes * can be used for developing/testing new modes
**/ **/
var Tokenizer = function(rules, flag) {
flag = flag ? "g" + flag : "g"; var Tokenizer = function(rules) {
this.states = rules; this.states = rules;
this.regExps = {}; this.regExps = {};
@ -46,13 +48,17 @@ var Tokenizer = function(rules, flag) {
var ruleRegExps = []; var ruleRegExps = [];
var matchTotal = 0; var matchTotal = 0;
var mapping = this.matchMappings[key] = {defaultToken: "default.text"}; var mapping = this.matchMappings[key] = {defaultToken: "default.text"};
var flag = "g";
for (var i = 0; i < state.length; i++) { for (var i = 0; i < state.length; i++) {
var rule = state[i]; var rule = state[i];
if (rule.defaultToken) { if (rule.defaultToken)
mapping.defaultToken = rule.defaultToken; mapping.defaultToken = rule.defaultToken;
if (rule.caseInsensitive)
flag = "gi";
if (rule.regex == null)
continue; continue;
}
if (rule.regex instanceof RegExp) if (rule.regex instanceof RegExp)
rule.regex = rule.regex.toString().slice(1, -1); rule.regex = rule.regex.toString().slice(1, -1);
@ -202,7 +208,11 @@ var Tokenizer = function(rules, flag) {
: rule.token; : rule.token;
if (rule.next) { if (rule.next) {
if (typeof rule.next == "string")
currentState = rule.next; currentState = rule.next;
else
currentState = rule.next(currentState, stack);
state = this.states[currentState]; state = this.states[currentState];
if (!state) { if (!state) {
window.console && console.error && console.error(currentState, "doesn't exist"); window.console && console.error && console.error(currentState, "doesn't exist");
@ -241,6 +251,12 @@ var Tokenizer = function(rules, flag) {
break; break;
lastIndex = index; lastIndex = index;
if (tokens.length > MAX_TOKEN_COUNT) {
token.value += line.substr(lastIndex);
currentState = "start"
break;
}
} }
if (token.type) if (token.type)

38
tool/lib.js Normal file
View file

@ -0,0 +1,38 @@
var plist = require("plist");
var util = require("util");
exports.parsePlist = function(themeXml, callback) {
var result = ""
plist.parseString(themeXml, function(_, theme) {
result = theme[0];
callback && callback(theme[0]);
});
return result;
}
exports.formatJSON = function(object, initialIndent) {
return util.inspect(object, false, 40).replace(/^/gm, initialIndent||"")
}
exports.fillTemplate = function(template, replacements) {
return template.replace(/%(.+?)%/g, function(str, m) {
return replacements[m] || "";
});
}
exports.hyphenate = function(str) {
return str.replace(/([A-Z])/g, "-$1").replace(/_/g, "-").toLowerCase();
}
exports.quoteString = function(str) {
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
}
exports.restoreJSONComments = function(objStr) {
return objStr.replace(/^(\s*)comment: '(.*)'/gm, function(_, i, c) {
return i + "//" + c.replace(/\\n(\\t)*/g, "\n" + i + "//") + "\n" + i
}).replace(/ \/\/ ERROR/g, '", // ERROR');
}

View file

@ -21,6 +21,34 @@
.separator-h { .separator-h {
padding: 0 20px; padding: 0 20px;
} }
#closeBtn {
background: rgba(245, 146, 146, 0.5);
border: 1px solid #F48A8A;
border-radius: 50%;
padding: 7px;
position: absolute;
right: -8px;
top: -8px;
z-index: 1000;
}
#closeBtn:hover {
background: rgba(245, 146, 146, 0.9);
}
#console{
/border: 1px solid lightblue;
bottom: 0;
height: 80px;
margin: 0 4%;
position: absolute;
width: 92%;
z-index: 1000;
box-shadow: 0 0 1px 2px gray
}
#consoleEditor{
height: 100%;
position: relative;
width: 100%;
}
</style> </style>
<link href="../doc/site/images/favicon.ico" rel="icon" type="image/x-icon"> <link href="../doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
</head> </head>
@ -29,10 +57,13 @@
<div id="header"> <div id="header">
<label for="modeEl">mode</label> <label for="modeEl">mode</label>
<select id="modeEl" size="1"></select> <select id="modeEl" size="1"></select>
<input type="button" value="&#10227;" title="sync" id="syncToMode"></select>
<span id="tablist"></span> <span id="tablist"></span>
<span class="separator-h"></span> <span class="separator-h"></span>
<label for="autorunEl">live preview</label> <label for="autorunEl">live preview</label>
<input type="checkbox" label="autorun" id="autorunEl" checked> <input type="checkbox" label="autorun" id="autorunEl" checked>
<span class="separator-h"></span>
<input type="button" value="measure speed" id="perfTest"></select>
<div style='float:right'> <div style='float:right'>
@ -44,6 +75,10 @@
</div> </div>
</div> </div>
<div id="editor"></div> <div id="editor"></div>
<div id="console" style="display:none">
<span id="closeBtn" onclick="this.parentNode.style.display='none'"></span>
<div id="consoleEditor"></div>
</div>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -14,6 +14,7 @@ var EditSession = require("ace/edit_session").EditSession;
var UndoManager = require("ace/undomanager").UndoManager; var UndoManager = require("ace/undomanager").UndoManager;
var DebugTokenizer = require("ace/tokenizer_dev").Tokenizer; var DebugTokenizer = require("ace/tokenizer_dev").Tokenizer;
var Tokenizer = require("ace/tokenizer").Tokenizer;
// createEditor // createEditor
var splitEditor = window.splitEditor = util.createSplitEditor("editor"); var splitEditor = window.splitEditor = util.createSplitEditor("editor");
@ -74,6 +75,33 @@ util.bindDropdown(modeEl, function(value) {
}); });
}); });
document.getElementById("syncToMode").onclick = function() {
docEl.value = modelist.modesByName[modeEl.value].desc;
docEl.onchange();
run();
}
document.getElementById("perfTest").onclick = function() {
var lines = editor2.session.doc.getAllLines()
if (!lines.length)
return
while (lines.length < 1000) {
lines = lines.concat(lines)
}
var tk = new Tokenizer(currentRules);
var testPerf = function(lines, tk){
var state = "start"
for (var i=0, l = lines.length; i <l; i++) {
state = tk.getLineTokens(lines[i], state).state
}
}
var t = performance.now();
testPerf(lines, tk);
t = t - performance.now(t);
log("tokenized " + lines.length + " lines in " + t + " ms");
}
util.fillDropdown("themeEl", { util.fillDropdown("themeEl", {
bright: [ bright: [
"chrome", "clouds", "crimson_editor", "dawn", "dreamweaver", "eclipse", "github", "chrome", "clouds", "crimson_editor", "dawn", "dreamweaver", "eclipse", "github",
@ -118,18 +146,26 @@ function run() {
var path = "ace/mode/new"; var path = "ace/mode/new";
var deps = getDeps(src, path); var deps = getDeps(src, path);
src = src.replace("define(", 'define("' + path +'", ["require","exports","module",' + deps +'],'); src = src.replace("define(", 'define("' + path +'", ["require","exports","module",' + deps +'],');
src += ';require(["ace/mode/new"], continueRun, function(e){console.log(e);window.require.undef("ace/mode/new")})'; src += ';require(["ace/mode/new"], function(e) {\
try{continueRun(e)}catch(e){log(e)}\
}, function(e){\
log(e);\
window.require.undef("ace/mode/new")\
});';
try { try {
eval(src); eval(src);
hideLog()
} catch(e) { } catch(e) {
console.log(e); log(e);
} }
} }
var currentRules
var continueRun = function(rules) { var continueRun = function(rules) {
rules = rules[Object.keys(rules)[0]]; rules = rules[Object.keys(rules)[0]];
currentRules = new rules().getRules()
var Tokenizer = DebugTokenizer; var Tokenizer = DebugTokenizer;
var tk = new Tokenizer(new rules().getRules()); var tk = new Tokenizer(currentRules);
editor2.session.$mode.$tokenizer = tk; editor2.session.$mode.$tokenizer = tk;
editor2.session.bgTokenizer.setTokenizer(tk); editor2.session.bgTokenizer.setTokenizer(tk);
editor2.renderer.updateText(); editor2.renderer.updateText();
@ -137,5 +173,23 @@ var continueRun = function(rules) {
editor1.commands.bindKey("ctrl-Return", run); editor1.commands.bindKey("ctrl-Return", run);
var logEditor
function log(e) {
console.log(e)
if (!logEditor) {
logEditor = util.createEditor(document.getElementById("consoleEditor"));
logEditor.session.setMode("ace/mode/javascript")
logEditor.session.setUseWorker(false)
}
logEditor.container.parentNode.style.display = '';
logEditor.resize()
logEditor.navigateFileEnd(e);
logEditor.insert(e + "\n");
}
function hideLog() {
if (logEditor)
logEditor.container.parentNode.style.display = 'none';
}
}); });

View file

@ -26,35 +26,19 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*
* Contributor(s):
*
*
*
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/* /* THIS FILE WAS AUTOGENERATED FROM %name% (UUID: %uuid%) */
THIS FILE WAS AUTOGENERATED BY %name% (UUID: %uuid%) */ /****************************************************************
* IT MIGHT NOT BE PERFECT, PARTICULARLY: *
/******* * IN DECIDING STATES TO TRANSITION TO, *
* IGNORING WHITESPACE, *
THIS FILE MIGHT NOT BE PERFECT, PARTICULARLY: * IGNORING GROUPS WITH ?:, *
* EXTENDING EXISTING MODES, *
IN DECIDING STATES TO TRANSITION TO, * GATHERING KEYWORDS, OR *
* DECIDING WHEN TO USE PUSH. *
IGNORING WHITESPACE, * ...But it's a good start from an existing *.tmlanguage file. *
****************************************************************/
IGNORING GROUPS WITH ?:,
EXTENDING EXISTING MODES,
GATHERING KEYWORDS, OR
RULE PREFERENCE ORDER.
...But it's a good start from an existing *.tmlanguage file.
*******/
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
@ -63,14 +47,12 @@ var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var %language%HighlightRules = function() { var %language%HighlightRules = function() {
// 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 = %languageTokens%
%languageTokens%
%repositoryRules% this.normalizeRules();
}; };
oop.inherits(%language%HighlightRules, TextHighlightRules); oop.inherits(%language%HighlightRules, TextHighlightRules);

View file

@ -1,89 +1,110 @@
var fs = require("fs"); var fs = require("fs");
var util = require("util"); var util = require("util");
var lib = require("./lib");
var parseLanguage = lib.parsePlist;
// for tracking token states
var startState = { start: [] }, statesObj = { };
var args = process.argv.splice(2);
var tmLanguageFile = args[0];
var devMode = args[1];
var parseString = require("plist").parseString;
function parseLanguage(languageXml, callback) {
parseString(languageXml, function(_, language) {
callback(language[0])
});
}
function logDebug(string, obj) { function logDebug(string, obj) {
console.log(string, obj); console.log(string, obj);
} }
String.prototype.splice = function( idx, rem, s ) {
return (this.slice(0,idx) + s + this.slice(idx + Math.abs(rem)));
};
String.prototype.replaceAt = function (index, char) { // tmLanguage processor
return this.substr(0, index) + char + this.substr(index + 1);
// for tracking token states
var states = {start: []};
var stateName = "start";
function processRules(rules){
if (rules.patterns)
states.start = processPatterns(rules.patterns);
if (rules.repository)
processRepository(rules.repository);
return states;
}
function processRepository(r) {
for (var key in r) {
var p = r[key];
if (p.begin)
var stateObj = [processPattern(r[key])];
else if (p.patterns && !p.repository)
var stateObj = processPatterns(p.patterns);
else
var stateObj = [processPattern(r[key])];
if (stateObj)
states["#" + key] = stateObj;
}
}
function processPatterns(pl) {
return pl.map(processPattern);
}
function processPattern(p) {
if (p.end == "(?!\\G)" && p.patterns && p.patterns.length == 1) {
var rule = processPattern(p.patterns[0]);
}
else if (p.begin && p.end) {
var rule = simpleRule(p.begin, p.name, p.beginCaptures || p.captures)
var next = processPatterns(p.patterns || []);
var endRule = simpleRule(p.end, p.name, p.endCaptures || p.captures);
endRule.next = "pop";
next.push(endRule);
if (p.name || p.contentName)
next.push({defaultToken: p.name || p.contentName});
rule.push = next;
}
else if (p.match) {
var rule = simpleRule(p.match, p.name, p.captures)
}
else if (p.include) {
var rule = {include: p.include};
} }
function keyCount(obj) { if (p.comment)
return Object.keys(obj).length; rule.comment = (rule.comment || "") + p.comment;
if (p.repository)
processRepository(p.repository);
return rule;
} }
function simpleRule(regex, name, captures) {
name = name || "text";
var rule = {};
/** regex = transformRegExp(regex, rule);
if (captures) {
Scrubbing is sometimes necessary, but there appears to be no var tokenArray = [];
automated way to do it... Object.keys(captures).forEach(function(x){
tokenArray[x] = captures[x] && captures[x].name;
});
function cleanSingleCapture(match) { if (tokenArray.length == 1) {
// if there's a single "( )", screw that and make it "(?: )" name = tokenArray[0];
return match.replace("(", "(?:"); } else {
} for (var i = 0; i < tokenArray.length; i++)
if (!tokenArray[i])
function cleanMultiCapture(match) { tokenArray[i] = name;
// regexp will be a quoted string, so turn "\" into "\\" name = tokenArray;
var spaceFinderRegExp = new RegExp("\\\\s.| .", "g"); rule.todo = "fix grouping";
var m;
/*
essentially turns things like
\\s*(mixin) ([\\w\\-]+)\\s*(\\()
into
(\\s*mixin)( [\\w\\-]+)(\\s*\\()
so that mode parser stops complaining
while ((m = spaceFinderRegExp.exec(match)) != null) {
var idx = m.index;
var nextParenIdx = match.indexOf("(", idx);
if (nextParenIdx > idx) {
match = match.splice(idx, 0, "(").replaceAt(nextParenIdx + 1, '');
} }
} }
//console.log("match", match); try {new RegExp(regex);} catch(e) {
return match; rule.TODO = "FIXME: regexp doesn't have js equivalent";
} }
*/ rule.token = name;
rule.regex = regex;
// stupid yet necessary function, to transform JSON id comments into real comments return rule;
function restoreComments(objStr) {
return objStr.replace(/"\s+(\/\/.+)",/g, "\$1").replace(/ \/\/ ERROR/g, '", // ERROR');
} }
function checkForLookBehind(str) {
var lookbehindRegExp = new RegExp("\\?<[=|!]", "g"); // regex transformation
return lookbehindRegExp.test(str) ? str + " // ERROR: This contains a lookbehind, which JS does not support :(" : str;
}
function removeXFlag(str) { function removeXFlag(str) {
if (str.slice(0,4) == "(?x)") { if (str && str.slice(0,4) == "(?x)") {
str = str.replace(/\\.|\[([^\]\\]|\\.)*?\]|\s+|(?:#[^\n]*)/g, function(s) { str = str.replace(/\\.|\[([^\]\\]|\\.)*?\]|\s+|(?:#[^\n]*)/g, function(s) {
if (s[0] == "[") if (s[0] == "[")
return s; return s;
@ -95,149 +116,31 @@ function removeXFlag(str) {
return str; return str;
} }
function transformRegExp(str) { function transformRegExp(str, rule) {
str = removeXFlag(str); str = removeXFlag(str);
str = checkForLookBehind(str); str = str.replace(/\\n(?!\?).?/g, '$'); // replace newlines by $ except if its postfixed by ?
if (/\(\?[i]\:/g.test(str)) {
str = str.replace(/\(\?[ims\-]\:/g, "(?:"); // checkForInvariantRegex
rule && (rule.caseInsensitive = true);
}
return str; return str;
} }
function assembleStateObjs(strState, pattern) { //
var patterns = pattern.patterns; function extractPatterns(tmRules) {
var stateObj = {}; var patterns = processRules(tmRules);
var tokenElem = []; return lib.restoreJSONComments(lib.formatJSON(patterns, " "));
if (patterns) {
for (var p in patterns) {
stateObj = {}; // this is apparently necessary
if (patterns[p].include) {
stateObj.include = patterns[p].include;
}
else {
stateObj.token = patterns[p].name;
stateObj.regex = transformRegExp(patterns[p].match);
}
statesObj[strState].push(stateObj);
} }
stateObj = {};
stateObj.token = "TODO";
stateObj.regex = transformRegExp(pattern.end);
stateObj.next = "start";
}
else {
stateObj.token = "TODO";
stateObj.regex = transformRegExp(pattern.end);
stateObj.next = "start";
statesObj[strState].push(stateObj);
stateObj = {};
stateObj.token = "TODO";
stateObj.regex = ".+";
stateObj.next = strState;
}
return stateObj;
}
function extractPatterns(patterns) {
var state = 0;
patterns.forEach(function(pattern) {
state++;
var i = 1;
var tokenArray = [];
var tokenObj = { token: [] };
var stateObj = {};
if (pattern.comment) {
startState.start.push(" // " + pattern.comment.trim());
}
// it needs a state transition
if (pattern.begin && pattern.end) {
var strState = "state_" + state;
if ( pattern.beginCaptures === undefined && pattern.endCaptures === undefined) {
tokenObj.token.push(pattern.captures);
}
else if (pattern.beginCaptures) {
tokenObj.token.push(pattern.beginCaptures);
}
else if (pattern.endCaptures) {
tokenObj.token.push(pattern.endCaptures);
}
if (tokenObj.token === undefined) {
if (pattern.name)
tokenObj.token.push(pattern.name);
else
logDebug("There's no token name for this state transition", pattern)
}
if (tokenObj.token === undefined) {
tokenObj.token.push(pattern.name);
}
statesObj[strState] = [ ];
statesObj[strState].push(assembleStateObjs(strState, pattern));
tokenObj.regex = transformRegExp(pattern.begin);
tokenObj.next = strState;
}
else if( ( pattern.begin || pattern.end ) && !( pattern.begin && pattern.end ) ) {
logDebug("Somehow, there's pattern.begin or pattern.end--but not both?", pattern);
}
else if (pattern.captures) {
tokenObj.token.push([]);
tokenObj.token.push(pattern.captures);
tokenObj.regex = transformRegExp(pattern.match);
}
else if (pattern.match) {
tokenObj.token.push(pattern.name);
tokenObj.regex = transformRegExp(pattern.match);
}
else if (pattern.include) {
tokenObj.token.push(pattern.include);
tokenObj.regex = "";
}
else {
tokenObj.token.push("");
tokenObj.regex = "";
logDebug("I've gone through every choice, and have no clue what this is:", pattern);
}
// sometimes captures have names--not sure when or why
if (pattern.name) {
tokenObj.token.push(pattern.name);
}
startState.start.push(tokenObj);
});
var resultingObj = startState;
for (var state in statesObj) {
resultingObj[state] = statesObj[state];
}
return restoreComments(JSON.stringify(resultingObj, null, " "));
}
function fillTemplate(template, replacements) {
return template.replace(/%(.+?)%/g, function(str, m) {
return replacements[m] || "";
});
}
// cli stuff
var modeTemplate = fs.readFileSync(__dirname + "/mode.tmpl.js", "utf8"); var modeTemplate = fs.readFileSync(__dirname + "/mode.tmpl.js", "utf8");
var modeHighlightTemplate = fs.readFileSync(__dirname + "/mode_highlight_rules.tmpl.js", "utf8"); var modeHighlightTemplate = fs.readFileSync(__dirname + "/mode_highlight_rules.tmpl.js", "utf8");
function convertLanguage(name) { function convertLanguageFile(name) {
var tmLanguage = fs.readFileSync(__dirname + "/" + name, "utf8"); var tmLanguage = fs.readFileSync(process.cwd() + "/" + name, "utf8");
parseLanguage(tmLanguage, function(language) { parseLanguage(tmLanguage, function(language) {
var languageHighlightFilename = language.name.replace(/[-_]/g, "").toLowerCase(); var languageHighlightFilename = language.name.replace(/[-_]/g, "").toLowerCase();
var languageNameSanitized = language.name.replace(/-/g, ""); var languageNameSanitized = language.name.replace(/-/g, "");
@ -252,32 +155,23 @@ function convertLanguage(name) {
console.log(util.inspect(language.repository, false, 4)); console.log(util.inspect(language.repository, false, 4));
} }
var languageMode = fillTemplate(modeTemplate, { var languageMode = lib.fillTemplate(modeTemplate, {
language: languageNameSanitized, language: languageNameSanitized,
languageHighlightFilename: languageHighlightFilename languageHighlightFilename: languageHighlightFilename
}); });
var patterns = extractPatterns(language.patterns); var patterns = extractPatterns(language);
var repository = {};
if (language.repository) { var languageHighlightRules = lib.fillTemplate(modeHighlightTemplate, {
for (var r in language.repository) {
repository[r] = language.repository[r];
}
repository = restoreComments(JSON.stringify(repository, null, " "));
}
var languageHighlightRules = fillTemplate(modeHighlightTemplate, {
language: languageNameSanitized, language: languageNameSanitized,
languageTokens: patterns, languageTokens: patterns.trim(),
repositoryRules: "/*** START REPOSITORY RULES\n" + repository + "\nEND REPOSITORY RULES ***/",
uuid: language.uuid, uuid: language.uuid,
name: name name: name
}); });
if (devMode) { if (devMode) {
console.log(languageMode) console.log(languageMode);
console.log(languageHighlightRules) console.log(languageHighlightRules);
console.log("Not writing, 'cause we're in dev mode, baby."); console.log("Not writing, 'cause we're in dev mode, baby.");
} }
else { else {
@ -287,8 +181,11 @@ function convertLanguage(name) {
}); });
} }
var args = process.argv.splice(2);
var tmLanguageFile = args[0];
var devMode = args[1];
if (tmLanguageFile === undefined) { if (tmLanguageFile === undefined) {
console.error("Please pass in a language file via the command line."); console.error("Please pass in a language file via the command line.");
process.exit(1); process.exit(1);
} }
convertLanguage(tmLanguageFile); convertLanguageFile(tmLanguageFile);