aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/ace/mode-lua.js
diff options
context:
space:
mode:
Diffstat (limited to 'contexts/data/lib/ace/mode-lua.js')
-rw-r--r--contexts/data/lib/ace/mode-lua.js610
1 files changed, 609 insertions, 1 deletions
diff --git a/contexts/data/lib/ace/mode-lua.js b/contexts/data/lib/ace/mode-lua.js
index 63b812c..1cc6a7a 100644
--- a/contexts/data/lib/ace/mode-lua.js
+++ b/contexts/data/lib/ace/mode-lua.js
@@ -1 +1,609 @@
-define("ace/mode/lua",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/lua_highlight_rules"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("./text").Mode,f=a("../tokenizer").Tokenizer,g=a("./lua_highlight_rules").LuaHighlightRules,h=function(){this.$tokenizer=new f((new g).getRules())};d.inherits(h,e),function(){this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a),f=e.tokens,g=["function","then","do","repeat"];if(a=="start"){var h=b.match(/^.*[\{\(\[]\s*$/);if(h)d+=c;else for(var i in f){var j=f[i];if(j.type!="keyword")continue;var k=g.indexOf(j.value);if(k!=-1){d+=c;break}}}return d}}.call(h.prototype),b.Mode=h}),define("ace/mode/lua_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("../lib/lang"),f=a("./text_highlight_rules").TextHighlightRules,g=function(){var a=e.arrayToMap("break|do|else|elseif|end|for|function|if|in|local|repeat|return|then|until|while|or|and|not".split("|")),b=e.arrayToMap("true|false|nil|_G|_VERSION".split("|")),c=e.arrayToMap("string|xpcall|package|tostring|print|os|unpack|require|getfenv|setmetatable|next|assert|tonumber|io|rawequal|collectgarbage|getmetatable|module|rawset|math|debug|pcall|table|newproxy|type|coroutine|_G|select|gcinfo|pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|load|error|loadfile|sub|upper|len|gfind|rep|find|match|char|dump|gmatch|reverse|byte|format|gsub|lower|preload|loadlib|loaded|loaders|cpath|config|path|seeall|exit|setlocale|date|getenv|difftime|remove|time|clock|tmpname|rename|execute|lines|write|close|flush|open|output|type|read|stderr|stdin|input|stdout|popen|tmpfile|log|max|acos|huge|ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|gethook|setmetatable|setlocal|traceback|setfenv|getinfo|setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|foreachi|maxn|foreach|concat|sort|remove|resume|yield|status|wrap|create|running".split("|")),d=e.arrayToMap("string|package|os|io|math|debug|table|coroutine".split("|")),f=e.arrayToMap("__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber".split("|")),g=e.arrayToMap("".split("|")),h=e.arrayToMap("setn|foreach|foreachi|gcinfo|log10|maxn".split("|")),i="",j="(?:(?:[1-9]\\d*)|(?:0))",k="(?:0[xX][\\dA-Fa-f]+)",l="(?:"+j+"|"+k+")",m="(?:\\.\\d+)",n="(?:\\d+)",o="(?:(?:"+n+"?"+m+")|(?:"+n+"\\.))",p="(?:"+o+")",q=[];this.$rules={start:[{token:"comment",regex:i+"\\-\\-\\[\\[.*\\]\\]"},{token:"comment",regex:i+"\\-\\-\\[\\=\\[.*\\]\\=\\]"},{token:"comment",regex:i+"\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]"},{token:"comment",regex:i+"\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]"},{token:"comment",regex:i+"\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]"},{token:"comment",regex:i+"\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]"},{token:"comment",regex:i+"\\-\\-\\[\\[.*$",merge:!0,next:"qcomment"},{token:"comment",regex:i+"\\-\\-\\[\\=\\[.*$",merge:!0,next:"qcomment1"},{token:"comment",regex:i+"\\-\\-\\[\\={2}\\[.*$",merge:!0,next:"qcomment2"},{token:"comment",regex:i+"\\-\\-\\[\\={3}\\[.*$",merge:!0,next:"qcomment3"},{token:"comment",regex:i+"\\-\\-\\[\\={4}\\[.*$",merge:!0,next:"qcomment4"},{token:function(a){var b=/\-\-\[(\=+)\[/,c;return(c=b.exec(a))!=null&&(c=c[1])!=undefined&&q.push(c.length),"comment"},regex:i+"\\-\\-\\[\\={5}\\=*\\[.*$",merge:!0,next:"qcomment5"},{token:"comment",regex:"\\-\\-.*$"},{token:"string",regex:i+"\\[\\[.*\\]\\]"},{token:"string",regex:i+"\\[\\=\\[.*\\]\\=\\]"},{token:"string",regex:i+"\\[\\={2}\\[.*\\]\\={2}\\]"},{token:"string",regex:i+"\\[\\={3}\\[.*\\]\\={3}\\]"},{token:"string",regex:i+"\\[\\={4}\\[.*\\]\\={4}\\]"},{token:"string",regex:i+"\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]"},{token:"string",regex:i+"\\[\\[.*$",merge:!0,next:"qstring"},{token:"string",regex:i+"\\[\\=\\[.*$",merge:!0,next:"qstring1"},{token:"string",regex:i+"\\[\\={2}\\[.*$",merge:!0,next:"qstring2"},{token:"string",regex:i+"\\[\\={3}\\[.*$",merge:!0,next:"qstring3"},{token:"string",regex:i+"\\[\\={4}\\[.*$",merge:!0,next:"qstring4"},{token:function(a){var b=/\[(\=+)\[/,c;return(c=b.exec(a))!=null&&(c=c[1])!=undefined&&q.push(c.length),"string"},regex:i+"\\[\\={5}\\=*\\[.*$",merge:!0,next:"qstring5"},{token:"string",regex:i+'"(?:[^\\\\]|\\\\.)*?"'},{token:"string",regex:i+"'(?:[^\\\\]|\\\\.)*?'"},{token:"constant.numeric",regex:p},{token:"constant.numeric",regex:l+"\\b"},{token:function(e){return a.hasOwnProperty(e)?"keyword":b.hasOwnProperty(e)?"constant.language":g.hasOwnProperty(e)?"invalid.illegal":d.hasOwnProperty(e)?"constant.library":h.hasOwnProperty(e)?"invalid.deprecated":c.hasOwnProperty(e)?"support.function":f.hasOwnProperty(e)?"support.function":"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+"}],qcomment:[{token:"comment",regex:"(?:[^\\\\]|\\\\.)*?\\]\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qcomment1:[{token:"comment",regex:"(?:[^\\\\]|\\\\.)*?\\]\\=\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qcomment2:[{token:"comment",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qcomment3:[{token:"comment",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qcomment4:[{token:"comment",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qcomment5:[{token:function(a){var b=/\](\=+)\]/,c=this.rules.qcomment5[0],d;c.next="start";if((d=b.exec(a))!=null&&(d=d[1])!=undefined){var e=d.length,f;(f=q.pop())!=e&&(q.push(f),c.next="qcomment5")}return"comment"},regex:"(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",next:"start"},{token:"comment",merge:!0,regex:".+"}],qstring:[{token:"string",regex:"(?:[^\\\\]|\\\\.)*?\\]\\]",next:"start"},{token:"string",merge:!0,regex:".+"}],qstring1:[{token:"string",regex:"(?:[^\\\\]|\\\\.)*?\\]\\=\\]",next:"start"},{token:"string",merge:!0,regex:".+"}],qstring2:[{token:"string",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",next:"start"},{token:"string",merge:!0,regex:".+"}],qstring3:[{token:"string",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",next:"start"},{token:"string",merge:!0,regex:".+"}],qstring4:[{token:"string",regex:"(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",next:"start"},{token:"string",merge:!0,regex:".+"}],qstring5:[{token:function(a){var b=/\](\=+)\]/,c=this.rules.qstring5[0],d;c.next="start";if((d=b.exec(a))!=null&&(d=d[1])!=undefined){var e=d.length,f;(f=q.pop())!=e&&(q.push(f),c.next="qstring5")}return"string"},regex:"(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",next:"start"},{token:"string",merge:!0,regex:".+"}]}};d.inherits(g,f),b.LuaHighlightRules=g}),function(){window.require(["ace/ace"],function(a){window.ace||(window.ace={});for(var b in a)a.hasOwnProperty(b)&&(ace[b]=a[b])})}() \ No newline at end of file
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Ajax.org B.V. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ace.define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules', 'ace/mode/folding/lua', 'ace/range'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
+var LuaFoldMode = require("./folding/lua").FoldMode;
+var Range = require("../range").Range;
+
+var Mode = function() {
+ this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules());
+ this.foldingRules = new LuaFoldMode();
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+ var indentKeywords = {
+ "function": 1,
+ "then": 1,
+ "do": 1,
+ "else": 1,
+ "elseif": 1,
+ "repeat": 1,
+ "end": -1,
+ "until": -1
+ };
+ var outdentKeywords = [
+ "else",
+ "elseif",
+ "end",
+ "until"
+ ];
+
+ function getNetIndentLevel(tokens) {
+ var level = 0;
+ for (var i = 0; i < tokens.length; i++) {
+ var token = tokens[i];
+ if (token.type == "keyword") {
+ if (token.value in indentKeywords) {
+ level += indentKeywords[token.value];
+ }
+ } else if (token.type == "paren.lparen") {
+ level ++;
+ } else if (token.type == "paren.rparen") {
+ level --;
+ }
+ }
+ if (level < 0) {
+ return -1;
+ } else if (level > 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ this.getNextLineIndent = function(state, line, tab) {
+ var indent = this.$getIndent(line);
+ var level = 0;
+
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
+ var tokens = tokenizedLine.tokens;
+
+ if (state == "start") {
+ level = getNetIndentLevel(tokens);
+ }
+ if (level > 0) {
+ return indent + tab;
+ } else if (level < 0 && indent.substr(indent.length - tab.length) == tab) {
+ if (!this.checkOutdent(state, line, "\n")) {
+ return indent.substr(0, indent.length - tab.length);
+ }
+ }
+ return indent;
+ };
+
+ this.checkOutdent = function(state, line, input) {
+ if (input != "\n" && input != "\r" && input != "\r\n")
+ return false;
+
+ if (line.match(/^\s*[\)\}\]]$/))
+ return true;
+
+ var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
+
+ if (!tokens || !tokens.length)
+ return false;
+
+ return (tokens[0].type == "keyword" && outdentKeywords.indexOf(tokens[0].value) != -1);
+ };
+
+ this.autoOutdent = function(state, session, row) {
+ var prevLine = session.getLine(row - 1);
+ var prevIndent = this.$getIndent(prevLine).length;
+ var prevTokens = this.$tokenizer.getLineTokens(prevLine, "start").tokens;
+ var tabLength = session.getTabString().length;
+ var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens);
+ var curIndent = this.$getIndent(session.getLine(row)).length;
+ if (curIndent < expectedIndent) {
+ return;
+ }
+ session.outdentRows(new Range(row, 0, row + 2, 0));
+ };
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});
+
+ace.define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var LuaHighlightRules = function() {
+
+ var keywords = (
+ "break|do|else|elseif|end|for|function|if|in|local|repeat|"+
+ "return|then|until|while|or|and|not"
+ );
+
+ var builtinConstants = ("true|false|nil|_G|_VERSION");
+
+ var functions = (
+ "string|xpcall|package|tostring|print|os|unpack|require|"+
+ "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+
+ "collectgarbage|getmetatable|module|rawset|math|debug|"+
+ "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+
+ "pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|"+
+ "load|error|loadfile|"+
+
+ "sub|upper|len|gfind|rep|find|match|char|dump|gmatch|"+
+ "reverse|byte|format|gsub|lower|preload|loadlib|loaded|"+
+ "loaders|cpath|config|path|seeall|exit|setlocale|date|"+
+ "getenv|difftime|remove|time|clock|tmpname|rename|execute|"+
+ "lines|write|close|flush|open|output|type|read|stderr|"+
+ "stdin|input|stdout|popen|tmpfile|log|max|acos|huge|"+
+ "ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|"+
+ "frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|"+
+ "atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|"+
+ "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+
+ "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+
+ "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+
+ "status|wrap|create|running|"+
+ "__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
+ "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber"
+ );
+
+ var stdLibaries = ("string|package|os|io|math|debug|table|coroutine");
+
+ var futureReserved = "";
+
+ var deprecatedIn5152 = ("setn|foreach|foreachi|gcinfo|log10|maxn");
+
+ var keywordMapper = this.createKeywordMapper({
+ "keyword": keywords,
+ "support.function": functions,
+ "invalid.deprecated": deprecatedIn5152,
+ "constant.library": stdLibaries,
+ "constant.language": builtinConstants,
+ "invalid.illegal": futureReserved,
+ "variable.language": "this"
+ }, "identifier");
+
+ var strPre = "";
+
+ var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
+ var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
+ var integer = "(?:" + decimalInteger + "|" + hexInteger + ")";
+
+ var fraction = "(?:\\.\\d+)";
+ var intPart = "(?:\\d+)";
+ var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
+ var floatNumber = "(?:" + pointFloat + ")";
+
+ var comment_stack = [];
+
+ this.$rules = {
+ "start" :
+ [{
+ token : "comment", // --[[ comment
+ regex : strPre + '\\-\\-\\[\\[.*\\]\\]'
+ }, {
+ token : "comment", // --[=[ comment
+ regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]'
+ }, {
+ token : "comment", // --[==[ comment
+ regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]'
+ }, {
+ token : "comment", // --[===[ comment
+ regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]'
+ }, {
+ token : "comment", // --[====[ comment
+ regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]'
+ }, {
+ token : "comment", // --[====+[ comment
+ regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
+ },
+ {
+ token : "comment", // --[[ comment
+ regex : strPre + '\\-\\-\\[\\[.*$',
+ next : "qcomment"
+ }, {
+ token : "comment", // --[=[ comment
+ regex : strPre + '\\-\\-\\[\\=\\[.*$',
+ next : "qcomment1"
+ }, {
+ token : "comment", // --[==[ comment
+ regex : strPre + '\\-\\-\\[\\={2}\\[.*$',
+ next : "qcomment2"
+ }, {
+ token : "comment", // --[===[ comment
+ regex : strPre + '\\-\\-\\[\\={3}\\[.*$',
+ next : "qcomment3"
+ }, {
+ token : "comment", // --[====[ comment
+ regex : strPre + '\\-\\-\\[\\={4}\\[.*$',
+ next : "qcomment4"
+ }, {
+ token : function(value){ // --[====+[ comment
+ var pattern = /\-\-\[(\=+)\[/, match;
+ if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
+ comment_stack.push(match.length);
+
+ return "comment";
+ },
+ regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$',
+ next : "qcomment5"
+ },
+ {
+ token : "comment",
+ regex : "\\-\\-.*$"
+ },
+ {
+ token : "string", // [[ string
+ regex : strPre + '\\[\\[.*\\]\\]'
+ }, {
+ token : "string", // [=[ string
+ regex : strPre + '\\[\\=\\[.*\\]\\=\\]'
+ }, {
+ token : "string", // [==[ string
+ regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]'
+ }, {
+ token : "string", // [===[ string
+ regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]'
+ }, {
+ token : "string", // [====[ string
+ regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]'
+ }, {
+ token : "string", // [====+[ string
+ regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
+ },
+ {
+ token : "string", // [[ string
+ regex : strPre + '\\[\\[.*$',
+ next : "qstring"
+ }, {
+ token : "string", // [=[ string
+ regex : strPre + '\\[\\=\\[.*$',
+ next : "qstring1"
+ }, {
+ token : "string", // [==[ string
+ regex : strPre + '\\[\\={2}\\[.*$',
+ next : "qstring2"
+ }, {
+ token : "string", // [===[ string
+ regex : strPre + '\\[\\={3}\\[.*$',
+ next : "qstring3"
+ }, {
+ token : "string", // [====[ string
+ regex : strPre + '\\[\\={4}\\[.*$',
+ next : "qstring4"
+ }, {
+ token : function(value){ // --[====+[ string
+ var pattern = /\[(\=+)\[/, match;
+ if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
+ comment_stack.push(match.length);
+
+ return "string";
+ },
+ regex : strPre + '\\[\\={5}\\=*\\[.*$',
+ next : "qstring5"
+ },
+
+ {
+ token : "string", // " string
+ regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
+ }, {
+ token : "string", // ' string
+ regex : strPre + "'(?:[^\\\\]|\\\\.)*?'"
+ }, {
+ token : "constant.numeric", // float
+ regex : floatNumber
+ }, {
+ token : "constant.numeric", // integer
+ regex : integer + "\\b"
+ }, {
+ token : keywordMapper,
+ 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+"
+ } ],
+
+ "qcomment": [ {
+ token : "comment",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+ "qcomment1": [ {
+ token : "comment",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+ "qcomment2": [ {
+ token : "comment",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+ "qcomment3": [ {
+ token : "comment",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+ "qcomment4": [ {
+ token : "comment",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+ "qcomment5": [ {
+ token : function(value){
+ var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match;
+ rule.next = "start";
+ if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
+ var found = match.length, expected;
+ if ((expected = comment_stack.pop()) != found){
+ comment_stack.push(expected);
+ rule.next = "qcomment5";
+ }
+ }
+
+ return "comment";
+ },
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : '.+'
+ } ],
+
+ "qstring": [ {
+ token : "string",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring1": [ {
+ token : "string",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring2": [ {
+ token : "string",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring3": [ {
+ token : "string",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring4": [ {
+ token : "string",
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring5": [ {
+ token : function(value){
+ var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match;
+ rule.next = "start";
+ if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
+ var found = match.length, expected;
+ if ((expected = comment_stack.pop()) != found){
+ comment_stack.push(expected);
+ rule.next = "qstring5";
+ }
+ }
+
+ return "string";
+ },
+ regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ]
+
+ };
+
+}
+
+oop.inherits(LuaHighlightRules, TextHighlightRules);
+
+exports.LuaHighlightRules = LuaHighlightRules;
+});
+
+ace.define('ace/mode/folding/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range', 'ace/token_iterator'], function(require, exports, module) {
+
+
+var oop = require("../../lib/oop");
+var BaseFoldMode = require("./fold_mode").FoldMode;
+var Range = require("../../range").Range;
+var TokenIterator = require("../../token_iterator").TokenIterator;
+
+
+var FoldMode = exports.FoldMode = function() {};
+
+oop.inherits(FoldMode, BaseFoldMode);
+
+(function() {
+
+ this.foldingStartMarker = /\b(function|then|do|repeat)\b|{\s*$|(\[=*\[)/;
+ this.foldingStopMarker = /\bend\b|^\s*}|\]=*\]/;
+
+ this.getFoldWidget = function(session, foldStyle, row) {
+ var line = session.getLine(row);
+ var isStart = this.foldingStartMarker.test(line);
+ var isEnd = this.foldingStopMarker.test(line);
+
+ if (isStart && !isEnd) {
+ var match = line.match(this.foldingStartMarker);
+ if (match[1] == "then" && /\belseif\b/.test(line))
+ return;
+ if (match[1]) {
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
+ return "start";
+ } else if (match[2]) {
+ var type = session.bgTokenizer.getState(row) || "";
+ if (type.indexOf("comment") != -1 || type.indexOf("string") != -1)
+ return "start";
+ } else {
+ return "start";
+ }
+ }
+ if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd)
+ return "";
+
+ var match = line.match(this.foldingStopMarker);
+ if (match[0] === "end") {
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
+ return "end";
+ } else if (match[0][0] === "]") {
+ var type = session.bgTokenizer.getState(row - 1) || "";
+ if (type.indexOf("comment") != -1 || type.indexOf("string") != -1)
+ return "end";
+ } else
+ return "end";
+ };
+
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
+ var line = session.doc.getLine(row);
+ var match = this.foldingStartMarker.exec(line);
+ if (match) {
+ if (match[1])
+ return this.luaBlock(session, row, match.index + 1);
+
+ if (match[2])
+ return session.getCommentFoldRange(row, match.index + 1);
+
+ return this.openingBracketBlock(session, "{", row, match.index);
+ }
+
+ var match = this.foldingStopMarker.exec(line);
+ if (match) {
+ if (match[0] === "end") {
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
+ return this.luaBlock(session, row, match.index + 1);
+ }
+
+ if (match[0][0] === "]")
+ return session.getCommentFoldRange(row, match.index + 1);
+
+ return this.closingBracketBlock(session, "}", row, match.index + match[0].length);
+ }
+ };
+
+ this.luaBlock = function(session, row, column) {
+ var stream = new TokenIterator(session, row, column);
+ var indentKeywords = {
+ "function": 1,
+ "do": 1,
+ "then": 1,
+ "elseif": -1,
+ "end": -1,
+ "repeat": 1,
+ "until": -1,
+ };
+
+ var token = stream.getCurrentToken();
+ if (!token || token.type != "keyword")
+ return;
+
+ var val = token.value;
+ var stack = [val];
+ var dir = indentKeywords[val];
+
+ if (!dir)
+ return;
+
+ var startColumn = dir === -1 ? stream.getCurrentTokenColumn() : session.getLine(row).length;
+ var startRow = row;
+
+ stream.step = dir === -1 ? stream.stepBackward : stream.stepForward;
+ while(token = stream.step()) {
+ if (token.type !== "keyword")
+ continue;
+ var level = dir * indentKeywords[token.value];
+
+ if (level > 0) {
+ stack.unshift(token.value);
+ } else if (level <= 0) {
+ stack.shift();
+ if (!stack.length && token.value != "elseif")
+ break;
+ if (level === 0)
+ stack.unshift(token.value);
+ }
+ }
+
+ var row = stream.getCurrentTokenRow();
+ if (dir === -1)
+ return new Range(row, session.getLine(row).length, startRow, startColumn);
+ else
+ return new Range(startRow, startColumn, row, stream.getCurrentTokenColumn());
+ };
+
+}).call(FoldMode.prototype);
+
+});