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_]\w*/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|SYMEXIST|SYMGLOBL|SYMLOCAL|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+|data(?!=)|quit|run)\b/i,
|
23 | alias: 'keyword',
|
24 | lookbehind: true
|
25 | };
|
26 |
|
27 | var comment = [
|
28 | /\/\*[\s\S]*?\*\
|
29 | {
|
30 | pattern: /(^[ \t]*|;\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: /%?\b\w+(?=\()/,
|
44 | alias: 'keyword'
|
45 | };
|
46 |
|
47 | var args = {
|
48 | 'function': func,
|
49 | 'arg-value': {
|
50 | pattern: /(=\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'$.]+/i,
|
67 | inside: {
|
68 | 'keyword': /^(?:format|put)(?==)/i,
|
69 | 'equals': /=/,
|
70 | 'format': {
|
71 | pattern: /(?:\w|\$\d)+\.\d?/,
|
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|norun|parseonly))?|endsubmit)\b/i,
|
96 | lookbehind: true,
|
97 | alias: 'keyword'
|
98 | };
|
99 |
|
100 | var actionSets = /aStore|accessControl|aggregation|audio|autotune|bayesianNetClassifier|bioMedImage|boolRule|builtins|cardinality|cdm|clustering|conditionalRandomFields|configuration|copula|countreg|dataDiscovery|dataPreprocess|dataSciencePilot|dataStep|decisionTree|deduplication|deepLearn|deepNeural|deepRnn|ds2|ecm|entityRes|espCluster|explainModel|factmac|fastKnn|fcmpact|fedSql|freqTab|gVarCluster|gam|gleam|graphSemiSupLearn|hiddenMarkovModel|hyperGroup|ica|image|iml|kernalPca|langModel|ldaTopic|loadStreams|mbc|mixed|mlTools|modelPublishing|network|neuralNet|nmf|nonParametricBayes|nonlinear|optNetwork|optimization|panel|pca|percentile|phreg|pls|qkb|qlim|quantreg|recommend|regression|reinforcementLearn|robustPca|ruleMining|sampling|sandwich|sccasl|search(?:Analytics)?|sentimentAnalysis|sequence|session(?:Prop)?|severity|simSystem|simple|smartData|sparkEmbeddedProcess|sparseML|spatialreg|spc|stabilityMonitoring|svDataDescription|svm|table|text(?:Filters|Frequency|Mining|Parse|Rule(?:Develop|Score)|Topic|Util)|timeData|transpose|tsInfo|tsReconcile|uniTimeSeries|varReduce/.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|else|end(?:comp|source)?|entryTitle|eval(?:uate)?|exec(?:ute)?|exit|file(?:name)?|fill(?:attrs)?|flist|fnc|function(?:list)?|global|goto|group(?:by)?|headline|headskip|histogram|if|infile|keep|keylabel|keyword|label|layout|leave|legendlabel|length|libname|loadactionset|merge|midpoints|_?null_|name|noobs|nowd|ods|options|or|otherwise|out(?:put)?|over(?:lay)?|plot|print|put|raise|ranexp|rannor|rbreak|retain|return|select|session|sessref|set|source|statgraph|sum|summarize|table|temp|terminate|then\s+do|then|title\d?|to|var|when|where|xaxisopts|y2axisopts|yaxisopts)\b/i,
|
125 | lookbehind: true,
|
126 | };
|
127 |
|
128 | Prism.languages.sas = {
|
129 | 'datalines': {
|
130 | pattern: /^([ \t]*)(?:cards|(?:data)?lines);[\s\S]+?^[ \t]*;/im,
|
131 | lookbehind: true,
|
132 | alias: 'string',
|
133 | inside: {
|
134 | 'keyword': {
|
135 | pattern: /^(?:cards|(?:data)?lines)/i
|
136 | },
|
137 | 'punctuation': /;/
|
138 | }
|
139 | },
|
140 |
|
141 | 'proc-sql': {
|
142 | pattern: /(^proc\s+(?:fed)?sql(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|data|quit|run);|(?![\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|begin|commit|exec(?:ute)?|reset|rollback|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+|data|quit|run);|(?![\s\S]))/im,
|
165 | lookbehind: true,
|
166 | inside: {
|
167 | 'comment': comment,
|
168 | 'groovy': {
|
169 | pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|norun|parseonly))?)(?:<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+|data|quit|run);|(?![\s\S]))/im,
|
186 | lookbehind: true,
|
187 | inside: {
|
188 | 'comment': comment,
|
189 | 'lua': {
|
190 | pattern: RegExp(/(^[ \t]*submit(?:\s+(?:load|norun|parseonly))?)(?:<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 |
|
215 | 'statement': {
|
216 | pattern: /^saveresult\s+\S+/i,
|
217 | inside: {
|
218 | keyword: /^(?:saveresult)/i
|
219 | }
|
220 | },
|
221 | rest: args
|
222 | }
|
223 | },
|
224 | 'cas-actions': casActions,
|
225 | 'statement': {
|
226 | pattern: /((?:^|\s)=?)(?:default|(?:un)?set|on|output|upload)[^;]+/im,
|
227 | lookbehind: true,
|
228 | inside: args
|
229 | },
|
230 | 'step': step,
|
231 | 'keyword': keywords,
|
232 | 'function': func,
|
233 | 'format': format,
|
234 | 'altformat': altformat,
|
235 | 'global-statements': globalStatements,
|
236 | 'number': number,
|
237 | 'numeric-constant': numericConstant,
|
238 | 'punctuation': punctuation,
|
239 | 'string': string
|
240 | }
|
241 | },
|
242 |
|
243 | 'proc-args': {
|
244 | pattern: RegExp(/(^proc\s+\w+\s+)(?!\s)(?:[^;"']|<str>)+;/.source.replace(/<str>/g, function () { return stringPattern; }), 'im'),
|
245 | lookbehind: true,
|
246 | inside: args
|
247 | },
|
248 |
|
249 | 'macro-keyword': macroKeyword,
|
250 | 'macro-variable': macroVariable,
|
251 | 'macro-string-functions': {
|
252 | pattern: /((?:^|\s|=))%(?:BQUOTE|NRBQUOTE|NRQUOTE|NRSTR|QUOTE|STR)\(.*?(?:[^%]\))/i,
|
253 | lookbehind: true,
|
254 | inside: {
|
255 | 'function': {
|
256 | pattern: /%(?:BQUOTE|NRBQUOTE|NRQUOTE|NRSTR|QUOTE|STR)/i,
|
257 | alias: 'keyword'
|
258 | },
|
259 | 'macro-keyword': macroKeyword,
|
260 | 'macro-variable': macroVariable,
|
261 | 'escaped-char': {
|
262 | pattern: /%['"()<>=¬^~;,#]/,
|
263 | },
|
264 | 'punctuation': punctuation
|
265 | }
|
266 | },
|
267 | 'macro-declaration': {
|
268 | pattern: /^%macro[^;]+(?=;)/im,
|
269 | inside: {
|
270 | 'keyword': /%macro/i,
|
271 | }
|
272 | },
|
273 | 'macro-end': {
|
274 | pattern: /^%mend[^;]+(?=;)/im,
|
275 | inside: {
|
276 | 'keyword': /%mend/i,
|
277 | }
|
278 | },
|
279 |
|
280 | 'macro': {
|
281 | pattern: /%_\w+(?=\()/,
|
282 | alias: 'keyword'
|
283 | },
|
284 | 'input': {
|
285 | pattern: /\binput\s[-\w\s/*.$&]+;/i,
|
286 | inside: {
|
287 | 'input': {
|
288 | alias: 'keyword',
|
289 | pattern: /^input/i,
|
290 | },
|
291 | 'comment': comment,
|
292 | 'number': number,
|
293 | 'numeric-constant': numericConstant
|
294 | }
|
295 | },
|
296 | 'options-args': {
|
297 | pattern: /(^options)[-'"|/\\<>*+=:()\w\s]*(?=;)/im,
|
298 | lookbehind: true,
|
299 | inside: args
|
300 | },
|
301 | 'cas-actions': casActions,
|
302 | 'comment': comment,
|
303 | 'function': func,
|
304 | 'format': format,
|
305 | 'altformat': altformat,
|
306 | 'numeric-constant': numericConstant,
|
307 | 'datetime': {
|
308 |
|
309 | pattern: RegExp(stringPattern + '(?:dt?|t)'),
|
310 | alias: 'number'
|
311 | },
|
312 | 'string': string,
|
313 | 'step': step,
|
314 | 'keyword': keywords,
|
315 |
|
316 | 'operator-keyword': {
|
317 | pattern: /\b(?:eq|ge|gt|in|le|lt|ne|not)\b/i,
|
318 | alias: 'operator'
|
319 | },
|
320 |
|
321 | 'number': number,
|
322 | 'operator': /\*\*?|\|\|?|!!?|¦¦?|<[>=]?|>[<=]?|[-+\/=&]|[~¬^]=?/,
|
323 | 'punctuation': punctuation
|
324 | };
|
325 |
|
326 | }(Prism));
|