diff --git a/build/demo/kitchen-sink/kitchen-sink-uncompressed.js b/build/demo/kitchen-sink/kitchen-sink-uncompressed.js
index bb632b2d..88a72799 100644
--- a/build/demo/kitchen-sink/kitchen-sink-uncompressed.js
+++ b/build/demo/kitchen-sink/kitchen-sink-uncompressed.js
@@ -244,7 +244,7 @@ exportAce(ACE_NAMESPACE);
* ***** END LICENSE BLOCK ***** */
-define('kitchen-sink/demo', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/config', 'ace/lib/event', 'ace/theme/textmate', 'ace/edit_session', 'ace/undomanager', 'ace/keyboard/keybinding/vim', 'ace/keyboard/keybinding/emacs', 'ace/keyboard/hash_handler', 'text!kitchen-sink/docs/plaintext.txt', 'text!kitchen-sink/docs/javascript.js', 'text!kitchen-sink/docs/coffeescript.coffee', 'text!kitchen-sink/docs/json.json', 'text!kitchen-sink/docs/css.css', 'text!kitchen-sink/docs/scss.scss', 'text!kitchen-sink/docs/html.html', 'text!kitchen-sink/docs/xml.xml', 'text!kitchen-sink/docs/svg.svg', 'text!kitchen-sink/docs/php.php', 'text!kitchen-sink/docs/coldfusion.cfm', 'text!kitchen-sink/docs/python.py', 'text!kitchen-sink/docs/ruby.rb', 'text!kitchen-sink/docs/perl.pl', 'text!kitchen-sink/docs/ocaml.ml', 'text!kitchen-sink/docs/lua.lua', 'text!kitchen-sink/docs/java.java', 'text!kitchen-sink/docs/clojure.clj', 'text!kitchen-sink/docs/groovy.groovy', 'text!kitchen-sink/docs/scala.scala', 'text!kitchen-sink/docs/csharp.cs', 'text!kitchen-sink/docs/powershell.ps1', 'text!kitchen-sink/docs/cpp.cpp', 'text!kitchen-sink/docs/Haxe.hx', 'text!kitchen-sink/docs/sh.sh', 'text!kitchen-sink/docs/xquery.xq', 'text!kitchen-sink/docs/markdown.md', 'text!kitchen-sink/docs/textile.textile', 'text!kitchen-sink/docs/latex.tex', 'text!kitchen-sink/docs/sql.sql', 'text!kitchen-sink/docs/pgsql.pgsql', 'ace/split'], function(require, exports, module) {
+define('kitchen-sink/demo', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/config', 'ace/lib/event', 'ace/theme/textmate', 'ace/edit_session', 'ace/undomanager', 'ace/keyboard/keybinding/vim', 'ace/keyboard/keybinding/emacs', 'ace/keyboard/hash_handler', 'text!kitchen-sink/docs/plaintext.txt', 'text!kitchen-sink/docs/javascript.js', 'text!kitchen-sink/docs/coffeescript.coffee', 'text!kitchen-sink/docs/json.json', 'text!kitchen-sink/docs/css.css', 'text!kitchen-sink/docs/scss.scss', 'text!kitchen-sink/docs/html.html', 'text!kitchen-sink/docs/xml.xml', 'text!kitchen-sink/docs/svg.svg', 'text!kitchen-sink/docs/php.php', 'text!kitchen-sink/docs/coldfusion.cfm', 'text!kitchen-sink/docs/python.py', 'text!kitchen-sink/docs/ruby.rb', 'text!kitchen-sink/docs/perl.pl', 'text!kitchen-sink/docs/ocaml.ml', 'text!kitchen-sink/docs/lua.lua', 'text!kitchen-sink/docs/liquid.liquid', 'text!kitchen-sink/docs/java.java', 'text!kitchen-sink/docs/clojure.clj', 'text!kitchen-sink/docs/groovy.groovy', 'text!kitchen-sink/docs/scala.scala', 'text!kitchen-sink/docs/csharp.cs', 'text!kitchen-sink/docs/powershell.ps1', 'text!kitchen-sink/docs/cpp.cpp', 'text!kitchen-sink/docs/Haxe.hx', 'text!kitchen-sink/docs/sh.sh', 'text!kitchen-sink/docs/xquery.xq', 'text!kitchen-sink/docs/markdown.md', 'text!kitchen-sink/docs/textile.textile', 'text!kitchen-sink/docs/latex.tex', 'text!kitchen-sink/docs/sql.sql', 'text!kitchen-sink/docs/pgsql.pgsql', 'ace/split'], function(require, exports, module) {
require("ace/lib/fixoldbrowsers");
require("ace/config").init();
@@ -266,7 +266,6 @@ var Doc = function(name, desc, file) {
this.name = name;
this.desc = desc;
this.doc = new EditSession(file);
- this.doc.setMode(modesByName[name].mode);
this.doc.modeName = name;
this.doc.setUndoManager(new UndoManager());
};
@@ -304,6 +303,7 @@ var modes = [
new Mode("json", "JSON", ["json"]),
new Mode("latex", "LaTeX", ["tex"]),
new Mode("lua", "Lua", ["lua"]),
+ new Mode("liquid", "Liquid", ["liquid"]),
new Mode("markdown", "Markdown", ["md", "markdown"]),
new Mode("ocaml", "OCaml", ["ml", "mli"]),
new Mode("perl", "Perl", ["pl", "pm"]),
@@ -395,6 +395,10 @@ var docs = [
"lua", "Lua",
require("text!./docs/lua.lua")
),
+ new Doc(
+ "liquid", "Liquid",
+ require("text!./docs/liquid.liquid")
+ ),
new Doc(
"java", "Java",
require("text!./docs/java.java")
@@ -522,6 +526,12 @@ modes.forEach(function(mode) {
bindDropdown("doc", function(value) {
var doc = docsByName[value].doc;
+
+ if (!docsByName[value].initialized) {
+ docsByName[value].initialized = true;
+ doc.setMode(modesByName[docsByName[value].name].mode);
+ }
+
var session = env.split.setSession(doc);
session.name = doc.name;
@@ -3858,6 +3868,10 @@ var EditSession = function(text, mode) {
return callback(_self.$modes[mode]);
_self.$modes[mode] = new module.Mode();
+ _self._emit("loadmode", {
+ name: mode,
+ mode: _self.$modes[mode]
+ });
callback(_self.$modes[mode]);
}
@@ -6403,12 +6417,15 @@ var Tokenizer = function(rules, flag) {
// Count number of matching groups. 2 extra groups from the full match
// And the catch-all on the end (used to force a match);
var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
-
+
// Replace any backreferences and offset appropriately.
var adjustedregex = state[i].regex.replace(/\\([0-9]+)/g, function (match, digit) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
});
+ if (matchcount > 1 && state[i].token.length !== matchcount-1)
+ throw new Error("Matching groups and length of the token array don't match");
+
mapping[matchTotal] = {
rule: i,
len: matchcount
@@ -6446,45 +6463,47 @@ var Tokenizer = function(rules, flag) {
var value = [match[0]];
for (var i = 0; i < match.length-2; i++) {
- if (match[i + 1] !== undefined) {
- rule = state[mapping[i].rule];
+ if (match[i + 1] === undefined)
+ continue;
- if (mapping[i].len > 1) {
- value = match.slice(i+2, i+1+mapping[i].len);
- }
-
- // compute token type
- if (typeof rule.token == "function")
- type = rule.token.apply(this, value);
- else
- type = rule.token;
+ rule = state[mapping[i].rule];
+
+ if (mapping[i].len > 1)
+ value = match.slice(i+2, i+1+mapping[i].len);
+
+ // compute token type
+ if (typeof rule.token == "function")
+ type = rule.token.apply(this, value);
+ else
+ type = rule.token;
- var next = rule.next;
- if (next && next !== currentState) {
- currentState = next;
- state = this.rules[currentState];
- mapping = this.matchMappings[currentState];
- lastIndex = re.lastIndex;
+ var next = rule.next;
+ if (next && next !== currentState) {
+ currentState = next;
+ state = this.rules[currentState];
+ mapping = this.matchMappings[currentState];
+ lastIndex = re.lastIndex;
- re = this.regExps[currentState];
- re.lastIndex = lastIndex;
- }
- break;
+ re = this.regExps[currentState];
+ re.lastIndex = lastIndex;
}
+ break;
}
-
+
if (value[0]) {
if (typeof type == "string") {
value = [value.join("")];
type = [type];
}
for (var i = 0; i < value.length; i++) {
+ if (!value[i])
+ continue;
+
if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
token.value += value[i];
} else {
- if (token.type) {
+ if (token.type)
tokens.push(token);
- }
token = {
type: type[i],
@@ -10263,6 +10282,84 @@ define("text!kitchen-sink/docs/lua.lua", [], "--[[--\n" +
"print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2\n" +
"");
+define("text!kitchen-sink/docs/liquid.liquid", [], "The following examples can be found in full at http://liquidmarkup.org/\n" +
+ "\n" +
+ "Liquid is an extraction from the e-commerce system Shopify.\n" +
+ "Shopify powers many thousands of e-commerce stores which all call for unique designs.\n" +
+ "For this we developed Liquid which allows our customers complete design freedom while\n" +
+ "maintaining the integrity of our servers.\n" +
+ "\n" +
+ "Liquid has been in production use since June 2006 and is now used by many other\n" +
+ "hosted web applications.\n" +
+ "\n" +
+ "It was developed for usage in Ruby on Rails web applications and integrates seamlessly\n" +
+ "as a plugin but it also works excellently as a stand alone library.\n" +
+ "\n" +
+ "Here's what it looks like:\n" +
+ "\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "Some more features include:\n" +
+ "\n" +
+ "Filters
\n" +
+ " The word \"tobi\" in uppercase: {{ 'tobi' | upcase }}
\n" +
+ "The word \"tobi\" has {{ 'tobi' | size }} letters!
\n" +
+ "Change \"Hello world\" to \"Hi world\": {{ 'Hello world' | replace: 'Hello', 'Hi' }}
\n" +
+ "The date today is {{ 'now' | date: \"%Y %b %d\" }}
\n" +
+ "\n" +
+ "\n" +
+ "If
\n" +
+ "\n" +
+ " {% if user.name == 'tobi' or user.name == 'marc' %} \n" +
+ " hi marc or tobi\n" +
+ " {% endif %}\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "Case
\n" +
+ "\n" +
+ " {% case template %}\n" +
+ " {% when 'index' %}\n" +
+ " Welcome\n" +
+ " {% when 'product' %}\n" +
+ " {{ product.vendor | link_to_vendor }} / {{ product.title }}\n" +
+ " {% else %}\n" +
+ " {{ page_title }}\n" +
+ " {% endcase %}\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "For Loops
\n" +
+ "\n" +
+ " {% for item in array %} \n" +
+ " {{ item }}\n" +
+ " {% endfor %}\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "Tables
\n" +
+ "\n" +
+ " {% tablerow item in items cols: 3 %}\n" +
+ " {% if tablerowloop.col_first %}\n" +
+ " First column: {{ item.variable }}\n" +
+ " {% else %}\n" +
+ " Different column: {{ item.variable }}\n" +
+ " {% endif %}\n" +
+ " {% endtablerow %}\n" +
+ "
\n" +
+ "");
+
define("text!kitchen-sink/docs/java.java", [], "public class InfiniteLoop {\n" +
"\n" +
" /*\n" +
@@ -11480,7 +11577,7 @@ var Editor = function(renderer, session) {
this.onScrollLeftChange = function() {
this.renderer.scrollToX(this.session.getScrollLeft());
};
-
+
this.onCursorChange = function() {
this.renderer.updateCursor();
@@ -12398,8 +12495,7 @@ var Editor = function(renderer, session) {
exports.Editor = Editor;
-});
-/* vim:ts=4:sts=4:sw=4:
+});/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
diff --git a/build/demo/kitchen-sink/mode-coldfusion-uncompressed.js b/build/demo/kitchen-sink/mode-coldfusion-uncompressed.js
index d1232f1d..5df21960 100644
--- a/build/demo/kitchen-sink/mode-coldfusion-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-coldfusion-uncompressed.js
@@ -1373,25 +1373,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -1407,7 +1478,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-groovy-uncompressed.js b/build/demo/kitchen-sink/mode-groovy-uncompressed.js
index 10f64e0d..25666f0d 100644
--- a/build/demo/kitchen-sink/mode-groovy-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-groovy-uncompressed.js
@@ -325,25 +325,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -359,7 +430,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-html-uncompressed.js b/build/demo/kitchen-sink/mode-html-uncompressed.js
index 6e2f9c93..bf9f2791 100644
--- a/build/demo/kitchen-sink/mode-html-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-html-uncompressed.js
@@ -384,25 +384,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -418,7 +489,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-java-uncompressed.js b/build/demo/kitchen-sink/mode-java-uncompressed.js
index a296fa34..1318404a 100644
--- a/build/demo/kitchen-sink/mode-java-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-java-uncompressed.js
@@ -326,25 +326,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -360,7 +431,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-javascript-uncompressed.js b/build/demo/kitchen-sink/mode-javascript-uncompressed.js
index 53dd30f0..17e5373c 100644
--- a/build/demo/kitchen-sink/mode-javascript-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-javascript-uncompressed.js
@@ -301,25 +301,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -335,7 +406,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-liquid-uncompressed.js b/build/demo/kitchen-sink/mode-liquid-uncompressed.js
new file mode 100644
index 00000000..630fc5de
--- /dev/null
+++ b/build/demo/kitchen-sink/mode-liquid-uncompressed.js
@@ -0,0 +1,1369 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/liquid', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/liquid_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) {
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var LiquidHighlightRules = require("./liquid_highlight_rules").LiquidHighlightRules;
+var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
+var Range = require("../range").Range;
+
+var Mode = function() {
+ this.$tokenizer = new Tokenizer(new LiquidHighlightRules().getRules());
+ this.$outdent = new MatchingBraceOutdent();
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+ this.toggleCommentLines = function(state, doc, startRow, endRow) {
+ var outdent = true;
+ var outentedRows = [];
+ var re = /^(\s*)#/;
+
+ for (var i=startRow; i<= endRow; i++) {
+ if (!re.test(doc.getLine(i))) {
+ outdent = false;
+ break;
+ }
+ }
+
+ if (outdent) {
+ var deleteRange = new Range(0, 0, 0, 0);
+ for (var i=startRow; i<= endRow; i++)
+ {
+ var line = doc.getLine(i);
+ var m = line.match(re);
+ deleteRange.start.row = i;
+ deleteRange.end.row = i;
+ deleteRange.end.column = m[0].length;
+ doc.replace(deleteRange, m[1]);
+ }
+ }
+ else {
+ doc.indentRows(startRow, endRow, "#");
+ }
+ };
+
+ this.getNextLineIndent = function(state, line, tab) {
+ var indent = this.$getIndent(line);
+
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
+ var tokens = tokenizedLine.tokens;
+ var endState = tokenizedLine.state;
+
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
+ return indent;
+ }
+
+ if (state == "start") {
+ var match = line.match(/^.*[\{\(\[]\s*$/);
+ if (match) {
+ indent += tab;
+ }
+ }
+
+ return indent;
+ };
+
+ this.checkOutdent = function(state, line, input) {
+ return this.$outdent.checkOutdent(line, input);
+ };
+
+ this.autoOutdent = function(state, doc, row) {
+ this.$outdent.autoOutdent(doc, row);
+ };
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ * Mihai Sucan
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/liquid_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/lib/lang', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+
+var oop = require("../lib/oop");
+var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
+var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
+var lang = require("../lib/lang");
+var xmlUtil = require("./xml_util");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var LiquidHighlightRules = function() {
+
+ // see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects
+ var functions = lang.arrayToMap(
+ // Standard Filters
+ ("date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|" +
+ "escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|" +
+ "truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split"
+ ).split("|")
+ );
+
+ var keywords = lang.arrayToMap(
+ // Standard Tags
+ ("capture|endcapture|case|endcase|when|comment|endcomment|" +
+ "cycle|for|endfor|in|reversed|if|endif|else|elsif|include|endinclude|unless|endunless|" +
+ // Commonly used tags
+ "style|text|image|widget|plugin|marker|endmarker|tablerow|endtablerow").split("|")
+ );
+
+ var builtinVariables = lang.arrayToMap(
+ ['forloop']
+ // ("forloop\\.(length|index|index0|rindex|rindex0|first|last)|limit|offset|range" +
+ // "tablerowloop\\.(length|index|index0|rindex|rindex0|first|last|col|col0|"+
+ // "col_first|col_last)").split("|")
+ );
+
+ var definitions = lang.arrayToMap(("assign").split("|"));
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+
+ this.$rules = {
+ start : [{
+ token : "variable",
+ regex : "{%",
+ next : "liquid_start"
+ }, {
+ token : "variable",
+ regex : "{{",
+ next : "liquid_start"
+ }, {
+ token : "meta.tag",
+ merge : true,
+ regex : "<\\!\\[CDATA\\[",
+ next : "cdata"
+ }, {
+ token : "xml_pe",
+ regex : "<\\?.*?\\?>"
+ }, {
+ token : "comment",
+ merge : true,
+ regex : "<\\!--",
+ next : "comment"
+ }, {
+ token : "meta.tag",
+ regex : "<(?=\s*script\\b)",
+ next : "script"
+ }, {
+ token : "meta.tag",
+ regex : "<(?=\s*style\\b)",
+ next : "style"
+ }, {
+ token : "meta.tag", // opening tag
+ regex : "<\\/?",
+ next : "tag"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, {
+ token : "text",
+ regex : "[^<]+"
+ } ],
+
+ cdata : [ {
+ token : "text",
+ regex : "\\]\\]>",
+ next : "start"
+ }, {
+ token : "text",
+ merge : true,
+ regex : "\\s+"
+ }, {
+ token : "text",
+ merge : true,
+ regex : ".+"
+ } ],
+
+ comment : [ {
+ token : "comment",
+ regex : ".*?-->",
+ next : "start"
+ }, {
+ token : "comment",
+ merge : true,
+ regex : ".+"
+ } ] ,
+
+ liquid_start : [{
+ token: "variable",
+ regex: "}}",
+ next: "start"
+ }, {
+ token: "variable",
+ regex: "%}",
+ next: "start"
+ }, {
+ token : "string", // single line
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ }, {
+ token : "string", // single line
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
+ }, {
+ token : "constant.numeric", // hex
+ regex : "0[xX][0-9a-fA-F]+\\b"
+ }, {
+ token : "constant.numeric", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, {
+ token : "constant.language.boolean",
+ regex : "(?:true|false)\\b"
+ }, {
+ token : function(value) {
+ if (functions.hasOwnProperty(value))
+ return "support.function";
+ else if (keywords.hasOwnProperty(value))
+ return "keyword";
+ else if (builtinVariables.hasOwnProperty(value))
+ return "variable.language";
+ else if (definitions.hasOwnProperty(value))
+ return "keyword.definition";
+ else
+ return "identifier";
+ },
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
+ }, {
+ token : "keyword.operator",
+ regex : "\/|\\*|\\-|\\+|=|!=|\\?\\:"
+ }, {
+ token : "paren.lparen",
+ regex : "[[({]"
+ }, {
+ token : "paren.rparen",
+ regex : "[\\])}]"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, ]
+ };
+
+ xmlUtil.tag(this.$rules, "tag", "start");
+ xmlUtil.tag(this.$rules, "style", "css-start");
+ xmlUtil.tag(this.$rules, "script", "js-start");
+
+ this.embedRules(JavaScriptHighlightRules, "js-", [{
+ token: "comment",
+ regex: "\\/\\/.*(?=<\\/script>)",
+ next: "tag"
+ }, {
+ token: "meta.tag",
+ regex: "<\\/(?=script)",
+ next: "tag"
+ }]);
+
+ this.embedRules(CssHighlightRules, "css-", [{
+ token: "meta.tag",
+ regex: "<\\/(?=style)",
+ next: "tag"
+ }]);
+};
+oop.inherits(LiquidHighlightRules, TextHighlightRules);
+
+exports.LiquidHighlightRules = LiquidHighlightRules;
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var lang = require("../lib/lang");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var CssHighlightRules = function() {
+
+ var properties = lang.arrayToMap(
+ ("-moz-appearance|-moz-box-sizing|-webkit-box-sizing|-moz-outline-radius|-moz-transform|-webkit-transform|" +
+ "appearance|azimuth|background-attachment|background-color|background-image|" +
+ "background-origin|background-position|background-repeat|background|border-bottom-color|" +
+ "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
+ "border-color|border-left-color|border-left-style|border-left-width|" +
+ "border-left|border-right-color|border-right-style|border-right-width|" +
+ "border-right|border-spacing|border-style|border-top-color|" +
+ "border-top-style|border-top-width|border-top|border-width|border|" +
+ "bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" +
+ "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
+ "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
+ "font-stretch|font-style|font-variant|font-weight|font|height|left|" +
+ "letter-spacing|line-height|list-style-image|list-style-position|" +
+ "list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
+ "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
+ "min-width|-moz-border-radius|opacity|orphans|outline-color|outline-offset|outline-radius|" +
+ "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
+ "padding-left|padding-right|padding-top|padding|page-break-after|" +
+ "page-break-before|page-break-inside|page|pause-after|pause-before|" +
+ "pause|pitch-range|pitch|play-during|pointer-events|position|quotes|resize|richness|right|" +
+ "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
+ "stress|table-layout|text-align|text-decoration|text-indent|" +
+ "text-shadow|text-transform|top|transform|unicode-bidi|vertical-align|" +
+ "visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
+ "z-index").split("|")
+ );
+
+ var functions = lang.arrayToMap(
+ ("rgb|rgba|url|attr|counter|counters").split("|")
+ );
+
+ var constants = lang.arrayToMap(
+ ("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
+ "block|bold|bolder|border-box|both|bottom|break-all|break-word|capitalize|center|" +
+ "char|circle|cjk-ideographic|col-resize|collapse|content-box|crosshair|dashed|" +
+ "decimal-leading-zero|decimal|default|disabled|disc|" +
+ "distribute-all-lines|distribute-letter|distribute-space|" +
+ "distribute|dotted|double|e-resize|ellipsis|fixed|georgian|groove|" +
+ "hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|" +
+ "ideograph-alpha|ideograph-numeric|ideograph-parenthesis|" +
+ "ideograph-space|inactive|inherit|inline-block|inline|inset|inside|" +
+ "inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|" +
+ "keep-all|left|lighter|line-edge|line-through|line|list-item|loose|" +
+ "lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|" +
+ "medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|" +
+ "nw-resize|none|normal|not-allowed|nowrap|oblique|outset|outside|" +
+ "overline|pointer|progress|relative|repeat-x|repeat-y|repeat|right|" +
+ "ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|" +
+ "solid|square|static|strict|super|sw-resize|table-footer-group|" +
+ "table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|" +
+ "transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|" +
+ "vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|" +
+ "zero").split("|")
+ );
+
+ var colors = lang.arrayToMap(
+ ("aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|" +
+ "purple|red|silver|teal|white|yellow").split("|")
+ );
+
+ var fonts = lang.arrayToMap(
+ ("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
+ "symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
+ "serif|monospace").split("|")
+ );
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+
+ var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
+
+ var base_ruleset = [
+ {
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "ruleset_comment"
+ },{
+ token : "string", // single line
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ }, {
+ token : "string", // single line
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
+ }, {
+ token : ["constant.numeric", "keyword"],
+ regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
+ }, {
+ token : ["constant.numeric"],
+ regex : "([0-9]+)"
+ }, {
+ token : "constant.numeric", // hex6 color
+ regex : "#[a-f0-9]{6}"
+ }, {
+ token : "constant.numeric", // hex3 color
+ regex : "#[a-f0-9]{3}"
+ }, {
+ token : function(value) {
+ if (properties.hasOwnProperty(value.toLowerCase())) {
+ return "support.type";
+ }
+ else if (functions.hasOwnProperty(value.toLowerCase())) {
+ return "support.function";
+ }
+ else if (constants.hasOwnProperty(value.toLowerCase())) {
+ return "support.constant";
+ }
+ else if (colors.hasOwnProperty(value.toLowerCase())) {
+ return "support.constant.color";
+ }
+ else if (fonts.hasOwnProperty(value.toLowerCase())) {
+ return "support.constant.fonts";
+ }
+ else {
+ return "text";
+ }
+ },
+ regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
+ }
+ ];
+
+ var ruleset = lang.copyArray(base_ruleset);
+ ruleset.unshift({
+ token : "paren.rparen",
+ regex : "\\}",
+ next: "start"
+ });
+
+ var media_ruleset = lang.copyArray( base_ruleset );
+ media_ruleset.unshift({
+ token : "paren.rparen",
+ regex : "\\}",
+ next: "media"
+ });
+
+ var base_comment = [{
+ token : "comment", // comment spanning whole line
+ merge : true,
+ regex : ".+"
+ }];
+
+ var comment = lang.copyArray(base_comment);
+ comment.unshift({
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ next : "start"
+ });
+
+ var media_comment = lang.copyArray(base_comment);
+ media_comment.unshift({
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ next : "media"
+ });
+
+ var ruleset_comment = lang.copyArray(base_comment);
+ ruleset_comment.unshift({
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ next : "ruleset"
+ });
+
+ this.$rules = {
+ "start" : [{
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "comment"
+ }, {
+ token: "paren.lparen",
+ regex: "\\{",
+ next: "ruleset"
+ }, {
+ token: "string",
+ regex: "@.*?{",
+ next: "media"
+ },{
+ token: "keyword",
+ regex: "#[a-z0-9-_]+"
+ },{
+ token: "variable",
+ regex: "\\.[a-z0-9-_]+"
+ },{
+ token: "string",
+ regex: ":[a-z0-9-_]+"
+ },{
+ token: "constant",
+ regex: "[a-z0-9-_]+"
+ }],
+
+ "media" : [ {
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "media_comment"
+ }, {
+ token: "paren.lparen",
+ regex: "\\{",
+ next: "media_ruleset"
+ },{
+ token: "string",
+ regex: "\\}",
+ next: "start"
+ },{
+ token: "keyword",
+ regex: "#[a-z0-9-_]+"
+ },{
+ token: "variable",
+ regex: "\\.[a-z0-9-_]+"
+ },{
+ token: "string",
+ regex: ":[a-z0-9-_]+"
+ },{
+ token: "constant",
+ regex: "[a-z0-9-_]+"
+ }],
+
+ "comment" : comment,
+
+ "ruleset" : ruleset,
+ "ruleset_comment" : ruleset_comment,
+
+ "media_ruleset" : media_ruleset,
+ "media_comment" : media_comment
+ };
+};
+
+oop.inherits(CssHighlightRules, TextHighlightRules);
+
+exports.CssHighlightRules = CssHighlightRules;
+
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ * Mihai Sucan
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var lang = require("../lib/lang");
+var unicode = require("../unicode");
+var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var JavaScriptHighlightRules = function() {
+
+ // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
+ var globals = lang.arrayToMap(
+ // Constructors
+ ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
+ // E4X
+ "Namespace|QName|XML|XMLList|" +
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
+ // Errors
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
+ "SyntaxError|TypeError|URIError|" +
+ // Non-constructor functions
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
+ "isNaN|parseFloat|parseInt|" +
+ // Other
+ "JSON|Math|" +
+ // Pseudo
+ "this|arguments|prototype|window|document"
+ ).split("|")
+ );
+
+ var keywords = lang.arrayToMap(
+ ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
+ "const|yield|import|get|set").split("|")
+ );
+
+ // keywords which can be followed by regular expressions
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
+
+ var deprecated = lang.arrayToMap(
+ ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
+ );
+
+ var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
+
+ var buildinConstants = lang.arrayToMap(
+ ("null|Infinity|NaN|undefined").split("|")
+ );
+
+ var futureReserved = lang.arrayToMap(
+ ("class|enum|extends|super|export|implements|private|" +
+ "public|interface|package|protected|static").split("|")
+ );
+
+ // TODO: Unicode escape sequences
+ var identifierRe = "[" + unicode.packages.L + "\\$_]["
+ + unicode.packages.L
+ + unicode.packages.Mn + unicode.packages.Mc
+ + unicode.packages.Nd
+ + unicode.packages.Pc + "\\$_]*\\b";
+
+ var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
+ "u[0-9a-fA-F]{4}|" + // unicode
+ "[0-2][0-7]{0,2}|" + // oct
+ "3[0-6][0-7]?|" + // oct
+ "37[0-7]?|" + // oct
+ "[4-7][0-7]?|" + //oct
+ ".)";
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+
+ this.$rules = {
+ "start" : [
+ {
+ token : "comment",
+ regex : "\\/\\/.*$"
+ },
+ new DocCommentHighlightRules().getStartRule("doc-start"),
+ {
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "comment"
+ }, {
+ token : "string",
+ regex : "'",
+ next : "qstring"
+ }, {
+ token : "string",
+ regex : '"',
+ next : "qqstring"
+ }, {
+ token : "constant.numeric", // hex
+ regex : "0[xX][0-9a-fA-F]+\\b"
+ }, {
+ token : "constant.numeric", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, { // match stuff like: Sound.prototype.play = function() { }
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
+ }, { // match stuff like: Sound.prototype.play = myfunc
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
+ }, { // match stuff like: Sound.play = function() { }
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
+ }, { // match stuff like: play = function() { }
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
+ }, { // match regular function like: function myFunc(arg) { }
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
+ }, { // match stuff like: foobar: function() { }
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
+ }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
+ }, {
+ token : "constant.language.boolean",
+ regex : "(?:true|false)\\b"
+ }, {
+ token : "keyword",
+ regex : "(?:" + kwBeforeRe + ")\\b",
+ next : "regex_allowed"
+ }, {
+ token : "support.function",
+ regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|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(?=\\()"
+ }, {
+ token : "support.function.dom",
+ regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
+ }, {
+ token : "support.constant",
+ regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
+ }, {
+ token : ["punctuation.operator", "support.function.firebug"],
+ regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b"
+
+ }, {
+ token : function(value) {
+ if (globals.hasOwnProperty(value))
+ return "variable.language";
+ else if (deprecated.hasOwnProperty(value))
+ return "invalid.deprecated";
+ else if (definitions.hasOwnProperty(value))
+ return "storage.type";
+ else if (keywords.hasOwnProperty(value))
+ return "keyword";
+ else if (buildinConstants.hasOwnProperty(value))
+ return "constant.language";
+ else if (futureReserved.hasOwnProperty(value))
+ return "invalid.illegal";
+ else if (value == "debugger")
+ return "invalid.deprecated";
+ else
+ return "identifier";
+ },
+ regex : identifierRe
+ }, {
+ token : "keyword.operator",
+ regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)",
+ next : "regex_allowed"
+ }, {
+ token : "punctuation.operator",
+ regex : "\\?|\\:|\\,|\\;|\\.",
+ next : "regex_allowed"
+ }, {
+ token : "paren.lparen",
+ regex : "[[({]",
+ next : "regex_allowed"
+ }, {
+ token : "paren.rparen",
+ regex : "[\\])}]"
+ }, {
+ token : "keyword.operator",
+ regex : "\\/=?",
+ next : "regex_allowed"
+ }, {
+ token: "comment",
+ regex: "^#!.*$"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }
+ ],
+ // regular expressions are only allowed after certain tokens. This
+ // makes sure we don't mix up regexps with the divison operator
+ "regex_allowed": [
+ {
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "comment_regex_allowed"
+ }, {
+ token : "comment",
+ regex : "\\/\\/.*$"
+ }, {
+ token: "string.regexp",
+ regex: "\\/",
+ next: "regex",
+ merge: true
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, {
+ // immediately return to the start mode without matching
+ // anything
+ token: "empty",
+ regex: "",
+ next: "start"
+ }
+ ],
+ "regex": [
+ {
+ token: "regexp.keyword.operator",
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
+ next: "regex"
+ }, {
+ // flag
+ token: "string.regexp",
+ regex: "/\\w*",
+ next: "start",
+ merge: true
+ }, {
+ token: "string.regexp",
+ regex: "[^\\\\/\\[]+",
+ next: "regex",
+ merge: true
+ }, {
+ token: "string.regexp.charachterclass",
+ regex: "\\[",
+ next: "regex_character_class",
+ merge: true
+ }, {
+ token: "empty",
+ regex: "",
+ next: "start"
+ }
+ ],
+ "regex_character_class": [
+ {
+ token: "regexp.keyword.operator",
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
+ next: "regex_character_class"
+ }, {
+ token: "string.regexp.charachterclass",
+ regex: "]",
+ next: "regex",
+ merge: true
+ }, {
+ token: "string.regexp.charachterclass",
+ regex: "[^\\\\\\]]+",
+ next: "regex_character_class",
+ merge: true
+ }, {
+ token: "empty",
+ regex: "",
+ next: "start"
+ }
+ ],
+ "comment_regex_allowed" : [
+ {
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ merge : true,
+ next : "regex_allowed"
+ }, {
+ token : "comment", // comment spanning whole line
+ merge : true,
+ regex : ".+"
+ }
+ ],
+ "comment" : [
+ {
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ merge : true,
+ next : "start"
+ }, {
+ token : "comment", // comment spanning whole line
+ merge : true,
+ regex : ".+"
+ }
+ ],
+ "qqstring" : [
+ {
+ token : "constant.language.escape",
+ regex : escapedRe
+ }, {
+ token : "string",
+ regex : '[^"\\\\]+'
+ }, {
+ token : "string",
+ regex : '"',
+ next : "start"
+ }
+ ],
+ "qstring" : [
+ {
+ token : "constant.language.escape",
+ regex : escapedRe
+ }, {
+ token : "string",
+ regex : "[^'\\\\]+"
+ }, {
+ token : "string",
+ regex : "'",
+ next : "start"
+ }
+ ]
+ };
+
+ this.embedRules(DocCommentHighlightRules, "doc-",
+ [ new DocCommentHighlightRules().getEndRule("start") ]);
+};
+
+oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
+
+exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var DocCommentHighlightRules = function() {
+
+ this.$rules = {
+ "start" : [ {
+ token : "comment.doc.tag",
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
+ }, {
+ token : "comment.doc",
+ merge : true,
+ regex : "\\s+"
+ }, {
+ token : "comment.doc",
+ merge : true,
+ regex : "TODO"
+ }, {
+ token : "comment.doc",
+ merge : true,
+ regex : "[^@\\*]+"
+ }, {
+ token : "comment.doc",
+ merge : true,
+ regex : "."
+ }]
+ };
+};
+
+oop.inherits(DocCommentHighlightRules, TextHighlightRules);
+
+(function() {
+
+ this.getStartRule = function(start) {
+ return {
+ token : "comment.doc", // doc comment
+ merge : true,
+ regex : "\\/\\*(?=\\*)",
+ next : start
+ };
+ };
+
+ this.getEndRule = function (start) {
+ return {
+ token : "comment.doc", // closing comment
+ merge : true,
+ regex : "\\*\\/",
+ next : start
+ };
+ };
+
+}).call(DocCommentHighlightRules.prototype);
+
+exports.DocCommentHighlightRules = DocCommentHighlightRules;
+
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/xml_util', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
+"use strict";
+
+var lang = require("../lib/lang");
+
+var formTags = lang.arrayToMap(
+ ("button|form|input|label|select|textarea").split("|")
+);
+
+var tableTags = lang.arrayToMap(
+ ("table|tbody|td|tfoot|th|tr").split("|")
+);
+
+function string(state) {
+ return [{
+ token : "string",
+ regex : '".*?"'
+ }, {
+ token : "string", // multi line string start
+ merge : true,
+ regex : '["].*',
+ next : state + "_qqstring"
+ }, {
+ token : "string",
+ regex : "'.*?'"
+ }, {
+ token : "string", // multi line string start
+ merge : true,
+ regex : "['].*",
+ next : state + "_qstring"
+ }];
+}
+
+function multiLineString(quote, state) {
+ return [{
+ token : "string",
+ merge : true,
+ regex : ".*?" + quote,
+ next : state
+ }, {
+ token : "string",
+ merge : true,
+ regex : '.+'
+ }];
+}
+
+exports.tag = function(states, name, nextState) {
+ states[name] = [{
+ token : "text",
+ regex : "\\s+"
+ }, {
+ //token : "meta.tag",
+
+ token : function(value) {
+ if ( value==='a' ) {
+ return "meta.tag.anchor";
+ }
+ else if ( value==='img' ) {
+ return "meta.tag.image";
+ }
+ else if ( value==='script' ) {
+ return "meta.tag.script";
+ }
+ else if ( value==='style' ) {
+ return "meta.tag.style";
+ }
+ else if (formTags.hasOwnProperty(value.toLowerCase())) {
+ return "meta.tag.form";
+ }
+ else if (tableTags.hasOwnProperty(value.toLowerCase())) {
+ return "meta.tag.table";
+ }
+ else {
+ return "meta.tag";
+ }
+ },
+ merge : true,
+ regex : "[-_a-zA-Z0-9:!]+",
+ next : name + "_embed_attribute_list"
+ }, {
+ token: "empty",
+ regex: "",
+ next : name + "_embed_attribute_list"
+ }];
+
+ states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
+ states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
+
+ states[name + "_embed_attribute_list"] = [{
+ token : "meta.tag",
+ merge : true,
+ regex : "\/?>",
+ next : nextState
+ }, {
+ token : "keyword.operator",
+ regex : "="
+ }, {
+ token : "entity.other.attribute-name",
+ regex : "[-_a-zA-Z0-9:]+"
+ }, {
+ token : "constant.numeric", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }].concat(string(name));
+};
+
+});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Ajax.org Code Editor (ACE).
+ *
+ * The Initial Developer of the Original Code is
+ * Ajax.org B.V.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Fabian Jakobs
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+"use strict";
+
+var Range = require("../range").Range;
+
+var MatchingBraceOutdent = function() {};
+
+(function() {
+
+ this.checkOutdent = function(line, input) {
+ if (! /^\s+$/.test(line))
+ return false;
+
+ return /^\s*\}/.test(input);
+ };
+
+ this.autoOutdent = function(doc, row) {
+ var line = doc.getLine(row);
+ var match = line.match(/^(\s*\})/);
+
+ if (!match) return 0;
+
+ var column = match[1].length;
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
+
+ if (!openBracePos || openBracePos.row == row) return 0;
+
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
+ doc.replace(new Range(row, 0, row, column-1), indent);
+ };
+
+ this.$getIndent = function(line) {
+ var match = line.match(/^(\s+)/);
+ if (match) {
+ return match[1];
+ }
+
+ return "";
+ };
+
+}).call(MatchingBraceOutdent.prototype);
+
+exports.MatchingBraceOutdent = MatchingBraceOutdent;
+});
diff --git a/build/demo/kitchen-sink/mode-markdown-uncompressed.js b/build/demo/kitchen-sink/mode-markdown-uncompressed.js
index c8df839a..392b0bf9 100644
--- a/build/demo/kitchen-sink/mode-markdown-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-markdown-uncompressed.js
@@ -381,25 +381,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -415,7 +486,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-scala-uncompressed.js b/build/demo/kitchen-sink/mode-scala-uncompressed.js
index e4771c2b..04a2fee8 100644
--- a/build/demo/kitchen-sink/mode-scala-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-scala-uncompressed.js
@@ -326,25 +326,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -360,7 +431,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/mode-svg-uncompressed.js b/build/demo/kitchen-sink/mode-svg-uncompressed.js
index 41c4c9ae..b059c5f4 100644
--- a/build/demo/kitchen-sink/mode-svg-uncompressed.js
+++ b/build/demo/kitchen-sink/mode-svg-uncompressed.js
@@ -1380,25 +1380,96 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, { // match stuff like: Sound.prototype.play = function() { }
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
- token : ["storage.type", "punctuation.operator", "support.function", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text"],
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "support.function",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text"
+ ],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
- token : ["storage.type", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "storage.type",
+ "punctuation.operator",
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
- token : ["entity.name.function", "text", "keyword.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "keyword.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
- token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "storage.type",
+ "text",
+ "entity.name.function",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
- token : ["entity.name.function", "text", "punctuation.operator", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)?(\\s*)(\\()(.*?)(\\))"
+ token : [
+ "entity.name.function",
+ "text",
+ "punctuation.operator",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
- token : ["text", "text", "storage.type", "text", "paren.lparen", "variable.parameter", "paren.rparen"],
+ token : [
+ "text",
+ "text",
+ "storage.type",
+ "text",
+ "paren.lparen",
+ "variable.parameter",
+ "paren.rparen"
+ ],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, {
token : "constant.language.boolean",
@@ -1414,7 +1485,7 @@ var JavaScriptHighlightRules = function() {
token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()"
}, {
- token : "support.function.constant",
+ token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b"
}, {
token : ["punctuation.operator", "support.function.firebug"],
diff --git a/build/demo/kitchen-sink/theme-chrome-uncompressed.js b/build/demo/kitchen-sink/theme-chrome-uncompressed.js
index 1caa9483..57700c4b 100644
--- a/build/demo/kitchen-sink/theme-chrome-uncompressed.js
+++ b/build/demo/kitchen-sink/theme-chrome-uncompressed.js
@@ -47,7 +47,6 @@ exports.cssText = ".ace-chrome .ace_editor {\
}\
\
.ace-chrome .ace_gutter {\
- width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
@@ -58,10 +57,6 @@ exports.cssText = ".ace-chrome .ace_editor {\
text-align: right;\
}\
\
-.ace-chrome .ace_gutter-layer .ace_gutter-cell {\
- padding-right: 6px;\
-}\
-\
.ace-chrome .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
diff --git a/build/demo/kitchen-sink/worker-javascript.js b/build/demo/kitchen-sink/worker-javascript.js
index 2b1e7704..2f61dd13 100644
--- a/build/demo/kitchen-sink/worker-javascript.js
+++ b/build/demo/kitchen-sink/worker-javascript.js
@@ -1540,12 +1540,13 @@ exports.implement = function(proto, mixin) {
*
* ***** END LICENSE BLOCK ***** */
-define('ace/mode/javascript_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/worker/jshint', 'ace/narcissus/jsparse'], function(require, exports, module) {
+define('ace/mode/javascript_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/worker/jshint', 'ace/narcissus/parser'], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;
var lint = require("../worker/jshint").JSHINT;
+var parser = require("../narcissus/parser");
var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
Mirror.call(this, sender);
@@ -1561,7 +1562,6 @@ oop.inherits(JavaScriptWorker, Mirror);
value = value.replace(/^#!.*\n/, "\n");
// var start = new Date();
- var parser = require("../narcissus/jsparse");
try {
parser.parse(value);
} catch(e) {
@@ -7218,598 +7218,648 @@ if (typeof exports === 'object' && exports)
* Parser.
*/
-define('ace/narcissus/jsparse', ['require', 'exports', 'module' , 'ace/narcissus/jslex', 'ace/narcissus/jsdefs'], function(require, exports, module) {
+define('ace/narcissus/parser', ['require', 'exports', 'module' , 'ace/narcissus/lexer', 'ace/narcissus/definitions', 'ace/narcissus/options'], function(require, exports, module) {
- var lexer = require("./jslex");
- var definitions = require("./jsdefs");
+var lexer = require('./lexer');
+var definitions = require('./definitions');
+var options = require('./options');
+var Tokenizer = lexer.Tokenizer;
- const StringMap = definitions.StringMap;
- const Stack = definitions.Stack;
+var Dict = definitions.Dict;
+var Stack = definitions.Stack;
- // Set constants in the local scope.
- eval(definitions.consts);
+// Set constants in the local scope.
+eval(definitions.consts);
- // Banned statement types by language version.
- const blackLists = { 160: {}, 185: {}, harmony: {} };
- blackLists[160][IMPORT] = true;
- blackLists[160][EXPORT] = true;
- blackLists[160][LET] = true;
- blackLists[160][MODULE] = true;
- blackLists[160][YIELD] = true;
- blackLists[185][IMPORT] = true;
- blackLists[185][EXPORT] = true;
- blackLists[185][MODULE] = true;
- blackLists.harmony[WITH] = true;
-
- /*
- * pushDestructuringVarDecls :: (node, hoisting node) -> void
- *
- * Recursively add all destructured declarations to varDecls.
- */
- function pushDestructuringVarDecls(n, s) {
- for (var i in n) {
- var sub = n[i];
- if (sub.type === IDENTIFIER) {
- s.varDecls.push(sub);
- } else {
- pushDestructuringVarDecls(sub, s);
- }
- }
- }
-
- function StaticContext(parentScript, parentBlock, inModule, inFunction) {
- this.parentScript = parentScript;
- this.parentBlock = parentBlock || parentScript;
- this.inModule = inModule || false;
- this.inFunction = inFunction || false;
- this.inForLoopInit = false;
- this.topLevel = true;
- this.allLabels = new Stack();
- this.currentLabels = new Stack();
- this.labeledTargets = new Stack();
- this.defaultLoopTarget = null;
- this.defaultTarget = null;
- this.blackList = blackLists[Narcissus.options.version];
- Narcissus.options.ecma3OnlyMode && (this.ecma3OnlyMode = true);
- Narcissus.options.parenFreeMode && (this.parenFreeMode = true);
- }
-
- StaticContext.prototype = {
- ecma3OnlyMode: false,
- parenFreeMode: false,
- // non-destructive update via prototype extension
- update: function(ext) {
- var desc = {};
- for (var key in ext) {
- desc[key] = {
- value: ext[key],
- writable: true,
- enumerable: true,
- configurable: true
- }
- }
- return Object.create(this, desc);
- },
- pushLabel: function(label) {
- return this.update({ currentLabels: this.currentLabels.push(label),
- allLabels: this.allLabels.push(label) });
- },
- pushTarget: function(target) {
- var isDefaultLoopTarget = target.isLoop;
- var isDefaultTarget = isDefaultLoopTarget || target.type === SWITCH;
-
- if (this.currentLabels.isEmpty()) {
- if (isDefaultLoopTarget) this.update({ defaultLoopTarget: target });
- if (isDefaultTarget) this.update({ defaultTarget: target });
- return this;
- }
-
- target.labels = new StringMap();
- this.currentLabels.forEach(function(label) {
- target.labels.set(label, true);
- });
- return this.update({ currentLabels: new Stack(),
- labeledTargets: this.labeledTargets.push(target),
- defaultLoopTarget: isDefaultLoopTarget
- ? target
- : this.defaultLoopTarget,
- defaultTarget: isDefaultTarget
- ? target
- : this.defaultTarget });
- },
- nest: function() {
- return this.topLevel ? this.update({ topLevel: false }) : this;
- },
- allow: function(type) {
- switch (type) {
- case EXPORT:
- if (!this.inModule || this.inFunction || !this.topLevel)
- return false;
- // FALL THROUGH
-
- case IMPORT:
- return !this.inFunction && this.topLevel;
-
- case MODULE:
- return !this.inFunction && this.topLevel;
-
- default:
- return true;
- }
- }
- };
-
- /*
- * Script :: (tokenizer, boolean, boolean) -> node
- *
- * Parses the toplevel and module/function bodies.
- */
- function Script(t, inModule, inFunction) {
- var n = new Node(t, scriptInit());
- Statements(t, new StaticContext(n, n, inModule, inFunction), n);
- return n;
- }
-
- // We extend Array slightly with a top-of-stack method.
- definitions.defineProperty(Array.prototype, "top",
- function() {
- return this.length && this[this.length-1];
- }, false, false, true);
-
- /*
- * Node :: (tokenizer, optional init object) -> node
- */
- function Node(t, init) {
- var token = t.token;
- if (token) {
- // If init.type exists it will override token.type.
- this.type = token.type;
- this.value = token.value;
- this.lineno = token.lineno;
-
- // Start and end are file positions for error handling.
- this.start = token.start;
- this.end = token.end;
+/*
+ * pushDestructuringVarDecls :: (node, hoisting node) -> void
+ *
+ * Recursively add all destructured declarations to varDecls.
+ */
+function pushDestructuringVarDecls(n, s) {
+ for (var i in n) {
+ var sub = n[i];
+ if (sub.type === IDENTIFIER) {
+ s.varDecls.push(sub);
} else {
- this.lineno = t.lineno;
- }
-
- // Node uses a tokenizer for debugging (getSource, filename getter).
- this.tokenizer = t;
- this.children = [];
-
- for (var prop in init)
- this[prop] = init[prop];
- }
-
- /*
- * SyntheticNode :: (tokenizer, optional init object) -> node
- */
- function SyntheticNode(t, init) {
- // print("SYNTHETIC NODE");
- // if (init.type === COMMA) {
- // print("SYNTHETIC COMMA");
- // print(init);
- // }
- this.tokenizer = t;
- this.children = [];
- for (var prop in init)
- this[prop] = init[prop];
- this.synthetic = true;
- }
-
- var Np = Node.prototype = SyntheticNode.prototype = {};
- Np.constructor = Node;
-
- const TO_SOURCE_SKIP = {
- type: true,
- value: true,
- lineno: true,
- start: true,
- end: true,
- tokenizer: true,
- assignOp: true
- };
- function unevalableConst(code) {
- var token = definitions.tokens[code];
- var constName = definitions.opTypeNames.hasOwnProperty(token)
- ? definitions.opTypeNames[token]
- : token in definitions.keywords
- ? token.toUpperCase()
- : token;
- return { toSource: function() { return constName } };
- }
- Np.toSource = function toSource() {
- var mock = {};
- var self = this;
- mock.type = unevalableConst(this.type);
- if ("value" in this)
- mock.value = this.value;
- if ("lineno" in this)
- mock.lineno = this.lineno;
- if ("start" in this)
- mock.start = this.start;
- if ("end" in this)
- mock.end = this.end;
- if (this.assignOp)
- mock.assignOp = unevalableConst(this.assignOp);
- for (var key in this) {
- if (this.hasOwnProperty(key) && !(key in TO_SOURCE_SKIP))
- mock[key] = this[key];
- }
- return mock.toSource();
- };
-
- // Always use push to add operands to an expression, to update start and end.
- Np.push = function (kid) {
- // kid can be null e.g. [1, , 2].
- if (kid !== null) {
- if (kid.start < this.start)
- this.start = kid.start;
- if (this.end < kid.end)
- this.end = kid.end;
- }
- return this.children.push(kid);
- }
-
- Node.indentLevel = 0;
-
- function tokenString(tt) {
- var t = definitions.tokens[tt];
- return /^\W/.test(t) ? definitions.opTypeNames[t] : t.toUpperCase();
- }
-
- Np.toString = function () {
- var a = [];
- for (var i in this) {
- if (this.hasOwnProperty(i) && i !== 'type' && i !== 'target')
- a.push({id: i, value: this[i]});
- }
- a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; });
- const INDENTATION = " ";
- var n = ++Node.indentLevel;
- var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenString(this.type);
- for (i = 0; i < a.length; i++)
- s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value;
- n = --Node.indentLevel;
- s += "\n" + INDENTATION.repeat(n) + "}";
- return s;
- }
-
- Np.getSource = function () {
- return this.tokenizer.source.slice(this.start, this.end);
- };
-
- /*
- * Helper init objects for common nodes.
- */
-
- const LOOP_INIT = { isLoop: true };
-
- function blockInit() {
- return { type: BLOCK, varDecls: [] };
- }
-
- function scriptInit() {
- return { type: SCRIPT,
- funDecls: [],
- varDecls: [],
- modDefns: new StringMap(),
- modAssns: new StringMap(),
- modDecls: new StringMap(),
- modLoads: new StringMap(),
- impDecls: [],
- expDecls: [],
- exports: new StringMap(),
- hasEmptyReturn: false,
- hasReturnWithValue: false,
- isGenerator: false };
- }
-
- definitions.defineGetter(Np, "filename",
- function() {
- return this.tokenizer.filename;
- });
-
- definitions.defineGetter(Np, "length",
- function() {
- throw new Error("Node.prototype.length is gone; " +
- "use n.children.length instead");
- });
-
- definitions.defineProperty(String.prototype, "repeat",
- function(n) {
- var s = "", t = this + s;
- while (--n >= 0)
- s += t;
- return s;
- }, false, false, true);
-
- function MaybeLeftParen(t, x) {
- if (x.parenFreeMode)
- return t.match(LEFT_PAREN) ? LEFT_PAREN : END;
- return t.mustMatch(LEFT_PAREN).type;
- }
-
- function MaybeRightParen(t, p) {
- if (p === LEFT_PAREN)
- t.mustMatch(RIGHT_PAREN);
- }
-
- /*
- * Statements :: (tokenizer, compiler context, node) -> void
- *
- * Parses a sequence of Statements.
- */
- function Statements(t, x, n) {
- try {
- while (!t.done && t.peek(true) !== RIGHT_CURLY)
- n.push(Statement(t, x));
- } catch (e) {
- if (t.done)
- t.unexpectedEOF = true;
- throw e;
+ pushDestructuringVarDecls(sub, s);
}
}
+}
- function Block(t, x) {
- t.mustMatch(LEFT_CURLY);
- var n = new Node(t, blockInit());
- Statements(t, x.update({ parentBlock: n }).pushTarget(n), n);
- t.mustMatch(RIGHT_CURLY);
- return n;
- }
+function Parser(tokenizer) {
+ tokenizer.parser = this;
+ this.t = tokenizer;
+ this.x = null;
+ this.unexpectedEOF = false;
+ options.mozillaMode && (this.mozillaMode = true);
+ options.parenFreeMode && (this.parenFreeMode = true);
+}
- const DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2;
+function StaticContext(parentScript, parentBlock, inModule, inFunction, strictMode) {
+ this.parentScript = parentScript;
+ this.parentBlock = parentBlock || parentScript;
+ this.inModule = inModule || false;
+ this.inFunction = inFunction || false;
+ this.inForLoopInit = false;
+ this.topLevel = true;
+ this.allLabels = new Stack();
+ this.currentLabels = new Stack();
+ this.labeledTargets = new Stack();
+ this.defaultLoopTarget = null;
+ this.defaultTarget = null;
+ this.strictMode = strictMode;
+}
- /*
- * Export :: (binding node, boolean) -> Export
- *
- * Static semantic representation of a module export.
- */
- function Export(node, isDefinition) {
- this.node = node; // the AST node declaring this individual export
- this.isDefinition = isDefinition; // is the node an 'export'-annotated definition?
- this.resolved = null; // resolved pointer to the target of this export
- }
-
- /*
- * registerExport :: (StringMap, EXPORT node) -> void
- */
- function registerExport(exports, decl) {
- function register(name, exp) {
- if (exports.has(name))
- throw new SyntaxError("multiple exports of " + name);
- exports.set(name, exp);
- }
-
- switch (decl.type) {
- case MODULE:
- case FUNCTION:
- register(decl.name, new Export(decl, true));
- break;
-
- case VAR:
- for (var i = 0; i < decl.children.length; i++)
- register(decl.children[i].name, new Export(decl.children[i], true));
- break;
-
- case LET:
- case CONST:
- throw new Error("NYI: " + definitions.tokens[decl.type]);
-
- case EXPORT:
- for (var i = 0; i < decl.pathList.length; i++) {
- var path = decl.pathList[i];
- switch (path.type) {
- case OBJECT_INIT:
- for (var j = 0; j < path.children.length; j++) {
- // init :: IDENTIFIER | PROPERTY_INIT
- var init = path.children[j];
- if (init.type === IDENTIFIER)
- register(init.value, new Export(init, false));
- else
- register(init.children[0].value, new Export(init.children[1], false));
- }
- break;
-
- case DOT:
- register(path.children[1].value, new Export(path, false));
- break;
-
- case IDENTIFIER:
- register(path.value, new Export(path, false));
- break;
-
- default:
- throw new Error("unexpected export path: " + definitions.tokens[path.type]);
- }
+StaticContext.prototype = {
+ // non-destructive update via prototype extension
+ update: function(ext) {
+ var desc = {};
+ for (var key in ext) {
+ desc[key] = {
+ value: ext[key],
+ writable: true,
+ enumerable: true,
+ configurable: true
}
- break;
-
- default:
- throw new Error("unexpected export decl: " + definitions.tokens[exp.type]);
}
- }
+ return Object.create(this, desc);
+ },
+ pushLabel: function(label) {
+ return this.update({ currentLabels: this.currentLabels.push(label),
+ allLabels: this.allLabels.push(label) });
+ },
+ pushTarget: function(target) {
+ var isDefaultLoopTarget = target.isLoop;
+ var isDefaultTarget = isDefaultLoopTarget || target.type === SWITCH;
- /*
- * Module :: (node) -> Module
- *
- * Static semantic representation of a module.
- */
- function Module(node) {
- var exports = node.body.exports;
- var modDefns = node.body.modDefns;
+ if (this.currentLabels.isEmpty()) {
+ if (isDefaultLoopTarget) this.update({ defaultLoopTarget: target });
+ if (isDefaultTarget) this.update({ defaultTarget: target });
+ return this;
+ }
- var exportedModules = new StringMap();
-
- exports.forEach(function(name, exp) {
- var node = exp.node;
- if (node.type === MODULE) {
- exportedModules.set(name, node);
- } else if (!exp.isDefinition && node.type === IDENTIFIER && modDefns.has(node.value)) {
- var mod = modDefns.get(node.value);
- exportedModules.set(name, mod);
- }
+ target.labels = new Dict();
+ this.currentLabels.forEach(function(label) {
+ target.labels.set(label, true);
});
+ return this.update({ currentLabels: new Stack(),
+ labeledTargets: this.labeledTargets.push(target),
+ defaultLoopTarget: isDefaultLoopTarget
+ ? target
+ : this.defaultLoopTarget,
+ defaultTarget: isDefaultTarget
+ ? target
+ : this.defaultTarget });
+ },
+ nest: function() {
+ return this.topLevel ? this.update({ topLevel: false }) : this;
+ },
+ canImport: function() {
+ return this.topLevel && !this.inFunction;
+ },
+ canExport: function() {
+ return this.inModule && this.topLevel && !this.inFunction;
+ },
+ banWith: function() {
+ return this.strictMode || this.inModule;
+ },
+ modulesAllowed: function() {
+ return this.topLevel && !this.inFunction;
+ }
+};
- this.node = node;
- this.exports = exports;
- this.exportedModules = exportedModules;
+var Pp = Parser.prototype;
+
+Pp.mozillaMode = false;
+
+Pp.parenFreeMode = false;
+
+Pp.withContext = function(x, f) {
+ var x0 = this.x;
+ this.x = x;
+ var result = f.call(this);
+ // NB: we don't bother with finally, since exceptions trash the parser
+ this.x = x0;
+ return result;
+};
+
+Pp.newNode = function newNode(opts) {
+ return new Node(this.t, opts);
+};
+
+Pp.fail = function fail(msg) {
+ throw this.t.newSyntaxError(msg);
+};
+
+Pp.match = function match(tt, scanOperand, keywordIsName) {
+ return this.t.match(tt, scanOperand, keywordIsName);
+};
+
+Pp.mustMatch = function mustMatch(tt, keywordIsName) {
+ return this.t.mustMatch(tt, keywordIsName);
+};
+
+Pp.peek = function peek(scanOperand) {
+ return this.t.peek(scanOperand);
+};
+
+Pp.peekOnSameLine = function peekOnSameLine(scanOperand) {
+ return this.t.peekOnSameLine(scanOperand);
+};
+
+Pp.done = function done() {
+ return this.t.done;
+};
+
+/*
+ * Script :: (boolean, boolean, boolean) -> node
+ *
+ * Parses the toplevel and module/function bodies.
+ */
+Pp.Script = function Script(inModule, inFunction, expectEnd) {
+ var node = this.newNode(scriptInit());
+ var x2 = new StaticContext(node, node, inModule, inFunction);
+ this.withContext(x2, function() {
+ this.Statements(node, true);
+ });
+ if (expectEnd && !this.done())
+ this.fail("expected end of input");
+ return node;
+};
+
+/*
+ * Pragma :: (expression statement node) -> boolean
+ *
+ * Checks whether a node is a pragma and annotates it.
+ */
+function Pragma(n) {
+ if (n.type === SEMICOLON) {
+ var e = n.expression;
+ if (e.type === STRING && e.value === "use strict") {
+ n.pragma = "strict";
+ return true;
+ }
+ }
+ return false;
+}
+
+/*
+ * Node :: (tokenizer, optional init object) -> node
+ */
+function Node(t, init) {
+ var token = t.token;
+ if (token) {
+ // If init.type exists it will override token.type.
+ this.type = token.type;
+ this.value = token.value;
+ this.lineno = token.lineno;
+
+ // Start and end are file positions for error handling.
+ this.start = token.start;
+ this.end = token.end;
+ } else {
+ this.lineno = t.lineno;
}
- /*
- * Statement :: (tokenizer, compiler context) -> node
- *
- * Parses a Statement.
- */
- function Statement(t, x) {
- var i, label, n, n2, p, c, ss, tt = t.get(true), tt2, x2, x3;
+ this.filename = t.filename;
+ this.children = [];
- var comments = t.blockComments;
+ for (var prop in init)
+ this[prop] = init[prop];
+}
- if (x.blackList[tt])
- throw t.newSyntaxError(definitions.tokens[tt] + " statements only allowed in Harmony");
- if (!x.allow(tt))
- throw t.newSyntaxError(definitions.tokens[tt] + " statement in illegal context");
+/*
+ * SyntheticNode :: (optional init object) -> node
+ */
+function SyntheticNode(init) {
+ this.children = [];
+ for (var prop in init)
+ this[prop] = init[prop];
+ this.synthetic = true;
+}
- // Cases for statements ending in a right curly return early, avoiding the
- // common semicolon insertion magic after this switch.
- switch (tt) {
- case IMPORT:
- n = new Node(t);
- n.pathList = ImportPathList(t, x);
- x.parentScript.impDecls.push(n);
- break;
+var Np = Node.prototype = SyntheticNode.prototype = {};
+Np.constructor = Node;
- case EXPORT:
- switch (t.peek()) {
- case MODULE:
- case FUNCTION:
- case LET:
- case VAR:
- case CONST:
- n = Statement(t, x);
- n.blockComments = comments;
- n.exported = true;
- x.parentScript.expDecls.push(n);
- registerExport(x.parentScript.exports, n);
- return n;
+var TO_SOURCE_SKIP = {
+ type: true,
+ value: true,
+ lineno: true,
+ start: true,
+ end: true,
+ tokenizer: true,
+ assignOp: true
+};
+function unevalableConst(code) {
+ var token = definitions.tokens[code];
+ var constName = definitions.opTypeNames.hasOwnProperty(token)
+ ? definitions.opTypeNames[token]
+ : token in definitions.keywords
+ ? token.toUpperCase()
+ : token;
+ return { toSource: function() { return constName } };
+}
+Np.toSource = function toSource() {
+ var mock = {};
+ var self = this;
+ mock.type = unevalableConst(this.type);
+ // avoid infinite recursion in case of back-links
+ if (this.generatingSource)
+ return mock.toSource();
+ this.generatingSource = true;
+ if ("value" in this)
+ mock.value = this.value;
+ if ("lineno" in this)
+ mock.lineno = this.lineno;
+ if ("start" in this)
+ mock.start = this.start;
+ if ("end" in this)
+ mock.end = this.end;
+ if (this.assignOp)
+ mock.assignOp = unevalableConst(this.assignOp);
+ for (var key in this) {
+ if (this.hasOwnProperty(key) && !(key in TO_SOURCE_SKIP))
+ mock[key] = this[key];
+ }
+ try {
+ return mock.toSource();
+ } finally {
+ delete this.generatingSource;
+ }
+};
+
+// Always use push to add operands to an expression, to update start and end.
+Np.push = function (kid) {
+ // kid can be null e.g. [1, , 2].
+ if (kid !== null) {
+ if (kid.start < this.start)
+ this.start = kid.start;
+ if (this.end < kid.end)
+ this.end = kid.end;
+ }
+ return this.children.push(kid);
+}
+
+Node.indentLevel = 0;
+
+function tokenString(tt) {
+ var t = definitions.tokens[tt];
+ return /^\W/.test(t) ? definitions.opTypeNames[t] : t.toUpperCase();
+}
+
+Np.toString = function () {
+ var a = [];
+ for (var i in this) {
+ if (this.hasOwnProperty(i) && i !== 'type' && i !== 'target')
+ a.push({id: i, value: this[i]});
+ }
+ a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; });
+ var INDENTATION = " ";
+ var n = ++Node.indentLevel;
+ var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenString(this.type);
+ for (i = 0; i < a.length; i++)
+ s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value;
+ n = --Node.indentLevel;
+ s += "\n" + INDENTATION.repeat(n) + "}";
+ return s;
+}
+
+Np.synth = function(init) {
+ var node = new SyntheticNode(init);
+ node.filename = this.filename;
+ node.lineno = this.lineno;
+ node.start = this.start;
+ node.end = this.end;
+ return node;
+};
+
+/*
+ * Helper init objects for common nodes.
+ */
+
+var LOOP_INIT = { isLoop: true };
+
+function blockInit() {
+ return { type: BLOCK, varDecls: [] };
+}
+
+function scriptInit() {
+ return { type: SCRIPT,
+ funDecls: [],
+ varDecls: [],
+ modDefns: new Dict(),
+ modAssns: new Dict(),
+ modDecls: new Dict(),
+ modLoads: new Dict(),
+ impDecls: [],
+ expDecls: [],
+ exports: new Dict(),
+ hasEmptyReturn: false,
+ hasReturnWithValue: false,
+ hasYield: false };
+}
+
+definitions.defineGetter(Np, "length",
+ function() {
+ throw new Error("Node.prototype.length is gone; " +
+ "use n.children.length instead");
+ });
+
+definitions.defineProperty(String.prototype, "repeat",
+ function(n) {
+ var s = "", t = this + s;
+ while (--n >= 0)
+ s += t;
+ return s;
+ }, false, false, true);
+
+Pp.MaybeLeftParen = function MaybeLeftParen() {
+ if (this.parenFreeMode)
+ return this.match(LEFT_PAREN) ? LEFT_PAREN : END;
+ return this.mustMatch(LEFT_PAREN).type;
+};
+
+Pp.MaybeRightParen = function MaybeRightParen(p) {
+ if (p === LEFT_PAREN)
+ this.mustMatch(RIGHT_PAREN);
+}
+
+/*
+ * Statements :: (node[, boolean]) -> void
+ *
+ * Parses a sequence of Statements.
+ */
+Pp.Statements = function Statements(n, topLevel) {
+ var prologue = !!topLevel;
+ try {
+ while (!this.done() && this.peek(true) !== RIGHT_CURLY) {
+ var n2 = this.Statement();
+ n.push(n2);
+ if (prologue && Pragma(n2)) {
+ this.x.strictMode = true;
+ n.strict = true;
+ } else {
+ prologue = false;
+ }
+ }
+ } catch (e) {
+ try {
+ if (this.done())
+ this.unexpectedEOF = true;
+ } catch(e) {}
+ throw e;
+ }
+}
+
+Pp.Block = function Block() {
+ this.mustMatch(LEFT_CURLY);
+ var n = this.newNode(blockInit());
+ var x2 = this.x.update({ parentBlock: n }).pushTarget(n);
+ this.withContext(x2, function() {
+ this.Statements(n);
+ });
+ this.mustMatch(RIGHT_CURLY);
+ return n;
+}
+
+var DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2;
+
+/*
+ * Export :: (binding node, boolean) -> Export
+ *
+ * Static semantic representation of a module export.
+ */
+function Export(node, isDefinition) {
+ this.node = node; // the AST node declaring this individual export
+ this.isDefinition = isDefinition; // is the node an 'export'-annotated definition?
+ this.resolved = null; // resolved pointer to the target of this export
+}
+
+/*
+ * registerExport :: (Dict, EXPORT node) -> void
+ */
+function registerExport(exports, decl) {
+ function register(name, exp) {
+ if (exports.has(name))
+ throw new SyntaxError("multiple exports of " + name);
+ exports.set(name, exp);
+ }
+
+ switch (decl.type) {
+ case MODULE:
+ case FUNCTION:
+ register(decl.name, new Export(decl, true));
+ break;
+
+ case VAR:
+ for (var i = 0; i < decl.children.length; i++)
+ register(decl.children[i].name, new Export(decl.children[i], true));
+ break;
+
+ case LET:
+ case CONST:
+ throw new Error("NYI: " + definitions.tokens[decl.type]);
+
+ case EXPORT:
+ for (var i = 0; i < decl.pathList.length; i++) {
+ var path = decl.pathList[i];
+ switch (path.type) {
+ case OBJECT_INIT:
+ for (var j = 0; j < path.children.length; j++) {
+ // init :: IDENTIFIER | PROPERTY_INIT
+ var init = path.children[j];
+ if (init.type === IDENTIFIER)
+ register(init.value, new Export(init, false));
+ else
+ register(init.children[0].value, new Export(init.children[1], false));
+ }
+ break;
+
+ case DOT:
+ register(path.children[1].value, new Export(path, false));
+ break;
+
+ case IDENTIFIER:
+ register(path.value, new Export(path, false));
+ break;
default:
- n = new Node(t);
- n.pathList = ExportPathList(t, x);
- break;
+ throw new Error("unexpected export path: " + definitions.tokens[path.type]);
}
- x.parentScript.expDecls.push(n);
- registerExport(x.parentScript.exports, n);
- break;
+ }
+ break;
+ default:
+ throw new Error("unexpected export decl: " + definitions.tokens[exp.type]);
+ }
+}
+
+/*
+ * Module :: (node) -> Module
+ *
+ * Static semantic representation of a module.
+ */
+function Module(node) {
+ var exports = node.body.exports;
+ var modDefns = node.body.modDefns;
+
+ var exportedModules = new Dict();
+
+ exports.forEach(function(name, exp) {
+ var node = exp.node;
+ if (node.type === MODULE) {
+ exportedModules.set(name, node);
+ } else if (!exp.isDefinition && node.type === IDENTIFIER && modDefns.has(node.value)) {
+ var mod = modDefns.get(node.value);
+ exportedModules.set(name, mod);
+ }
+ });
+
+ this.node = node;
+ this.exports = exports;
+ this.exportedModules = exportedModules;
+}
+
+/*
+ * Statement :: () -> node
+ *
+ * Parses a Statement.
+ */
+Pp.Statement = function Statement() {
+ var i, label, n, n2, p, c, ss, tt = this.t.get(true), tt2, x0, x2, x3;
+
+ var comments = this.t.blockComments;
+
+ // Cases for statements ending in a right curly return early, avoiding the
+ // common semicolon insertion magic after this switch.
+ switch (tt) {
+ case IMPORT:
+ if (!this.x.canImport())
+ this.fail("illegal context for import statement");
+ n = this.newNode();
+ n.pathList = this.ImportPathList();
+ this.x.parentScript.impDecls.push(n);
+ break;
+
+ case EXPORT:
+ if (!this.x.canExport())
+ this.fail("export statement not in module top level");
+ switch (this.peek()) {
case MODULE:
- n = new Node(t);
- n.blockComments = comments;
- t.mustMatch(IDENTIFIER);
- label = t.token.value;
-
- if (t.match(LEFT_CURLY)) {
- n.name = label;
- n.body = Script(t, true, false);
- n.module = new Module(n);
- t.mustMatch(RIGHT_CURLY);
- x.parentScript.modDefns.set(n.name, n);
- return n;
- }
-
- t.unget();
- ModuleVariables(t, x, n);
- return n;
-
case FUNCTION:
- // DECLARED_FORM extends funDecls of x, STATEMENT_FORM doesn't.
- return FunctionDefinition(t, x, true, x.topLevel ? DECLARED_FORM : STATEMENT_FORM, comments);
-
- case LEFT_CURLY:
- n = new Node(t, blockInit());
- Statements(t, x.update({ parentBlock: n }).pushTarget(n).nest(), n);
- t.mustMatch(RIGHT_CURLY);
+ case LET:
+ case VAR:
+ case CONST:
+ n = this.Statement();
+ n.blockComments = comments;
+ n.exported = true;
+ this.x.parentScript.expDecls.push(n);
+ registerExport(this.x.parentScript.exports, n);
return n;
+ }
+ n = this.newNode();
+ n.pathList = this.ExportPathList();
+ this.x.parentScript.expDecls.push(n);
+ registerExport(this.x.parentScript.exports, n);
+ break;
- case IF:
- n = new Node(t);
- n.condition = HeadExpression(t, x);
- x2 = x.pushTarget(n).nest();
- n.thenPart = Statement(t, x2);
- n.elsePart = t.match(ELSE, true) ? Statement(t, x2) : null;
- return n;
+ case FUNCTION:
+ // DECLARED_FORM extends funDecls of x, STATEMENT_FORM doesn't.
+ return this.FunctionDefinition(true, this.x.topLevel ? DECLARED_FORM : STATEMENT_FORM, comments);
- case SWITCH:
- // This allows CASEs after a DEFAULT, which is in the standard.
- n = new Node(t, { cases: [], defaultIndex: -1 });
- n.discriminant = HeadExpression(t, x);
- x2 = x.pushTarget(n).nest();
- t.mustMatch(LEFT_CURLY);
- while ((tt = t.get()) !== RIGHT_CURLY) {
+ case LEFT_CURLY:
+ n = this.newNode(blockInit());
+ x2 = this.x.update({ parentBlock: n }).pushTarget(n).nest();
+ this.withContext(x2, function() {
+ this.Statements(n);
+ });
+ this.mustMatch(RIGHT_CURLY);
+ return n;
+
+ case IF:
+ n = this.newNode();
+ n.condition = this.HeadExpression();
+ x2 = this.x.pushTarget(n).nest();
+ this.withContext(x2, function() {
+ n.thenPart = this.Statement();
+ n.elsePart = this.match(ELSE, true) ? this.Statement() : null;
+ });
+ return n;
+
+ case SWITCH:
+ // This allows CASEs after a DEFAULT, which is in the standard.
+ n = this.newNode({ cases: [], defaultIndex: -1 });
+ n.discriminant = this.HeadExpression();
+ x2 = this.x.pushTarget(n).nest();
+ this.withContext(x2, function() {
+ this.mustMatch(LEFT_CURLY);
+ while ((tt = this.t.get()) !== RIGHT_CURLY) {
switch (tt) {
case DEFAULT:
if (n.defaultIndex >= 0)
- throw t.newSyntaxError("More than one switch default");
+ this.fail("More than one switch default");
// FALL THROUGH
case CASE:
- n2 = new Node(t);
+ n2 = this.newNode();
if (tt === DEFAULT)
n.defaultIndex = n.cases.length;
else
- n2.caseLabel = Expression(t, x2, COLON);
+ n2.caseLabel = this.Expression(COLON);
break;
default:
- throw t.newSyntaxError("Invalid switch case");
+ this.fail("Invalid switch case");
}
- t.mustMatch(COLON);
- n2.statements = new Node(t, blockInit());
- while ((tt=t.peek(true)) !== CASE && tt !== DEFAULT &&
- tt !== RIGHT_CURLY)
- n2.statements.push(Statement(t, x2));
+ this.mustMatch(COLON);
+ n2.statements = this.newNode(blockInit());
+ while ((tt=this.peek(true)) !== CASE && tt !== DEFAULT &&
+ tt !== RIGHT_CURLY)
+ n2.statements.push(this.Statement());
n.cases.push(n2);
}
- return n;
+ });
+ return n;
- case FOR:
- n = new Node(t, LOOP_INIT);
- n.blockComments = comments;
- if (t.match(IDENTIFIER)) {
- if (t.token.value === "each")
- n.isEach = true;
- else
- t.unget();
- }
- if (!x.parenFreeMode)
- t.mustMatch(LEFT_PAREN);
- x2 = x.pushTarget(n).nest();
- x3 = x.update({ inForLoopInit: true });
- n2 = null;
- if ((tt = t.peek(true)) !== SEMICOLON) {
+ case FOR:
+ n = this.newNode(LOOP_INIT);
+ n.blockComments = comments;
+ if (this.match(IDENTIFIER)) {
+ if (this.t.token.value === "each")
+ n.isEach = true;
+ else
+ this.t.unget();
+ }
+ if (!this.parenFreeMode)
+ this.mustMatch(LEFT_PAREN);
+ x2 = this.x.pushTarget(n).nest();
+ x3 = this.x.update({ inForLoopInit: true });
+ n2 = null;
+ if ((tt = this.peek(true)) !== SEMICOLON) {
+ this.withContext(x3, function() {
if (tt === VAR || tt === CONST) {
- t.get();
- n2 = Variables(t, x3);
+ this.t.get();
+ n2 = this.Variables();
} else if (tt === LET) {
- t.get();
- if (t.peek() === LEFT_PAREN) {
- n2 = LetBlock(t, x3, false);
+ this.t.get();
+ if (this.peek() === LEFT_PAREN) {
+ n2 = this.LetBlock(false);
} else {
// Let in for head, we need to add an implicit block
// around the rest of the for.
- x3.parentBlock = n;
+ this.x.parentBlock = n;
n.varDecls = [];
- n2 = Variables(t, x3);
+ n2 = this.Variables();
}
} else {
- n2 = Expression(t, x3);
+ n2 = this.Expression();
}
- }
- if (n2 && t.match(IN)) {
- n.type = FOR_IN;
- n.object = Expression(t, x3);
+ });
+ }
+ if (n2 && this.match(IN)) {
+ n.type = FOR_IN;
+ this.withContext(x3, function() {
+ n.object = this.Expression();
if (n2.type === VAR || n2.type === LET) {
c = n2.children;
@@ -7817,8 +7867,9 @@ define('ace/narcissus/jsparse', ['require', 'exports', 'module' , 'ace/narcissus
// there must be only one destructuring or only one
// decl.
if (c.length !== 1 && n2.destructurings.length !== 1) {
+ // FIXME: this.fail ?
throw new SyntaxError("Invalid for..in left-hand side",
- t.filename, n2.lineno);
+ this.filename, n2.lineno);
}
if (n2.destructurings.length > 0) {
n.iterator = n2.destructurings[0];
@@ -7828,1252 +7879,1364 @@ define('ace/narcissus/jsparse', ['require', 'exports', 'module' , 'ace/narcissus
n.varDecl = n2;
} else {
if (n2.type === ARRAY_INIT || n2.type === OBJECT_INIT) {
- n2.destructuredNames = checkDestructuring(t, x3, n2);
+ n2.destructuredNames = this.checkDestructuring(n2);
}
n.iterator = n2;
}
- } else {
- x3.inForLoopInit = false;
- n.setup = n2;
- t.mustMatch(SEMICOLON);
- if (n.isEach)
- throw t.newSyntaxError("Invalid for each..in loop");
- n.condition = (t.peek(true) === SEMICOLON)
- ? null
- : Expression(t, x3);
- t.mustMatch(SEMICOLON);
- tt2 = t.peek(true);
- n.update = (x.parenFreeMode
+ });
+ } else {
+ x3.inForLoopInit = false;
+ n.setup = n2;
+ this.mustMatch(SEMICOLON);
+ if (n.isEach)
+ this.fail("Invalid for each..in loop");
+ this.withContext(x3, function() {
+ n.condition = (this.peek(true) === SEMICOLON)
+ ? null
+ : this.Expression();
+ this.mustMatch(SEMICOLON);
+ tt2 = this.peek(true);
+ n.update = (this.parenFreeMode
? tt2 === LEFT_CURLY || definitions.isStatementStartCode[tt2]
: tt2 === RIGHT_PAREN)
- ? null
- : Expression(t, x3);
+ ? null
+ : this.Expression();
+ });
+ }
+ if (!this.parenFreeMode)
+ this.mustMatch(RIGHT_PAREN);
+ this.withContext(x2, function() {
+ n.body = this.Statement();
+ });
+ return n;
+
+ case WHILE:
+ n = this.newNode({ isLoop: true });
+ n.blockComments = comments;
+ n.condition = this.HeadExpression();
+ x2 = this.x.pushTarget(n).nest();
+ this.withContext(x2, function() {
+ n.body = this.Statement();
+ });
+ return n;
+
+ case DO:
+ n = this.newNode({ isLoop: true });
+ n.blockComments = comments;
+ x2 = this.x.pushTarget(n).next();
+ this.withContext(x2, function() {
+ n.body = this.Statement();
+ });
+ this.mustMatch(WHILE);
+ n.condition = this.HeadExpression();
+ //