Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/prql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){// https://prql-lang.org/
2 "use strict";
3 var oop = require("../lib/oop");
4 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
5 var PrqlHighlightRules = function () {
6 var builtinFunctions = "min|max|sum|average|stddev|every|any|concat_array|count|" +
7 "lag|lead|first|last|rank|rank_dense|row_number|" +
8 "round|as|in|" +
9 "tuple_every|tuple_map|tuple_zip|_eq|_is_null|" +
10 "from_text|" +
11 "lower|upper|" +
12 "read_parquet|read_csv";
13 var builtinTypes = [
14 "bool",
15 "int",
16 "int8",
17 "int16",
18 "int32",
19 "int64",
20 "int128",
21 "float",
22 "text",
23 "timestamp",
24 "set"
25 ].join("|");
26 var keywordMapper = this.createKeywordMapper({
27 "constant.language": "null",
28 "constant.language.boolean": "true|false",
29 "keyword": "let|into|case|prql|type|module|internal",
30 "storage.type": "let|func",
31 "support.function": builtinFunctions,
32 "support.type": builtinTypes,
33 "variable.language": "date|math"
34 }, "identifier");
35 var escapeRe = /\\(\d+|['"\\&bfnrt]|u\{[0-9a-fA-F]{1,6}\}|x[0-9a-fA-F]{2})/;
36 var identifierRe = /[A-Za-z_][a-z_A-Z0-9]/.source;
37 var numRe = /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/.source;
38 var bidi = "[\\u202A\\u202B\\u202D\\u202E\\u2066\\u2067\\u2068\\u202C\\u2069]";
39 this.$rules = {
40 start: [
41 {
42 token: "string.start",
43 regex: 's?"',
44 next: "string"
45 }, {
46 token: "string.start",
47 regex: 'f"',
48 next: "fstring"
49 }, {
50 token: "string.start",
51 regex: 'r"',
52 next: "rstring"
53 }, {
54 token: "string.single",
55 start: "'",
56 end: "'"
57 }, {
58 token: "string.character",
59 regex: "'(?:" + escapeRe.source + "|.)'?"
60 }, {
61 token: "constant.language",
62 regex: "^" + identifierRe + "*"
63 }, {
64 token: ["constant.numeric", "keyword"],
65 regex: "(" + numRe + ")(years|months|weeks|days|hours|minutes|seconds|milliseconds|microseconds)"
66 }, {
67 token: "constant.numeric", // hexadecimal, octal and binary
68 regex: /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
69 }, {
70 token: "constant.numeric", // decimal integers and floats
71 regex: numRe
72 }, {
73 token: "comment.block.documentation",
74 regex: "#!.*"
75 }, {
76 token: "comment.line.number-sign",
77 regex: "#.*"
78 }, {
79 token: "keyword.operator",
80 regex: /\|\s*/,
81 next: "pipe"
82 }, {
83 token: "keyword.operator",
84 regex: /->|=>|==|!=|>=|<=|~=|&&|\|\||\?\?|\/\/|@/
85 }, {
86 token: "invalid.illegal",
87 regex: bidi
88 }, {
89 token: "punctuation.operator",
90 regex: /[,`]/
91 }, {
92 token: keywordMapper,
93 regex: "[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b"
94 }, {
95 token: "paren.lparen",
96 regex: /[\[({]/
97 }, {
98 token: "paren.rparen",
99 regex: /[\])}]/
100 }
101 ],
102 pipe: [{
103 token: "constant.language",
104 regex: identifierRe + "*",
105 next: "pop"
106 }, {
107 token: "error",
108 regex: "",
109 next: "pop"
110 }],
111 string: [{
112 token: "constant.character.escape",
113 regex: escapeRe
114 }, {
115 token: "text",
116 regex: /\\(\s|$)/,
117 next: "stringGap"
118 }, {
119 token: "string.end",
120 regex: '"',
121 next: "start"
122 }, {
123 token: "invalid.illegal",
124 regex: bidi
125 }, {
126 defaultToken: "string.double"
127 }],
128 stringGap: [{
129 token: "text",
130 regex: /\\/,
131 next: "string"
132 }, {
133 token: "error",
134 regex: "",
135 next: "start"
136 }],
137 fstring: [{
138 token: "constant.character.escape",
139 regex: escapeRe
140 }, {
141 token: "string.end",
142 regex: '"',
143 next: "start"
144 }, {
145 token: "invalid.illegal",
146 regex: bidi
147 }, {
148 token: "paren.lparen",
149 regex: "{",
150 push: "fstringParenRules"
151 }, {
152 token: "invalid.illegal",
153 regex: bidi
154 }, {
155 defaultToken: "string"
156 }],
157 fstringParenRules: [{
158 token: "constant.language",
159 regex: "^" + identifierRe + "*"
160 }, {
161 token: "paren.rparen",
162 regex: "}",
163 next: "pop"
164 }],
165 rstring: [{
166 token: "string.end",
167 regex: '"',
168 next: "start"
169 }, {
170 token: "invalid.illegal",
171 regex: bidi
172 }, {
173 defaultToken: "string"
174 }]
175 };
176 this.normalizeRules();
177 };
178 oop.inherits(PrqlHighlightRules, TextHighlightRules);
179 exports.PrqlHighlightRules = PrqlHighlightRules;
180
181 });
182
183 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";
184 var oop = require("../../lib/oop");
185 var Range = require("../../range").Range;
186 var BaseFoldMode = require("./fold_mode").FoldMode;
187 var FoldMode = exports.FoldMode = function (commentRegex) {
188 if (commentRegex) {
189 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
190 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
191 }
192 };
193 oop.inherits(FoldMode, BaseFoldMode);
194 (function () {
195 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
196 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
197 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
198 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
199 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
200 this._getFoldWidgetBase = this.getFoldWidget;
201 this.getFoldWidget = function (session, foldStyle, row) {
202 var line = session.getLine(row);
203 if (this.singleLineBlockCommentRe.test(line)) {
204 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
205 return "";
206 }
207 var fw = this._getFoldWidgetBase(session, foldStyle, row);
208 if (!fw && this.startRegionRe.test(line))
209 return "start"; // lineCommentRegionStart
210 return fw;
211 };
212 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
213 var line = session.getLine(row);
214 if (this.startRegionRe.test(line))
215 return this.getCommentRegionBlock(session, line, row);
216 var match = line.match(this.foldingStartMarker);
217 if (match) {
218 var i = match.index;
219 if (match[1])
220 return this.openingBracketBlock(session, match[1], row, i);
221 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
222 if (range && !range.isMultiLine()) {
223 if (forceMultiline) {
224 range = this.getSectionRange(session, row);
225 }
226 else if (foldStyle != "all")
227 range = null;
228 }
229 return range;
230 }
231 if (foldStyle === "markbegin")
232 return;
233 var match = line.match(this.foldingStopMarker);
234 if (match) {
235 var i = match.index + match[0].length;
236 if (match[1])
237 return this.closingBracketBlock(session, match[1], row, i);
238 return session.getCommentFoldRange(row, i, -1);
239 }
240 };
241 this.getSectionRange = function (session, row) {
242 var line = session.getLine(row);
243 var startIndent = line.search(/\S/);
244 var startRow = row;
245 var startColumn = line.length;
246 row = row + 1;
247 var endRow = row;
248 var maxRow = session.getLength();
249 while (++row < maxRow) {
250 line = session.getLine(row);
251 var indent = line.search(/\S/);
252 if (indent === -1)
253 continue;
254 if (startIndent > indent)
255 break;
256 var subRange = this.getFoldWidgetRange(session, "all", row);
257 if (subRange) {
258 if (subRange.start.row <= startRow) {
259 break;
260 }
261 else if (subRange.isMultiLine()) {
262 row = subRange.end.row;
263 }
264 else if (startIndent == indent) {
265 break;
266 }
267 }
268 endRow = row;
269 }
270 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
271 };
272 this.getCommentRegionBlock = function (session, line, row) {
273 var startColumn = line.search(/\s*$/);
274 var maxRow = session.getLength();
275 var startRow = row;
276 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
277 var depth = 1;
278 while (++row < maxRow) {
279 line = session.getLine(row);
280 var m = re.exec(line);
281 if (!m)
282 continue;
283 if (m[1])
284 depth--;
285 else
286 depth++;
287 if (!depth)
288 break;
289 }
290 var endRow = row;
291 if (endRow > startRow) {
292 return new Range(startRow, startColumn, endRow, line.length);
293 }
294 };
295 }).call(FoldMode.prototype);
296
297 });
298
299 ace.define("ace/mode/prql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/prql_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
300 var oop = require("../lib/oop");
301 var TextMode = require("./text").Mode;
302 var HighlightRules = require("./prql_highlight_rules").PrqlHighlightRules;
303 var FoldMode = require("./folding/cstyle").FoldMode;
304 var Mode = function () {
305 this.HighlightRules = HighlightRules;
306 this.foldingRules = new FoldMode();
307 this.$behaviour = this.$defaultBehaviour;
308 };
309 oop.inherits(Mode, TextMode);
310 (function () {
311 this.lineCommentStart = "#";
312 this.$id = "ace/mode/prql";
313 }).call(Mode.prototype);
314 exports.Mode = Mode;
315
316 }); (function() {
317 ace.require(["ace/mode/prql"], function(m) {
318 if (typeof module == "object" && typeof exports == "object" && module) {
319 module.exports = m;
320 }
321 });
322 })();
323