]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/processing.js
Initial commit.
[flow-web.git] / static / highlight / languages / processing.js
1 /*! `processing` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Processing
8 Description: Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts.
9 Author: Erik Paluka <erik.paluka@gmail.com>
10 Website: https://processing.org
11 Category: graphics
12 */
13
14 function processing(hljs) {
15 const regex = hljs.regex;
16 const BUILT_INS = [
17 "displayHeight",
18 "displayWidth",
19 "mouseY",
20 "mouseX",
21 "mousePressed",
22 "pmouseX",
23 "pmouseY",
24 "key",
25 "keyCode",
26 "pixels",
27 "focused",
28 "frameCount",
29 "frameRate",
30 "height",
31 "width",
32 "size",
33 "createGraphics",
34 "beginDraw",
35 "createShape",
36 "loadShape",
37 "PShape",
38 "arc",
39 "ellipse",
40 "line",
41 "point",
42 "quad",
43 "rect",
44 "triangle",
45 "bezier",
46 "bezierDetail",
47 "bezierPoint",
48 "bezierTangent",
49 "curve",
50 "curveDetail",
51 "curvePoint",
52 "curveTangent",
53 "curveTightness",
54 "shape",
55 "shapeMode",
56 "beginContour",
57 "beginShape",
58 "bezierVertex",
59 "curveVertex",
60 "endContour",
61 "endShape",
62 "quadraticVertex",
63 "vertex",
64 "ellipseMode",
65 "noSmooth",
66 "rectMode",
67 "smooth",
68 "strokeCap",
69 "strokeJoin",
70 "strokeWeight",
71 "mouseClicked",
72 "mouseDragged",
73 "mouseMoved",
74 "mousePressed",
75 "mouseReleased",
76 "mouseWheel",
77 "keyPressed",
78 "keyPressedkeyReleased",
79 "keyTyped",
80 "print",
81 "println",
82 "save",
83 "saveFrame",
84 "day",
85 "hour",
86 "millis",
87 "minute",
88 "month",
89 "second",
90 "year",
91 "background",
92 "clear",
93 "colorMode",
94 "fill",
95 "noFill",
96 "noStroke",
97 "stroke",
98 "alpha",
99 "blue",
100 "brightness",
101 "color",
102 "green",
103 "hue",
104 "lerpColor",
105 "red",
106 "saturation",
107 "modelX",
108 "modelY",
109 "modelZ",
110 "screenX",
111 "screenY",
112 "screenZ",
113 "ambient",
114 "emissive",
115 "shininess",
116 "specular",
117 "add",
118 "createImage",
119 "beginCamera",
120 "camera",
121 "endCamera",
122 "frustum",
123 "ortho",
124 "perspective",
125 "printCamera",
126 "printProjection",
127 "cursor",
128 "frameRate",
129 "noCursor",
130 "exit",
131 "loop",
132 "noLoop",
133 "popStyle",
134 "pushStyle",
135 "redraw",
136 "binary",
137 "boolean",
138 "byte",
139 "char",
140 "float",
141 "hex",
142 "int",
143 "str",
144 "unbinary",
145 "unhex",
146 "join",
147 "match",
148 "matchAll",
149 "nf",
150 "nfc",
151 "nfp",
152 "nfs",
153 "split",
154 "splitTokens",
155 "trim",
156 "append",
157 "arrayCopy",
158 "concat",
159 "expand",
160 "reverse",
161 "shorten",
162 "sort",
163 "splice",
164 "subset",
165 "box",
166 "sphere",
167 "sphereDetail",
168 "createInput",
169 "createReader",
170 "loadBytes",
171 "loadJSONArray",
172 "loadJSONObject",
173 "loadStrings",
174 "loadTable",
175 "loadXML",
176 "open",
177 "parseXML",
178 "saveTable",
179 "selectFolder",
180 "selectInput",
181 "beginRaw",
182 "beginRecord",
183 "createOutput",
184 "createWriter",
185 "endRaw",
186 "endRecord",
187 "PrintWritersaveBytes",
188 "saveJSONArray",
189 "saveJSONObject",
190 "saveStream",
191 "saveStrings",
192 "saveXML",
193 "selectOutput",
194 "popMatrix",
195 "printMatrix",
196 "pushMatrix",
197 "resetMatrix",
198 "rotate",
199 "rotateX",
200 "rotateY",
201 "rotateZ",
202 "scale",
203 "shearX",
204 "shearY",
205 "translate",
206 "ambientLight",
207 "directionalLight",
208 "lightFalloff",
209 "lights",
210 "lightSpecular",
211 "noLights",
212 "normal",
213 "pointLight",
214 "spotLight",
215 "image",
216 "imageMode",
217 "loadImage",
218 "noTint",
219 "requestImage",
220 "tint",
221 "texture",
222 "textureMode",
223 "textureWrap",
224 "blend",
225 "copy",
226 "filter",
227 "get",
228 "loadPixels",
229 "set",
230 "updatePixels",
231 "blendMode",
232 "loadShader",
233 "PShaderresetShader",
234 "shader",
235 "createFont",
236 "loadFont",
237 "text",
238 "textFont",
239 "textAlign",
240 "textLeading",
241 "textMode",
242 "textSize",
243 "textWidth",
244 "textAscent",
245 "textDescent",
246 "abs",
247 "ceil",
248 "constrain",
249 "dist",
250 "exp",
251 "floor",
252 "lerp",
253 "log",
254 "mag",
255 "map",
256 "max",
257 "min",
258 "norm",
259 "pow",
260 "round",
261 "sq",
262 "sqrt",
263 "acos",
264 "asin",
265 "atan",
266 "atan2",
267 "cos",
268 "degrees",
269 "radians",
270 "sin",
271 "tan",
272 "noise",
273 "noiseDetail",
274 "noiseSeed",
275 "random",
276 "randomGaussian",
277 "randomSeed"
278 ];
279 const IDENT = hljs.IDENT_RE;
280 const FUNC_NAME = { variants: [
281 {
282 match: regex.concat(regex.either(...BUILT_INS), regex.lookahead(/\s*\(/)),
283 className: "built_in"
284 },
285 {
286 relevance: 0,
287 match: regex.concat(
288 /\b(?!for|if|while)/,
289 IDENT, regex.lookahead(/\s*\(/)),
290 className: "title.function"
291 }
292 ] };
293 const NEW_CLASS = {
294 match: [
295 /new\s+/,
296 IDENT
297 ],
298 className: {
299 1: "keyword",
300 2: "class.title"
301 }
302 };
303 const PROPERTY = {
304 relevance: 0,
305 match: [
306 /\./,
307 IDENT
308 ],
309 className: { 2: "property" }
310 };
311 const CLASS = {
312 variants: [
313 { match: [
314 /class/,
315 /\s+/,
316 IDENT,
317 /\s+/,
318 /extends/,
319 /\s+/,
320 IDENT
321 ] },
322 { match: [
323 /class/,
324 /\s+/,
325 IDENT
326 ] }
327 ],
328 className: {
329 1: "keyword",
330 3: "title.class",
331 5: "keyword",
332 7: "title.class.inherited"
333 }
334 };
335
336 const TYPES = [
337 "boolean",
338 "byte",
339 "char",
340 "color",
341 "double",
342 "float",
343 "int",
344 "long",
345 "short",
346 ];
347 const CLASSES = [
348 "BufferedReader",
349 "PVector",
350 "PFont",
351 "PImage",
352 "PGraphics",
353 "HashMap",
354 "String",
355 "Array",
356 "FloatDict",
357 "ArrayList",
358 "FloatList",
359 "IntDict",
360 "IntList",
361 "JSONArray",
362 "JSONObject",
363 "Object",
364 "StringDict",
365 "StringList",
366 "Table",
367 "TableRow",
368 "XML"
369 ];
370 const JAVA_KEYWORDS = [
371 "abstract",
372 "assert",
373 "break",
374 "case",
375 "catch",
376 "const",
377 "continue",
378 "default",
379 "else",
380 "enum",
381 "final",
382 "finally",
383 "for",
384 "if",
385 "import",
386 "instanceof",
387 "long",
388 "native",
389 "new",
390 "package",
391 "private",
392 "private",
393 "protected",
394 "protected",
395 "public",
396 "public",
397 "return",
398 "static",
399 "strictfp",
400 "switch",
401 "synchronized",
402 "throw",
403 "throws",
404 "transient",
405 "try",
406 "void",
407 "volatile",
408 "while"
409 ];
410
411 return {
412 name: 'Processing',
413 aliases: [ 'pde' ],
414 keywords: {
415 keyword: [ ...JAVA_KEYWORDS ],
416 literal: 'P2D P3D HALF_PI PI QUARTER_PI TAU TWO_PI null true false',
417 title: 'setup draw',
418 variable: "super this",
419 built_in: [
420 ...BUILT_INS,
421 ...CLASSES
422 ],
423 type: TYPES
424 },
425 contains: [
426 CLASS,
427 NEW_CLASS,
428 FUNC_NAME,
429 PROPERTY,
430 hljs.C_LINE_COMMENT_MODE,
431 hljs.C_BLOCK_COMMENT_MODE,
432 hljs.APOS_STRING_MODE,
433 hljs.QUOTE_STRING_MODE,
434 hljs.C_NUMBER_MODE
435 ]
436 };
437 }
438
439 return processing;
440
441 })();
442
443 hljs.registerLanguage('processing', hljsGrammar);
444 })();