This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathace-mode-warpscript.ts
176 lines (160 loc) · 5.94 KB
/
ace-mode-warpscript.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import { Monarch } from './monarch'
declare var ace
export default function() {
if (!window['ace']) {
return
}
ace.define('ace/mode/warpscript_keywords', function(require, exports, module) {
const warpscriptConstants:String = Monarch.rules['constants'].join('|') + "|TRUE|true|FALSE|false";
const warpscriptFunctions:String = Monarch.rules['keywords'].join('|');
const warpscriptControl:String = Monarch.rules['control'].join('|');
const warpscriptFrameworkFunctions:String = Monarch.rules['functions'].join('|');
exports.KeywordMap = {
"constant.language": warpscriptConstants,
"keyword.control": warpscriptControl,
"keyword.other": warpscriptFrameworkFunctions,
"support.function": warpscriptFunctions
}
})
ace.define("ace/mode/warpscript_highlight_rules", ["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/warpscript_keywords"], function(require, exports, module) {
const oop = require("../lib/oop")
const TextHighlightRules = require("./text_highlight_rules").TextHighlightRules
const keywordMap = require("./warpscript_keywords").KeywordMap
const WarpScriptHighlightRules = function() {
this.keywordMapper = this.createKeywordMapper(keywordMap, "identifier", false)
this.$rules = {
start : [{
token: "comment",
regex: /(?:#|\/\/)(?:[^?]|\?[^>])*/,
}, {
token : "comment", // multi line comment
regex : "\\/\\*",
next : "comment"
},{
token : "string.quoted.single",
regex : /'[^']*'/
}, {
token : "constant.numeric",
regex : /[+-]?\d+(\.\d+)?([eE][+-]?\d+)?\b/
}, {
token: "support.variable",
regex: /\@[a-zA-Z0-9_$]*\b/
}, {
token : this.keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b",
caseInsensitive: false
}, {
token : "keyword.operator",
regex : /!=|!|%|&|&&|\*|\*\*|\+|\-|\/|<|<=|==|>|>=|\[|\]|\[\]|\^|\{\}|\{|\}|\||\|\||~=/
}, {
token : "paren.lparen",
regex : /[\[\{]/
}, {
token : "paren.rparen",
regex : /[\]\}]/
}, {
token : "text",
regex : /\s+/
}],
line_comment: [{
token : "comment",
regex : "$|^",
next : "start"
}, {
defaultToken : "comment",
caseInsensitive: true
}],
comment: [{
token : "comment",
regex : "\\*\\/",
next : "start"
}, {
defaultToken : "comment"
}]
}
}
oop.inherits(WarpScriptHighlightRules, TextHighlightRules)
exports.WarpScriptHighlightRules = WarpScriptHighlightRules
})
ace.define("ace/mode/warpscript_completions", ["require", "exports", "module", "ace/mode/warpscript_keywords"], function(require, exports, module) {
const keywordMap = require("./warpscript_keywords").KeywordMap
var keywordList = []
for (let key in keywordMap) {
keywordList = keywordList.concat(keywordMap[key].split(/\|/))
}
keywordList = keywordList.sort()
let WarpScriptCompletions = function() {};
(function() {
this.getCompletions = function(state, session, pos, prefix) {
var matchingWords = []
for (let word in keywordList) {
if (keywordList[word].search(prefix) > -1)
matchingWords.push(keywordList[word])
}
const matchingWordsObjects = matchingWords.map(function(value) {
return {
caption: value,
snippet: value,
meta: "WARPSCRIPT",
score: Number.MAX_VALUE
}
})
return matchingWordsObjects
}
}).call(WarpScriptCompletions.prototype)
exports.WarpScriptCompletions = WarpScriptCompletions
})
ace.define("ace/mode/warpscript", ["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/warpscript_highlight_rules","ace/range","ace/mode/warpscript_completions"], function(require, exports, module) {
const oop = require("../lib/oop")
const TextMode = require("./text").Mode
const WarpScriptHighlightRules = require("./warpscript_highlight_rules").WarpScriptHighlightRules
const WarpScriptCompletions = require("./warpscript_completions").WarpScriptCompletions
const Range = require("../range").Range
const Mode = function() {
this.HighlightRules = WarpScriptHighlightRules
this.$completer = new WarpScriptCompletions()
}
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "*"
this.$id = "ace/mode/warpscript"
this.getCompletions = function(state, session, pos, prefix) {
const completerResponse = this.$completer.getCompletions(state, session, pos, prefix)
return completerResponse
}
}).call(Mode.prototype)
exports.Mode = Mode
})
ace.define('ace/snippets/warpscript', ["require","exports","module"], function(require, exports, module) {
exports.scope = 'warpscript'
exports.snippets = [{
name: 'fetch',
content: "[ ${1:read_token} '${2:class}' { ${3} } \\$end \\$interval ] FETCH\n"
}, {
name: 'find',
content: "[ ${1:read_token} '${2:class}' { ${3} } ] FIND \n"
}, {
name: 'bucketize',
content: '[ SWAP bucketizer.${1:max} \\$end ${2:5 m} ${3:0} ] BUCKETIZE \n'
}, {
name: 'map',
content: "[ SWAP mapper.${1:max} ${2:0} ${3:0} ${4:0} ] MAP \n"
}, {
name: 'reduce',
content: "[ SWAP [ ${1:} ] reducer.${2:sum} ] REDUCE \n"
}, {
name: 'new gts',
content: "NEWGTS '${1:name}' RENAME { ${2:labels} } RELABEL \n"
}, {
name: 'lmap',
content: '<% ${1:DROP}\n${2:} \n%> LMAP'
}, {
name: 'ift',
content: '<% ${1:true} %>\n\t<% ${2:} %>\nIFT \n'
}, {
name: 'ifte',
content: '<% ${1:true} %>\n\t<% ${2:} %>\n\t<% ${3:} %>\nIFTE \n'
}]
})
return true
}