use lower case file names and use define(function(require, exports, module) {})

This commit is contained in:
Fabian Jakobs 2010-11-05 09:45:01 +01:00
commit e377e03a82
45 changed files with 200 additions and 199 deletions

View file

@ -0,0 +1,143 @@
/**
* Ajax.org Code Editor (ACE)
*
* @copyright 2010, Ajax.org Services B.V.
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
* @author Fabian Jakobs <fabian AT ajax DOT org>
*/
define(function(require, exports, module) {
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules");
var TextHighlightRules = require("./text_highlight_rules");
JavaScriptHighlightRules = function() {
var docComment = new DocCommentHighlightRules();
var keywords = lang.arrayToMap(
("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
"if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|")
);
var buildinConstants = lang.arrayToMap(
("true|false|null|undefined|Infinity|NaN|undefined").split("|")
);
// ES3 future reserved
var futureReserved = lang.arrayToMap(
("abstract|boolean|byte|char|class|const|enum|export|extends|final|" +
"float|goto|implements|int|interface|long|native|package|private|" +
"protected|short|static|super|synchronized|throws|transient|volatile" +
"double|import|public").split("|")
);
// ES5 future reserved
// var futureReserved = lang.arrayToMap(
// ("class|enum|extends|super|const|export|import|implements|let|private|" +
// "public|yield|interface|package|protected|static").split("|")
// );
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [ {
token : "comment",
regex : "\\/\\/.*$"
},
docComment.getStartRule("doc-start"),
{
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).,;]|$)"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // multi line string start
regex : '["].*\\\\$',
next : "qqstring"
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "string", // multi line string start
regex : "['].*\\\\$",
next : "qstring"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : function(value) {
if (value == "this")
return "variable.language";
else if (keywords[value])
return "keyword";
else if (buildinConstants[value])
return "constant.language";
else if (futureReserved[value])
return "invalid.illegal";
else if (value == "debugger")
return "invalid.deprecated";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
regex : "[\\[\\(\\{]"
}, {
token : "rparen",
regex : "[\\]\\)\\}]"
}, {
token : "text",
regex : "\\s+"
} ],
"comment" : [ {
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
regex : ".+"
} ],
"qqstring" : [ {
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
next : "start"
}, {
token : "string",
regex : '.+'
} ],
"qstring" : [ {
token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
next : "start"
}, {
token : "string",
regex : '.+'
} ]
};
this.addRules(docComment.getRules(), "doc-");
this.$rules["doc-start"][0].next = "start";
};
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
return JavaScriptHighlightRules;
});