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