]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/sas.js
Initial commit.
[flow-web.git] / static / highlight / languages / sas.js
1 /*! `sas` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: SAS
8 Author: Mauricio Caceres <mauricio.caceres.bravo@gmail.com>
9 Description: Syntax Highlighting for SAS
10 Category: scientific
11 */
12
13 /** @type LanguageFn */
14 function sas(hljs) {
15 const regex = hljs.regex;
16 // Data step and PROC SQL statements
17 const SAS_KEYWORDS = [
18 "do",
19 "if",
20 "then",
21 "else",
22 "end",
23 "until",
24 "while",
25 "abort",
26 "array",
27 "attrib",
28 "by",
29 "call",
30 "cards",
31 "cards4",
32 "catname",
33 "continue",
34 "datalines",
35 "datalines4",
36 "delete",
37 "delim",
38 "delimiter",
39 "display",
40 "dm",
41 "drop",
42 "endsas",
43 "error",
44 "file",
45 "filename",
46 "footnote",
47 "format",
48 "goto",
49 "in",
50 "infile",
51 "informat",
52 "input",
53 "keep",
54 "label",
55 "leave",
56 "length",
57 "libname",
58 "link",
59 "list",
60 "lostcard",
61 "merge",
62 "missing",
63 "modify",
64 "options",
65 "output",
66 "out",
67 "page",
68 "put",
69 "redirect",
70 "remove",
71 "rename",
72 "replace",
73 "retain",
74 "return",
75 "select",
76 "set",
77 "skip",
78 "startsas",
79 "stop",
80 "title",
81 "update",
82 "waitsas",
83 "where",
84 "window",
85 "x|0",
86 "systask",
87 "add",
88 "and",
89 "alter",
90 "as",
91 "cascade",
92 "check",
93 "create",
94 "delete",
95 "describe",
96 "distinct",
97 "drop",
98 "foreign",
99 "from",
100 "group",
101 "having",
102 "index",
103 "insert",
104 "into",
105 "in",
106 "key",
107 "like",
108 "message",
109 "modify",
110 "msgtype",
111 "not",
112 "null",
113 "on",
114 "or",
115 "order",
116 "primary",
117 "references",
118 "reset",
119 "restrict",
120 "select",
121 "set",
122 "table",
123 "unique",
124 "update",
125 "validate",
126 "view",
127 "where"
128 ];
129
130 // Built-in SAS functions
131 const FUNCTIONS = [
132 "abs",
133 "addr",
134 "airy",
135 "arcos",
136 "arsin",
137 "atan",
138 "attrc",
139 "attrn",
140 "band",
141 "betainv",
142 "blshift",
143 "bnot",
144 "bor",
145 "brshift",
146 "bxor",
147 "byte",
148 "cdf",
149 "ceil",
150 "cexist",
151 "cinv",
152 "close",
153 "cnonct",
154 "collate",
155 "compbl",
156 "compound",
157 "compress",
158 "cos",
159 "cosh",
160 "css",
161 "curobs",
162 "cv",
163 "daccdb",
164 "daccdbsl",
165 "daccsl",
166 "daccsyd",
167 "dacctab",
168 "dairy",
169 "date",
170 "datejul",
171 "datepart",
172 "datetime",
173 "day",
174 "dclose",
175 "depdb",
176 "depdbsl",
177 "depdbsl",
178 "depsl",
179 "depsl",
180 "depsyd",
181 "depsyd",
182 "deptab",
183 "deptab",
184 "dequote",
185 "dhms",
186 "dif",
187 "digamma",
188 "dim",
189 "dinfo",
190 "dnum",
191 "dopen",
192 "doptname",
193 "doptnum",
194 "dread",
195 "dropnote",
196 "dsname",
197 "erf",
198 "erfc",
199 "exist",
200 "exp",
201 "fappend",
202 "fclose",
203 "fcol",
204 "fdelete",
205 "fetch",
206 "fetchobs",
207 "fexist",
208 "fget",
209 "fileexist",
210 "filename",
211 "fileref",
212 "finfo",
213 "finv",
214 "fipname",
215 "fipnamel",
216 "fipstate",
217 "floor",
218 "fnonct",
219 "fnote",
220 "fopen",
221 "foptname",
222 "foptnum",
223 "fpoint",
224 "fpos",
225 "fput",
226 "fread",
227 "frewind",
228 "frlen",
229 "fsep",
230 "fuzz",
231 "fwrite",
232 "gaminv",
233 "gamma",
234 "getoption",
235 "getvarc",
236 "getvarn",
237 "hbound",
238 "hms",
239 "hosthelp",
240 "hour",
241 "ibessel",
242 "index",
243 "indexc",
244 "indexw",
245 "input",
246 "inputc",
247 "inputn",
248 "int",
249 "intck",
250 "intnx",
251 "intrr",
252 "irr",
253 "jbessel",
254 "juldate",
255 "kurtosis",
256 "lag",
257 "lbound",
258 "left",
259 "length",
260 "lgamma",
261 "libname",
262 "libref",
263 "log",
264 "log10",
265 "log2",
266 "logpdf",
267 "logpmf",
268 "logsdf",
269 "lowcase",
270 "max",
271 "mdy",
272 "mean",
273 "min",
274 "minute",
275 "mod",
276 "month",
277 "mopen",
278 "mort",
279 "n",
280 "netpv",
281 "nmiss",
282 "normal",
283 "note",
284 "npv",
285 "open",
286 "ordinal",
287 "pathname",
288 "pdf",
289 "peek",
290 "peekc",
291 "pmf",
292 "point",
293 "poisson",
294 "poke",
295 "probbeta",
296 "probbnml",
297 "probchi",
298 "probf",
299 "probgam",
300 "probhypr",
301 "probit",
302 "probnegb",
303 "probnorm",
304 "probt",
305 "put",
306 "putc",
307 "putn",
308 "qtr",
309 "quote",
310 "ranbin",
311 "rancau",
312 "ranexp",
313 "rangam",
314 "range",
315 "rank",
316 "rannor",
317 "ranpoi",
318 "rantbl",
319 "rantri",
320 "ranuni",
321 "repeat",
322 "resolve",
323 "reverse",
324 "rewind",
325 "right",
326 "round",
327 "saving",
328 "scan",
329 "sdf",
330 "second",
331 "sign",
332 "sin",
333 "sinh",
334 "skewness",
335 "soundex",
336 "spedis",
337 "sqrt",
338 "std",
339 "stderr",
340 "stfips",
341 "stname",
342 "stnamel",
343 "substr",
344 "sum",
345 "symget",
346 "sysget",
347 "sysmsg",
348 "sysprod",
349 "sysrc",
350 "system",
351 "tan",
352 "tanh",
353 "time",
354 "timepart",
355 "tinv",
356 "tnonct",
357 "today",
358 "translate",
359 "tranwrd",
360 "trigamma",
361 "trim",
362 "trimn",
363 "trunc",
364 "uniform",
365 "upcase",
366 "uss",
367 "var",
368 "varfmt",
369 "varinfmt",
370 "varlabel",
371 "varlen",
372 "varname",
373 "varnum",
374 "varray",
375 "varrayx",
376 "vartype",
377 "verify",
378 "vformat",
379 "vformatd",
380 "vformatdx",
381 "vformatn",
382 "vformatnx",
383 "vformatw",
384 "vformatwx",
385 "vformatx",
386 "vinarray",
387 "vinarrayx",
388 "vinformat",
389 "vinformatd",
390 "vinformatdx",
391 "vinformatn",
392 "vinformatnx",
393 "vinformatw",
394 "vinformatwx",
395 "vinformatx",
396 "vlabel",
397 "vlabelx",
398 "vlength",
399 "vlengthx",
400 "vname",
401 "vnamex",
402 "vtype",
403 "vtypex",
404 "weekday",
405 "year",
406 "yyq",
407 "zipfips",
408 "zipname",
409 "zipnamel",
410 "zipstate"
411 ];
412
413 // Built-in macro functions
414 const MACRO_FUNCTIONS = [
415 "bquote",
416 "nrbquote",
417 "cmpres",
418 "qcmpres",
419 "compstor",
420 "datatyp",
421 "display",
422 "do",
423 "else",
424 "end",
425 "eval",
426 "global",
427 "goto",
428 "if",
429 "index",
430 "input",
431 "keydef",
432 "label",
433 "left",
434 "length",
435 "let",
436 "local",
437 "lowcase",
438 "macro",
439 "mend",
440 "nrbquote",
441 "nrquote",
442 "nrstr",
443 "put",
444 "qcmpres",
445 "qleft",
446 "qlowcase",
447 "qscan",
448 "qsubstr",
449 "qsysfunc",
450 "qtrim",
451 "quote",
452 "qupcase",
453 "scan",
454 "str",
455 "substr",
456 "superq",
457 "syscall",
458 "sysevalf",
459 "sysexec",
460 "sysfunc",
461 "sysget",
462 "syslput",
463 "sysprod",
464 "sysrc",
465 "sysrput",
466 "then",
467 "to",
468 "trim",
469 "unquote",
470 "until",
471 "upcase",
472 "verify",
473 "while",
474 "window"
475 ];
476
477 const LITERALS = [
478 "null",
479 "missing",
480 "_all_",
481 "_automatic_",
482 "_character_",
483 "_infile_",
484 "_n_",
485 "_name_",
486 "_null_",
487 "_numeric_",
488 "_user_",
489 "_webout_"
490 ];
491
492 return {
493 name: 'SAS',
494 case_insensitive: true,
495 keywords: {
496 literal: LITERALS,
497 keyword: SAS_KEYWORDS
498 },
499 contains: [
500 {
501 // Distinct highlight for proc <proc>, data, run, quit
502 className: 'keyword',
503 begin: /^\s*(proc [\w\d_]+|data|run|quit)[\s;]/
504 },
505 {
506 // Macro variables
507 className: 'variable',
508 begin: /&[a-zA-Z_&][a-zA-Z0-9_]*\.?/
509 },
510 {
511 begin: [
512 /^\s*/,
513 /datalines;|cards;/,
514 /(?:.*\n)+/,
515 /^\s*;\s*$/
516 ],
517 className: {
518 2: "keyword",
519 3: "string"
520 }
521 },
522 {
523 begin: [
524 /%mend|%macro/,
525 /\s+/,
526 /[a-zA-Z_&][a-zA-Z0-9_]*/
527 ],
528 className: {
529 1: "built_in",
530 3: "title.function"
531 }
532 },
533 { // Built-in macro variables
534 className: 'built_in',
535 begin: '%' + regex.either(...MACRO_FUNCTIONS)
536 },
537 {
538 // User-defined macro functions
539 className: 'title.function',
540 begin: /%[a-zA-Z_][a-zA-Z_0-9]*/
541 },
542 {
543 // TODO: this is most likely an incorrect classification
544 // built_in may need more nuance
545 // https://github.com/highlightjs/highlight.js/issues/2521
546 className: 'meta',
547 begin: regex.either(...FUNCTIONS) + '(?=\\()'
548 },
549 {
550 className: 'string',
551 variants: [
552 hljs.APOS_STRING_MODE,
553 hljs.QUOTE_STRING_MODE
554 ]
555 },
556 hljs.COMMENT('\\*', ';'),
557 hljs.C_BLOCK_COMMENT_MODE
558 ]
559 };
560 }
561
562 return sas;
563
564 })();
565
566 hljs.registerLanguage('sas', hljsGrammar);
567 })();