1 | (function (Prism) {
|
2 |
|
3 | var stringPattern = /(?:"(?:""|[^"])*"(?!")|'(?:''|[^'])*'(?!'))/.source;
|
4 |
|
5 | var number = /\b(?:\d[\da-f]*x|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i;
|
6 | var numericConstant = {
|
7 | pattern: RegExp(stringPattern + '[bx]'),
|
8 | alias: 'number'
|
9 | };
|
10 |
|
11 | var macroVariable = {
|
12 | pattern: /&[a-z_][a-z_0-9]*/i
|
13 | };
|
14 |
|
15 | var macroKeyword = {
|
16 | pattern: /((?:^|\s|=|\())%(?:ABORT|BY|CMS|COPY|DISPLAY|DO|ELSE|END|EVAL|GLOBAL|GO|GOTO|IF|INC|INCLUDE|INDEX|INPUT|KTRIM|LENGTH|LET|LIST|LOCAL|PUT|QKTRIM|QSCAN|QSUBSTR|QSYSFUNC|QUPCASE|RETURN|RUN|SCAN|SUBSTR|SUPERQ|SYMDEL|SYMGLOBL|SYMLOCAL|SYMEXIST|SYSCALL|SYSEVALF|SYSEXEC|SYSFUNC|SYSGET|SYSRPUT|THEN|TO|TSO|UNQUOTE|UNTIL|UPCASE|WHILE|WINDOW)\b/i,
|
17 | lookbehind: true,
|
18 | alias: 'keyword'
|
19 | };
|
20 |
|
21 | var step = {
|
22 | pattern: /(^|\s+)(?:proc\s+\w+|quit|run|data(?!\=))\b/i,
|
23 | alias: 'keyword',
|
24 | lookbehind: true
|
25 | };
|
26 |
|
27 | var comment = [
|
28 | /\/\*[\s\S]*?\*\
|
29 | {
|
30 | pattern: /(^\s*|;\s*)\*[^;]*;/m,
|
31 | lookbehind: true
|
32 | }
|
33 | ];
|
34 |
|
35 | var string = {
|
36 | pattern: RegExp(stringPattern),
|
37 | greedy: true
|
38 | };
|
39 |
|
40 | var punctuation = /[$%@.(){}\[\];,\\]/;
|
41 |
|
42 | var func = {
|
43 | pattern: /%?\w+(?=\()/,
|
44 | alias: 'keyword'
|
45 | };
|
46 |
|
47 | var args = {
|
48 | 'function': func,
|
49 | 'arg-value': {
|
50 | pattern: /(\s*=\s*)[A-Z\.]+/i,
|
51 | lookbehind: true
|
52 | },
|
53 | 'operator': /=/,
|
54 | 'macro-variable': macroVariable,
|
55 | 'arg': {
|
56 | pattern: /[A-Z]+/i,
|
57 | alias: 'keyword'
|
58 | },
|
59 | 'number': number,
|
60 | 'numeric-constant': numericConstant,
|
61 | 'punctuation': punctuation,
|
62 | 'string': string
|
63 | };
|
64 |
|
65 | var format = {
|
66 | pattern: /\b(?:format|put)\b=?[\w'$.]+/im,
|
67 | inside: {
|
68 | 'keyword': /^(?:format|put)(?=\=)/i,
|
69 | 'equals': /=/,
|
70 | 'format': {
|
71 | pattern: /(?:\w|\$\d)+\.\d?/i,
|
72 | alias: 'number'
|
73 | }
|
74 | }
|
75 | };
|
76 |
|
77 | var altformat = {
|
78 | pattern: /\b(?:format|put)\s+[\w']+(?:\s+[$.\w]+)+(?=;)/i,
|
79 | inside: {
|
80 | 'keyword': /^(?:format|put)/i,
|
81 | 'format': {
|
82 | pattern: /[\w$]+\.\d?/,
|
83 | alias: 'number'
|
84 | }
|
85 | }
|
86 | };
|
87 |
|
88 | var globalStatements = {
|
89 | pattern: /((?:^|[\s])=?)(?:catname|checkpoint execute_always|dm|endsas|filename|footnote|%include|libname|%list|lock|missing|options|page|resetline|%run|sasfile|skip|sysecho|title\d?)\b/i,
|
90 | lookbehind: true,
|
91 | alias: 'keyword'
|
92 | };
|
93 |
|
94 | var submitStatement = {
|
95 | pattern: /(^|\s)(?:submit(?:\s+(?:load|parseonly|norun))?|endsubmit)\b/i,
|
96 | lookbehind: true,
|
97 | alias: 'keyword'
|
98 | };
|
99 |
|
100 | var actionSets = /accessControl|cdm|aggregation|aStore|ruleMining|audio|autotune|bayesianNetClassifier|bioMedImage|boolRule|builtins|cardinality|sccasl|clustering|copula|countreg|dataDiscovery|dataPreprocess|dataSciencePilot|dataStep|decisionTree|deepLearn|deepNeural|varReduce|simSystem|ds2|deduplication|ecm|entityRes|espCluster|explainModel|factmac|fastKnn|fcmpact|fedSql|freqTab|gam|gleam|graphSemiSupLearn|gVarCluster|hiddenMarkovModel|hyperGroup|image|iml|ica|kernalPca|langModel|ldaTopic|sparseML|mlTools|mixed|modelPublishing|mbc|network|optNetwork|neuralNet|nonlinear|nmf|nonParametricBayes|optimization|panel|pls|percentile|pca|phreg|qkb|qlim|quantreg|recommend|tsReconcile|deepRnn|regression|reinforcementLearn|robustPca|sampling|sparkEmbeddedProcess|search(?:Analytics)?|sentimentAnalysis|sequence|configuration|session(?:Prop)?|severity|simple|smartData|sandwich|spatialreg|stabilityMonitoring|spc|loadStreams|svDataDescription|svm|table|conditionalRandomFields|text(?:Rule(?:Develop|Score)|Mining|Parse|Topic|Util|Filters|Frequency)|tsInfo|timeData|transpose|uniTimeSeries/.source;
|
101 |
|
102 | var casActions = {
|
103 | pattern: RegExp(/(^|\s)(?:action\s+)?(?:<act>)\.[a-z]+\b[^;]+/.source.replace(/<act>/g, function () { return actionSets; }), 'i'),
|
104 | lookbehind: true,
|
105 | inside: {
|
106 | 'keyword': RegExp(/(?:<act>)\.[a-z]+\b/.source.replace(/<act>/g, function () { return actionSets; }), 'i'),
|
107 | 'action': {
|
108 | pattern: /(?:action)/i,
|
109 | alias: 'keyword'
|
110 | },
|
111 | 'comment': comment,
|
112 | 'function': func,
|
113 | 'arg-value': args['arg-value'],
|
114 | 'operator': args.operator,
|
115 | 'argument': args.arg,
|
116 | 'number': number,
|
117 | 'numeric-constant': numericConstant,
|
118 | 'punctuation': punctuation,
|
119 | 'string': string
|
120 | }
|
121 | };
|
122 |
|
123 | var keywords = {
|
124 | pattern: /((?:^|\s)=?)(?:after|analysis|and|array|barchart|barwidth|begingraph|by|call|cas|cbarline|cfill|class(?:lev)?|close|column|computed?|contains|continue|data(?=\=)|define|delete|describe|document|do\s+over|do|dol|drop|dul|end(?:source|comp)?|entryTitle|else|eval(?:uate)?|exec(?:ute)?|exit|fill(?:attrs)?|file(?:name)?|flist|fnc|function(?:list)?|goto|global|group(?:by)?|headline|headskip|histogram|if|infile|keep|keylabel|keyword|label|layout|leave|legendlabel|length|libname|loadactionset|merge|midpoints|name|noobs|nowd|_?null_|ods|options|or|otherwise|out(?:put)?|over(?:lay)?|plot|put|print|raise|ranexp|rannor|rbreak|retain|return|select|set|session|sessref|source|statgraph|sum|summarize|table|temp|terminate|then\s+do|then|title\d?|to|var|when|where|xaxisopts|yaxisopts|y2axisopts)\b/i,
|
125 | lookbehind: true,
|
126 | };
|
127 |
|
128 | Prism.languages.sas = {
|
129 | 'datalines': {
|
130 | pattern: /^(\s*)(?:(?:data)?lines|cards);[\s\S]+?^\s*;/im,
|
131 | lookbehind: true,
|
132 | alias: 'string',
|
133 | inside: {
|
134 | 'keyword': {
|
135 | pattern: /^(?:(?:data)?lines|cards)/i
|
136 | },
|
137 | 'punctuation': /;/
|
138 | }
|
139 | },
|
140 |
|
141 | 'proc-sql': {
|
142 | pattern: /(^proc\s+(?:fed)?sql(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
|
143 | lookbehind: true,
|
144 | inside: {
|
145 | 'sql': {
|
146 | pattern: RegExp(/^[ \t]*(?:select|alter\s+table|(?:create|describe|drop)\s+(?:index|table(?:\s+constraints)?|view)|create\s+unique\s+index|insert\s+into|update)(?:<str>|[^;"'])+;/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
|
147 | alias: 'language-sql',
|
148 | inside: Prism.languages.sql
|
149 | },
|
150 | 'global-statements': globalStatements,
|
151 | 'sql-statements': {
|
152 | pattern: /(^|\s)(?:disconnect\s+from|exec(?:ute)?|begin|commit|rollback|reset|validate)\b/i,
|
153 | lookbehind: true,
|
154 | alias: 'keyword'
|
155 | },
|
156 | 'number': number,
|
157 | 'numeric-constant': numericConstant,
|
158 | 'punctuation': punctuation,
|
159 | 'string': string
|
160 | }
|
161 | },
|
162 |
|
163 | 'proc-groovy': {
|
164 | pattern: /(^proc\s+groovy(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
|
165 | lookbehind: true,
|
166 | inside: {
|
167 | 'comment': comment,
|
168 | 'groovy': {
|
169 | pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|parseonly|norun))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
|
170 | lookbehind: true,
|
171 | alias: 'language-groovy',
|
172 | inside: Prism.languages.groovy
|
173 | },
|
174 | 'keyword': keywords,
|
175 | 'submit-statement': submitStatement,
|
176 | 'global-statements': globalStatements,
|
177 | 'number': number,
|
178 | 'numeric-constant': numericConstant,
|
179 | 'punctuation': punctuation,
|
180 | 'string': string
|
181 | }
|
182 | },
|
183 |
|
184 | 'proc-lua': {
|
185 | pattern: /(^proc\s+lua(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|run|data);|(?![\s\S]))/im,
|
186 | lookbehind: true,
|
187 | inside: {
|
188 | 'comment': comment,
|
189 | 'lua': {
|
190 | pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|parseonly|norun))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
|
191 | lookbehind: true,
|
192 | alias: 'language-lua',
|
193 | inside: Prism.languages.lua
|
194 | },
|
195 | 'keyword': keywords,
|
196 | 'submit-statement': submitStatement,
|
197 | 'global-statements': globalStatements,
|
198 | 'number': number,
|
199 | 'numeric-constant': numericConstant,
|
200 | 'punctuation': punctuation,
|
201 | 'string': string
|
202 | }
|
203 | },
|
204 |
|
205 | 'proc-cas': {
|
206 | pattern: /(^proc\s+cas(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|data);|(?![\s\S]))/im,
|
207 | lookbehind: true,
|
208 | inside: {
|
209 | 'comment': comment,
|
210 | 'statement-var': {
|
211 | pattern: /((?:^|\s)=?)saveresult\s+[^;]+/im,
|
212 | lookbehind: true,
|
213 | inside: {
|
214 | 'statement': {
|
215 | pattern: /^saveresult\s+\S+/i,
|
216 | inside: {
|
217 | keyword: /^(?:saveresult)/i
|
218 | }
|
219 | },
|
220 | rest: args
|
221 | }
|
222 | },
|
223 | 'cas-actions': casActions,
|
224 | 'statement': {
|
225 | pattern: /((?:^|\s)=?)(?:default|(?:un)?set|on|output|upload)[^;]+/im,
|
226 | lookbehind: true,
|
227 | inside: args
|
228 | },
|
229 | 'step': step,
|
230 | 'keyword': keywords,
|
231 | 'function': func,
|
232 | 'format': format,
|
233 | 'altformat': altformat,
|
234 | 'global-statements': globalStatements,
|
235 | 'number': number,
|
236 | 'numeric-constant': numericConstant,
|
237 | 'punctuation': punctuation,
|
238 | 'string': string
|
239 | }
|
240 | },
|
241 |
|
242 | 'proc-args': {
|
243 | pattern: RegExp(/(^proc\s+\w+\s+)(?!\s)(?:[^;"']|<str>)+;/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
|
244 | lookbehind: true,
|
245 | inside: args
|
246 | },
|
247 |
|
248 | 'macro-keyword': macroKeyword,
|
249 | 'macro-variable': macroVariable,
|
250 | 'macro-string-functions': {
|
251 | pattern: /((?:^|\s|=))%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)\(.*?(?:[^%]\))/i,
|
252 | lookbehind: true,
|
253 | inside: {
|
254 | 'function': {
|
255 | pattern: /%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)/i,
|
256 | alias: 'keyword'
|
257 | },
|
258 | 'macro-keyword': macroKeyword,
|
259 | 'macro-variable': macroVariable,
|
260 | 'escaped-char': {
|
261 | pattern: /%['"()<>=¬^~;,#]/i,
|
262 | },
|
263 | 'punctuation': punctuation
|
264 | }
|
265 | },
|
266 | 'macro-declaration': {
|
267 | pattern: /^%macro[^;]+(?=;)/im,
|
268 | inside: {
|
269 | 'keyword': /%macro/i,
|
270 | }
|
271 | },
|
272 | 'macro-end': {
|
273 | pattern: /^%mend[^;]+(?=;)/im,
|
274 | inside: {
|
275 | 'keyword': /%mend/i,
|
276 | }
|
277 | },
|
278 |
|
279 | 'macro': {
|
280 | pattern: /%_\w+(?=\()/,
|
281 | alias: 'keyword'
|
282 | },
|
283 | 'input': {
|
284 | pattern: /\binput\s+[-\w\s/*.$&]+;/i,
|
285 | inside: {
|
286 | 'input': {
|
287 | alias: 'keyword',
|
288 | pattern: /^input/i,
|
289 | },
|
290 | 'comment': comment,
|
291 | 'number': number,
|
292 | 'numeric-constant': numericConstant
|
293 | }
|
294 | },
|
295 | 'options-args': {
|
296 | pattern: /(^options)[-'"|/\\<>*+=:()\w\s]*(?=;)/im,
|
297 | lookbehind: true,
|
298 | inside: args
|
299 | },
|
300 | 'cas-actions': casActions,
|
301 | 'comment': comment,
|
302 | 'function': func,
|
303 | 'format': format,
|
304 | 'altformat': altformat,
|
305 | 'numeric-constant': numericConstant,
|
306 | 'datetime': {
|
307 |
|
308 | pattern: RegExp(stringPattern + '(?:dt?|t)'),
|
309 | alias: 'number'
|
310 | },
|
311 | 'string': string,
|
312 | 'step': step,
|
313 | 'keyword': keywords,
|
314 |
|
315 | 'operator-keyword': {
|
316 | pattern: /\b(?:eq|ne|gt|lt|ge|le|in|not)\b/i,
|
317 | alias: 'operator'
|
318 | },
|
319 |
|
320 | 'number': number,
|
321 | 'operator': /\*\*?|\|\|?|!!?|¦¦?|<[>=]?|>[<=]?|[-+\/=&]|[~¬^]=?/i,
|
322 | 'punctuation': punctuation
|
323 | };
|
324 |
|
325 | }(Prism));
|