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