123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582 |
- ace.define("ace/mode/crystal_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 CrystalHighlightRules = function () {
- var builtinFunctions = ("puts|initialize|previous_def|typeof|as|pointerof|sizeof|instance_sizeof");
- var keywords = ("if|end|else|elsif|unless|case|when|break|while|next|until|def|return|class|new|getter|setter|property|lib"
- + "|fun|do|struct|private|protected|public|module|super|abstract|include|extend|begin|enum|raise|yield|with"
- + "|alias|rescue|ensure|macro|uninitialized|union|type|require");
- var buildinConstants = ("true|TRUE|false|FALSE|nil|NIL|__LINE__|__END_LINE__|__FILE__|__DIR__");
- var builtinVariables = ("$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE|" +
- "root_url|flash|session|cookies|params|request|response|logger|self");
- var keywordMapper = this.$keywords = this.createKeywordMapper({
- "keyword": keywords,
- "constant.language": buildinConstants,
- "variable.language": builtinVariables,
- "support.function": builtinFunctions
- }, "identifier");
- var hexNumber = "(?:0[xX][\\dA-Fa-f]+)";
- var decNumber = "(?:[0-9][\\d_]*)";
- var octNumber = "(?:0o[0-7][0-7]*)";
- var binNumber = "(?:0[bB][01]+)";
- var intNumber = "(?:[+-]?)(?:" + hexNumber + "|" + decNumber + "|" + octNumber + "|" + binNumber + ")(?:_?[iIuU](?:8|16|32|64))?\\b";
- var escapeExpression = /\\(?:[nsrtvfbae'"\\]|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u{[\da-fA-F]{1,6}})/;
- var extEscapeExspresssion = /\\(?:[nsrtvfbae'"\\]|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u{[\da-fA-F]{1,6}}|u{(:?[\da-fA-F]{2}\s)*[\da-fA-F]{2}})/;
- this.$rules = {
- "start": [
- {
- token: "comment",
- regex: "#.*$"
- }, {
- token: "string.regexp",
- regex: "[/]",
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.regexp",
- regex: "[/][imx]*(?=[).,;\\s]|$)",
- next: "pop"
- }, {
- defaultToken: "string.regexp"
- }]
- },
- [{
- regex: "[{}]", onMatch: function (val, state, stack) {
- this.next = val == "{" ? this.nextState : "";
- if (val == "{" && stack.length) {
- stack.unshift("start", state);
- return "paren.lparen";
- }
- if (val == "}" && stack.length) {
- stack.shift();
- this.next = stack.shift();
- if (this.next.indexOf("string") != -1)
- return "paren.end";
- }
- return val == "{" ? "paren.lparen" : "paren.rparen";
- },
- nextState: "start"
- }, {
- token: "string.start",
- regex: /"/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string",
- regex: /\\#{/
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- token: "string.end",
- regex: /"/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- token: "string.start",
- regex: /`/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string",
- regex: /\\#{/
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- token: "string.end",
- regex: /`/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "rpstring",
- token: "string.start",
- regex: /%[Qx]?\(/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.start",
- regex: /\(/,
- push: "rpstring"
- }, {
- token: "string.end",
- regex: /\)/,
- next: "pop"
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "spstring",
- token: "string.start",
- regex: /%[Qx]?\[/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.start",
- regex: /\[/,
- push: "spstring"
- }, {
- token: "string.end",
- regex: /]/,
- next: "pop"
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "fpstring",
- token: "string.start",
- regex: /%[Qx]?{/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.start",
- regex: /{/,
- push: "fpstring"
- }, {
- token: "string.end",
- regex: /}/,
- next: "pop"
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "tpstring",
- token: "string.start",
- regex: /%[Qx]?</,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.start",
- regex: /</,
- push: "tpstring"
- }, {
- token: "string.end",
- regex: />/,
- next: "pop"
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "ppstring",
- token: "string.start",
- regex: /%[Qx]?\|/,
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "string.end",
- regex: /\|/,
- next: "pop"
- }, {
- token: "paren.start",
- regex: /#{/,
- push: "start"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "rpqstring",
- token: "string.start",
- regex: /%[qwir]\(/,
- push: [{
- token: "string.start",
- regex: /\(/,
- push: "rpqstring"
- }, {
- token: "string.end",
- regex: /\)/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "spqstring",
- token: "string.start",
- regex: /%[qwir]\[/,
- push: [{
- token: "string.start",
- regex: /\[/,
- push: "spqstring"
- }, {
- token: "string.end",
- regex: /]/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "fpqstring",
- token: "string.start",
- regex: /%[qwir]{/,
- push: [{
- token: "string.start",
- regex: /{/,
- push: "fpqstring"
- }, {
- token: "string.end",
- regex: /}/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "tpqstring",
- token: "string.start",
- regex: /%[qwir]</,
- push: [{
- token: "string.start",
- regex: /</,
- push: "tpqstring"
- }, {
- token: "string.end",
- regex: />/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- stateName: "ppqstring",
- token: "string.start",
- regex: /%[qwir]\|/,
- push: [{
- token: "string.end",
- regex: /\|/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }, {
- token: "string.start",
- regex: /'/,
- push: [{
- token: "constant.language.escape",
- regex: escapeExpression
- }, {
- token: "string.end",
- regex: /'|$/,
- next: "pop"
- }, {
- defaultToken: "string"
- }]
- }], {
- token: "text",
- regex: "::"
- }, {
- token: "variable.instance",
- regex: "@{1,2}[a-zA-Z_\\d]+"
- }, {
- token: "variable.fresh",
- regex: "%[a-zA-Z_\\d]+"
- }, {
- token: "support.class",
- regex: "[A-Z][a-zA-Z_\\d]+"
- }, {
- token: "constant.other.symbol",
- regex: "[:](?:(?:===|<=>|\\[]\\?|\\[]=|\\[]|>>|\\*\\*|<<|==|!=|>=|<=|!~|=~|<|\\+|-|\\*|\\/|%|&|\\||\\^|>|!|~)|(?:(?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?))"
- }, {
- token: "constant.numeric",
- regex: "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?(?:_?[fF](?:32|64))?\\b"
- }, {
- token: "constant.numeric",
- regex: intNumber
- }, {
- token: "constant.other.symbol",
- regex: ':"',
- push: [{
- token: "constant.language.escape",
- regex: extEscapeExspresssion
- }, {
- token: "constant.other.symbol",
- regex: '"',
- next: "pop"
- }, {
- defaultToken: "constant.other.symbol"
- }]
- }, {
- token: "constant.language.boolean",
- regex: "(?:true|false)\\b"
- }, {
- token: "support.function",
- regex: "(?:is_a\\?|nil\\?|responds_to\\?|as\\?)"
- }, {
- token: keywordMapper,
- regex: "[a-zA-Z_$][a-zA-Z0-9_$!?]*\\b"
- }, {
- token: "variable.system",
- regex: "\\$\\!|\\$\\?"
- }, {
- token: "punctuation.separator.key-value",
- regex: "=>"
- }, {
- stateName: "heredoc",
- onMatch: function (value, currentState, stack) {
- var next = "heredoc";
- var tokens = value.split(this.splitRegex);
- stack.push(next, tokens[3]);
- return [
- { type: "constant", value: tokens[1] },
- { type: "string", value: tokens[2] },
- { type: "support.class", value: tokens[3] },
- { type: "string", value: tokens[4] }
- ];
- },
- regex: "(<<-)([']?)([\\w]+)([']?)",
- rules: {
- heredoc: [{
- token: "string",
- regex: "^ +"
- }, {
- onMatch: function (value, currentState, stack) {
- if (value === stack[1]) {
- stack.shift();
- stack.shift();
- this.next = stack[0] || "start";
- return "support.class";
- }
- this.next = "";
- return "string";
- },
- regex: ".*$",
- next: "start"
- }]
- }
- }, {
- regex: "$",
- token: "empty",
- next: function (currentState, stack) {
- if (stack[0] === "heredoc")
- return stack[0];
- return currentState;
- }
- }, {
- token: "punctuation.operator",
- regex: /[.]\s*(?![.])/,
- push: [{
- token: "punctuation.operator",
- regex: /[.]\s*(?![.])/
- }, {
- token: "support.function",
- regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
- }, {
- regex: "",
- token: "empty",
- next: "pop"
- }]
- }, {
- token: "keyword.operator",
- regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|\\?|\\:|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\^|\\|"
- }, {
- token: "punctuation.operator",
- regex: /[?:,;.]/
- }, {
- token: "paren.lparen",
- regex: "[[({]"
- }, {
- token: "paren.rparen",
- regex: "[\\])}]"
- }, {
- token: "text",
- regex: "\\s+"
- }
- ]
- };
- this.normalizeRules();
- };
- oop.inherits(CrystalHighlightRules, TextHighlightRules);
- exports.CrystalHighlightRules = CrystalHighlightRules;
- });
- ace.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) {
- return line.match(/^\s*/)[0];
- };
- }).call(MatchingBraceOutdent.prototype);
- exports.MatchingBraceOutdent = MatchingBraceOutdent;
- });
- ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
- var oop = require("../../lib/oop");
- var BaseFoldMode = require("./fold_mode").FoldMode;
- var Range = require("../../range").Range;
- var FoldMode = exports.FoldMode = function () { };
- oop.inherits(FoldMode, BaseFoldMode);
- (function () {
- this.getFoldWidgetRange = function (session, foldStyle, row) {
- var range = this.indentationBlock(session, row);
- if (range)
- return range;
- var re = /\S/;
- var line = session.getLine(row);
- var startLevel = line.search(re);
- if (startLevel == -1 || line[startLevel] != "#")
- return;
- var startColumn = line.length;
- var maxRow = session.getLength();
- var startRow = row;
- var endRow = row;
- while (++row < maxRow) {
- line = session.getLine(row);
- var level = line.search(re);
- if (level == -1)
- continue;
- if (line[level] != "#")
- break;
- endRow = row;
- }
- if (endRow > startRow) {
- var endColumn = session.getLine(endRow).length;
- return new Range(startRow, startColumn, endRow, endColumn);
- }
- };
- this.getFoldWidget = function (session, foldStyle, row) {
- var line = session.getLine(row);
- var indent = line.search(/\S/);
- var next = session.getLine(row + 1);
- var prev = session.getLine(row - 1);
- var prevIndent = prev.search(/\S/);
- var nextIndent = next.search(/\S/);
- if (indent == -1) {
- session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
- return "";
- }
- if (prevIndent == -1) {
- if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
- session.foldWidgets[row - 1] = "";
- session.foldWidgets[row + 1] = "";
- return "start";
- }
- }
- else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
- if (session.getLine(row - 2).search(/\S/) == -1) {
- session.foldWidgets[row - 1] = "start";
- session.foldWidgets[row + 1] = "";
- return "";
- }
- }
- if (prevIndent != -1 && prevIndent < indent)
- session.foldWidgets[row - 1] = "start";
- else
- session.foldWidgets[row - 1] = "";
- if (indent < nextIndent)
- return "start";
- else
- return "";
- };
- }).call(FoldMode.prototype);
- });
- ace.define("ace/mode/crystal",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/crystal_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module){"use strict";
- var oop = require("../lib/oop");
- var TextMode = require("./text").Mode;
- var CrystalHighlightRules = require("./crystal_highlight_rules").CrystalHighlightRules;
- var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
- var Range = require("../range").Range;
- var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
- var FoldMode = require("./folding/coffee").FoldMode;
- var Mode = function () {
- this.HighlightRules = CrystalHighlightRules;
- this.$outdent = new MatchingBraceOutdent();
- this.$behaviour = new CstyleBehaviour();
- this.foldingRules = new FoldMode();
- };
- oop.inherits(Mode, TextMode);
- (function () {
- this.lineCommentStart = "#";
- this.getNextLineIndent = function (state, line, tab) {
- var indent = this.$getIndent(line);
- var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
- var tokens = tokenizedLine.tokens;
- if (tokens.length && tokens[tokens.length - 1].type == "comment") {
- return indent;
- }
- if (state == "start") {
- var match = line.match(/^.*[\{\(\[]\s*$/);
- var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/);
- var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/);
- var startingConditional = line.match(/^\s*(if|else|when)\s*/);
- if (match || startingClassOrMethod || startingDoBlock || startingConditional) {
- indent += tab;
- }
- }
- return indent;
- };
- this.checkOutdent = function (state, line, input) {
- return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
- };
- this.autoOutdent = function (state, session, row) {
- var line = session.getLine(row);
- if (/}/.test(line))
- return this.$outdent.autoOutdent(session, row);
- var indent = this.$getIndent(line);
- var prevLine = session.getLine(row - 1);
- var prevIndent = this.$getIndent(prevLine);
- var tab = session.getTabString();
- if (prevIndent.length <= indent.length) {
- if (indent.slice(-tab.length) == tab)
- session.remove(new Range(row, indent.length - tab.length, row, indent.length));
- }
- };
- this.$id = "ace/mode/crystal";
- }).call(Mode.prototype);
- exports.Mode = Mode;
- }); (function() {
- ace.require(["ace/mode/crystal"], function(m) {
- if (typeof module == "object" && typeof exports == "object" && module) {
- module.exports = m;
- }
- });
- })();
-
|