]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/arcade.js
Initial commit.
[flow-web.git] / static / highlight / languages / arcade.js
1 /*! `arcade` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: ArcGIS Arcade
8 Category: scripting
9 Website: https://developers.arcgis.com/arcade/
10 Description: ArcGIS Arcade is an expression language used in many Esri ArcGIS products such as Pro, Online, Server, Runtime, JavaScript, and Python
11 */
12
13 /** @type LanguageFn */
14 function arcade(hljs) {
15 const regex = hljs.regex;
16 const IDENT_RE = '[A-Za-z_][0-9A-Za-z_]*';
17 const KEYWORDS = {
18 keyword: [
19 "break",
20 "case",
21 "catch",
22 "continue",
23 "debugger",
24 "do",
25 "else",
26 "export",
27 "for",
28 "function",
29 "if",
30 "import",
31 "in",
32 "new",
33 "of",
34 "return",
35 "switch",
36 "try",
37 "var",
38 "void",
39 "while"
40 ],
41 literal: [
42 "BackSlash",
43 "DoubleQuote",
44 "ForwardSlash",
45 "Infinity",
46 "NaN",
47 "NewLine",
48 "PI",
49 "SingleQuote",
50 "Tab",
51 "TextFormatting",
52 "false",
53 "null",
54 "true",
55 "undefined"
56 ],
57 built_in: [
58 "Abs",
59 "Acos",
60 "All",
61 "Angle",
62 "Any",
63 "Area",
64 "AreaGeodetic",
65 "Array",
66 "Asin",
67 "Atan",
68 "Atan2",
69 "Attachments",
70 "Average",
71 "Back",
72 "Bearing",
73 "Boolean",
74 "Buffer",
75 "BufferGeodetic",
76 "Ceil",
77 "Centroid",
78 "ChangeTimeZone",
79 "Clip",
80 "Concatenate",
81 "Console",
82 "Constrain",
83 "Contains",
84 "ConvertDirection",
85 "ConvexHull",
86 "Cos",
87 "Count",
88 "Crosses",
89 "Cut",
90 "Date|0",
91 "DateAdd",
92 "DateDiff",
93 "DateOnly",
94 "Day",
95 "Decode",
96 "DefaultValue",
97 "Densify",
98 "DensifyGeodetic",
99 "Dictionary",
100 "Difference",
101 "Disjoint",
102 "Distance",
103 "DistanceGeodetic",
104 "DistanceToCoordinate",
105 "Distinct",
106 "Domain",
107 "DomainCode",
108 "DomainName",
109 "EnvelopeIntersects",
110 "Equals",
111 "Erase",
112 "Exp",
113 "Expects",
114 "Extent",
115 "Feature",
116 "FeatureInFilter",
117 "FeatureSet",
118 "FeatureSetByAssociation",
119 "FeatureSetById",
120 "FeatureSetByName",
121 "FeatureSetByPortalItem",
122 "FeatureSetByRelationshipClass",
123 "FeatureSetByRelationshipName",
124 "Filter",
125 "FilterBySubtypeCode",
126 "Find",
127 "First|0",
128 "Floor",
129 "FromCharCode",
130 "FromCodePoint",
131 "FromJSON",
132 "Front",
133 "GdbVersion",
134 "Generalize",
135 "Geometry",
136 "GetEnvironment",
137 "GetFeatureSet",
138 "GetFeatureSetInfo",
139 "GetUser",
140 "GroupBy",
141 "Guid",
142 "HasKey",
143 "HasValue",
144 "Hash",
145 "Hour",
146 "IIf",
147 "ISOMonth",
148 "ISOWeek",
149 "ISOWeekday",
150 "ISOYear",
151 "Includes",
152 "IndexOf",
153 "Insert",
154 "Intersection",
155 "Intersects",
156 "IsEmpty",
157 "IsNan",
158 "IsSelfIntersecting",
159 "IsSimple",
160 "KnowledgeGraphByPortalItem",
161 "Left|0",
162 "Length",
163 "Length3D",
164 "LengthGeodetic",
165 "Log",
166 "Lower",
167 "Map",
168 "Max",
169 "Mean",
170 "MeasureToCoordinate",
171 "Mid",
172 "Millisecond",
173 "Min",
174 "Minute",
175 "Month",
176 "MultiPartToSinglePart",
177 "Multipoint",
178 "NearestCoordinate",
179 "NearestVertex",
180 "NextSequenceValue",
181 "None",
182 "Now",
183 "Number",
184 "Offset",
185 "OrderBy",
186 "Overlaps",
187 "Point",
188 "PointToCoordinate",
189 "Polygon",
190 "Polyline",
191 "Pop",
192 "Portal",
193 "Pow",
194 "Proper",
195 "Push",
196 "QueryGraph",
197 "Random",
198 "Reduce",
199 "Relate",
200 "Replace",
201 "Resize",
202 "Reverse",
203 "Right|0",
204 "RingIsClockwise",
205 "Rotate",
206 "Round",
207 "Schema",
208 "Second",
209 "SetGeometry",
210 "Simplify",
211 "Sin",
212 "Slice",
213 "Sort",
214 "Splice",
215 "Split",
216 "Sqrt",
217 "StandardizeFilename",
218 "StandardizeGuid",
219 "Stdev",
220 "SubtypeCode",
221 "SubtypeName",
222 "Subtypes",
223 "Sum",
224 "SymmetricDifference",
225 "Tan",
226 "Text",
227 "Time",
228 "TimeZone",
229 "TimeZoneOffset",
230 "Timestamp",
231 "ToCharCode",
232 "ToCodePoint",
233 "ToHex",
234 "ToLocal",
235 "ToUTC",
236 "Today",
237 "Top|0",
238 "Touches",
239 "TrackAccelerationAt",
240 "TrackAccelerationWindow",
241 "TrackCurrentAcceleration",
242 "TrackCurrentDistance",
243 "TrackCurrentSpeed",
244 "TrackCurrentTime",
245 "TrackDistanceAt",
246 "TrackDistanceWindow",
247 "TrackDuration",
248 "TrackFieldWindow",
249 "TrackGeometryWindow",
250 "TrackIndex",
251 "TrackSpeedAt",
252 "TrackSpeedWindow",
253 "TrackStartTime",
254 "TrackWindow",
255 "Trim",
256 "TypeOf",
257 "Union",
258 "Upper",
259 "UrlEncode",
260 "Variance",
261 "Week",
262 "Weekday",
263 "When|0",
264 "Within",
265 "Year|0",
266 ]
267 };
268 const PROFILE_VARS = [
269 "aggregatedFeatures",
270 "analytic",
271 "config",
272 "datapoint",
273 "datastore",
274 "editcontext",
275 "feature",
276 "featureSet",
277 "feedfeature",
278 "fencefeature",
279 "fencenotificationtype",
280 "graph",
281 "join",
282 "layer",
283 "locationupdate",
284 "map",
285 "measure",
286 "measure",
287 "originalFeature",
288 "record",
289 "reference",
290 "rowindex",
291 "sourcedatastore",
292 "sourcefeature",
293 "sourcelayer",
294 "target",
295 "targetdatastore",
296 "targetfeature",
297 "targetlayer",
298 "userInput",
299 "value",
300 "variables",
301 "view"
302 ];
303 const SYMBOL = {
304 className: 'symbol',
305 begin: '\\$' + regex.either(...PROFILE_VARS)
306 };
307 const NUMBER = {
308 className: 'number',
309 variants: [
310 { begin: '\\b(0[bB][01]+)' },
311 { begin: '\\b(0[oO][0-7]+)' },
312 { begin: hljs.C_NUMBER_RE }
313 ],
314 relevance: 0
315 };
316 const SUBST = {
317 className: 'subst',
318 begin: '\\$\\{',
319 end: '\\}',
320 keywords: KEYWORDS,
321 contains: [] // defined later
322 };
323 const TEMPLATE_STRING = {
324 className: 'string',
325 begin: '`',
326 end: '`',
327 contains: [
328 hljs.BACKSLASH_ESCAPE,
329 SUBST
330 ]
331 };
332 SUBST.contains = [
333 hljs.APOS_STRING_MODE,
334 hljs.QUOTE_STRING_MODE,
335 TEMPLATE_STRING,
336 NUMBER,
337 hljs.REGEXP_MODE
338 ];
339 const PARAMS_CONTAINS = SUBST.contains.concat([
340 hljs.C_BLOCK_COMMENT_MODE,
341 hljs.C_LINE_COMMENT_MODE
342 ]);
343
344 return {
345 name: 'ArcGIS Arcade',
346 case_insensitive: true,
347 keywords: KEYWORDS,
348 contains: [
349 hljs.APOS_STRING_MODE,
350 hljs.QUOTE_STRING_MODE,
351 TEMPLATE_STRING,
352 hljs.C_LINE_COMMENT_MODE,
353 hljs.C_BLOCK_COMMENT_MODE,
354 SYMBOL,
355 NUMBER,
356 { // object attr container
357 begin: /[{,]\s*/,
358 relevance: 0,
359 contains: [
360 {
361 begin: IDENT_RE + '\\s*:',
362 returnBegin: true,
363 relevance: 0,
364 contains: [
365 {
366 className: 'attr',
367 begin: IDENT_RE,
368 relevance: 0
369 }
370 ]
371 }
372 ]
373 },
374 { // "value" container
375 begin: '(' + hljs.RE_STARTERS_RE + '|\\b(return)\\b)\\s*',
376 keywords: 'return',
377 contains: [
378 hljs.C_LINE_COMMENT_MODE,
379 hljs.C_BLOCK_COMMENT_MODE,
380 hljs.REGEXP_MODE,
381 {
382 className: 'function',
383 begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>',
384 returnBegin: true,
385 end: '\\s*=>',
386 contains: [
387 {
388 className: 'params',
389 variants: [
390 { begin: IDENT_RE },
391 { begin: /\(\s*\)/ },
392 {
393 begin: /\(/,
394 end: /\)/,
395 excludeBegin: true,
396 excludeEnd: true,
397 keywords: KEYWORDS,
398 contains: PARAMS_CONTAINS
399 }
400 ]
401 }
402 ]
403 }
404 ],
405 relevance: 0
406 },
407 {
408 beginKeywords: 'function',
409 end: /\{/,
410 excludeEnd: true,
411 contains: [
412 hljs.inherit(hljs.TITLE_MODE, {
413 className: "title.function",
414 begin: IDENT_RE
415 }),
416 {
417 className: 'params',
418 begin: /\(/,
419 end: /\)/,
420 excludeBegin: true,
421 excludeEnd: true,
422 contains: PARAMS_CONTAINS
423 }
424 ],
425 illegal: /\[|%/
426 },
427 { begin: /\$[(.]/ }
428 ],
429 illegal: /#(?!!)/
430 };
431 }
432
433 return arcade;
434
435 })();
436
437 hljs.registerLanguage('arcade', hljsGrammar);
438 })();