Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-elm.js

raw symbols SCIP
1 ace.define("ace/mode/elm_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){// TODO check with https://github.com/deadfoxygrandpa/Elm.tmLanguage
2 "use strict";
3 var oop = require("../lib/oop");
4 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
5 var ElmHighlightRules = function () {
6 var keywordMapper = this.createKeywordMapper({
7 "keyword": "as|case|class|data|default|deriving|do|else|export|foreign|" +
8 "hiding|jsevent|if|import|in|infix|infixl|infixr|instance|let|" +
9 "module|newtype|of|open|then|type|where|_|port|\u03BB"
10 }, "identifier");
11 var escapeRe = /\\(\d+|['"\\&trnbvf])/;
12 var smallRe = /[a-z_]/.source;
13 var largeRe = /[A-Z]/.source;
14 var idRe = /[a-z_A-Z0-9']/.source;
15 this.$rules = {
16 start: [{
17 token: "string.start",
18 regex: '"',
19 next: "string"
20 }, {
21 token: "string.character",
22 regex: "'(?:" + escapeRe.source + "|.)'?"
23 }, {
24 regex: /0(?:[xX][0-9A-Fa-f]+|[oO][0-7]+)|\d+(\.\d+)?([eE][-+]?\d*)?/,
25 token: "constant.numeric"
26 }, {
27 token: "comment",
28 regex: "--.*"
29 }, {
30 token: "keyword",
31 regex: /\.\.|\||:|=|\\|"|->|<-|\u2192/
32 }, {
33 token: "keyword.operator",
34 regex: /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]+/
35 }, {
36 token: "operator.punctuation",
37 regex: /[,;`]/
38 }, {
39 regex: largeRe + idRe + "+\\.?",
40 token: function (value) {
41 if (value[value.length - 1] == ".")
42 return "entity.name.function";
43 return "constant.language";
44 }
45 }, {
46 regex: "^" + smallRe + idRe + "+",
47 token: function (value) {
48 return "constant.language";
49 }
50 }, {
51 token: keywordMapper,
52 regex: "[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b"
53 }, {
54 regex: "{-#?",
55 token: "comment.start",
56 onMatch: function (value, currentState, stack) {
57 this.next = value.length == 2 ? "blockComment" : "docComment";
58 return this.token;
59 }
60 }, {
61 token: "variable.language",
62 regex: /\[markdown\|/,
63 next: "markdown"
64 }, {
65 token: "paren.lparen",
66 regex: /[\[({]/
67 }, {
68 token: "paren.rparen",
69 regex: /[\])}]/
70 }],
71 markdown: [{
72 regex: /\|\]/,
73 next: "start"
74 }, {
75 defaultToken: "string"
76 }],
77 blockComment: [{
78 regex: "{-",
79 token: "comment.start",
80 push: "blockComment"
81 }, {
82 regex: "-}",
83 token: "comment.end",
84 next: "pop"
85 }, {
86 defaultToken: "comment"
87 }],
88 docComment: [{
89 regex: "{-",
90 token: "comment.start",
91 push: "docComment"
92 }, {
93 regex: "-}",
94 token: "comment.end",
95 next: "pop"
96 }, {
97 defaultToken: "doc.comment"
98 }],
99 string: [{
100 token: "constant.language.escape",
101 regex: escapeRe
102 }, {
103 token: "text",
104 regex: /\\(\s|$)/,
105 next: "stringGap"
106 }, {
107 token: "string.end",
108 regex: '"',
109 next: "start"
110 }, {
111 defaultToken: "string"
112 }],
113 stringGap: [{
114 token: "text",
115 regex: /\\/,
116 next: "string"
117 }, {
118 token: "error",
119 regex: "",
120 next: "start"
121 }]
122 };
123 this.normalizeRules();
124 };
125 oop.inherits(ElmHighlightRules, TextHighlightRules);
126 exports.ElmHighlightRules = ElmHighlightRules;
127
128 });
129
130 ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
131 var oop = require("../../lib/oop");
132 var Range = require("../../range").Range;
133 var BaseFoldMode = require("./fold_mode").FoldMode;
134 var FoldMode = exports.FoldMode = function (commentRegex) {
135 if (commentRegex) {
136 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
137 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
138 }
139 };
140 oop.inherits(FoldMode, BaseFoldMode);
141 (function () {
142 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
143 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
144 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
145 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
146 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
147 this._getFoldWidgetBase = this.getFoldWidget;
148 this.getFoldWidget = function (session, foldStyle, row) {
149 var line = session.getLine(row);
150 if (this.singleLineBlockCommentRe.test(line)) {
151 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
152 return "";
153 }
154 var fw = this._getFoldWidgetBase(session, foldStyle, row);
155 if (!fw && this.startRegionRe.test(line))
156 return "start"; // lineCommentRegionStart
157 return fw;
158 };
159 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
160 var line = session.getLine(row);
161 if (this.startRegionRe.test(line))
162 return this.getCommentRegionBlock(session, line, row);
163 var match = line.match(this.foldingStartMarker);
164 if (match) {
165 var i = match.index;
166 if (match[1])
167 return this.openingBracketBlock(session, match[1], row, i);
168 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
169 if (range && !range.isMultiLine()) {
170 if (forceMultiline) {
171 range = this.getSectionRange(session, row);
172 }
173 else if (foldStyle != "all")
174 range = null;
175 }
176 return range;
177 }
178 if (foldStyle === "markbegin")
179 return;
180 var match = line.match(this.foldingStopMarker);
181 if (match) {
182 var i = match.index + match[0].length;
183 if (match[1])
184 return this.closingBracketBlock(session, match[1], row, i);
185 return session.getCommentFoldRange(row, i, -1);
186 }
187 };
188 this.getSectionRange = function (session, row) {
189 var line = session.getLine(row);
190 var startIndent = line.search(/\S/);
191 var startRow = row;
192 var startColumn = line.length;
193 row = row + 1;
194 var endRow = row;
195 var maxRow = session.getLength();
196 while (++row < maxRow) {
197 line = session.getLine(row);
198 var indent = line.search(/\S/);
199 if (indent === -1)
200 continue;
201 if (startIndent > indent)
202 break;
203 var subRange = this.getFoldWidgetRange(session, "all", row);
204 if (subRange) {
205 if (subRange.start.row <= startRow) {
206 break;
207 }
208 else if (subRange.isMultiLine()) {
209 row = subRange.end.row;
210 }
211 else if (startIndent == indent) {
212 break;
213 }
214 }
215 endRow = row;
216 }
217 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
218 };
219 this.getCommentRegionBlock = function (session, line, row) {
220 var startColumn = line.search(/\s*$/);
221 var maxRow = session.getLength();
222 var startRow = row;
223 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
224 var depth = 1;
225 while (++row < maxRow) {
226 line = session.getLine(row);
227 var m = re.exec(line);
228 if (!m)
229 continue;
230 if (m[1])
231 depth--;
232 else
233 depth++;
234 if (!depth)
235 break;
236 }
237 var endRow = row;
238 if (endRow > startRow) {
239 return new Range(startRow, startColumn, endRow, line.length);
240 }
241 };
242 }).call(FoldMode.prototype);
243
244 });
245
246 ace.define("ace/mode/elm",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/elm_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
247 THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
248 */
249 "use strict";
250 var oop = require("../lib/oop");
251 var TextMode = require("./text").Mode;
252 var HighlightRules = require("./elm_highlight_rules").ElmHighlightRules;
253 var FoldMode = require("./folding/cstyle").FoldMode;
254 var Mode = function () {
255 this.HighlightRules = HighlightRules;
256 this.foldingRules = new FoldMode();
257 this.$behaviour = this.$defaultBehaviour;
258 };
259 oop.inherits(Mode, TextMode);
260 (function () {
261 this.lineCommentStart = "--";
262 this.blockComment = { start: "{-", end: "-}", nestable: true };
263 this.$id = "ace/mode/elm";
264 }).call(Mode.prototype);
265 exports.Mode = Mode;
266
267 }); (function() {
268 ace.require(["ace/mode/elm"], function(m) {
269 if (typeof module == "object" && typeof exports == "object" && module) {
270 module.exports = m;
271 }
272 });
273 })();
274