[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = sas
|
---|
| 4 | sas.displayName = 'sas'
|
---|
| 5 | sas.aliases = []
|
---|
| 6 | function sas(Prism) {
|
---|
| 7 | ;(function (Prism) {
|
---|
| 8 | var stringPattern = /(?:"(?:""|[^"])*"(?!")|'(?:''|[^'])*'(?!'))/.source
|
---|
| 9 | var number = /\b(?:\d[\da-f]*x|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i
|
---|
| 10 | var numericConstant = {
|
---|
| 11 | pattern: RegExp(stringPattern + '[bx]'),
|
---|
| 12 | alias: 'number'
|
---|
| 13 | }
|
---|
| 14 | var macroVariable = {
|
---|
| 15 | pattern: /&[a-z_]\w*/i
|
---|
| 16 | }
|
---|
| 17 | var macroKeyword = {
|
---|
| 18 | pattern:
|
---|
| 19 | /((?:^|\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,
|
---|
| 20 | lookbehind: true,
|
---|
| 21 | alias: 'keyword'
|
---|
| 22 | }
|
---|
| 23 | var step = {
|
---|
| 24 | pattern: /(^|\s)(?:proc\s+\w+|data(?!=)|quit|run)\b/i,
|
---|
| 25 | alias: 'keyword',
|
---|
| 26 | lookbehind: true
|
---|
| 27 | }
|
---|
| 28 | var comment = [
|
---|
| 29 | /\/\*[\s\S]*?\*\//,
|
---|
| 30 | {
|
---|
| 31 | pattern: /(^[ \t]*|;\s*)\*[^;]*;/m,
|
---|
| 32 | lookbehind: true
|
---|
| 33 | }
|
---|
| 34 | ]
|
---|
| 35 | var string = {
|
---|
| 36 | pattern: RegExp(stringPattern),
|
---|
| 37 | greedy: true
|
---|
| 38 | }
|
---|
| 39 | var punctuation = /[$%@.(){}\[\];,\\]/
|
---|
| 40 | var func = {
|
---|
| 41 | pattern: /%?\b\w+(?=\()/,
|
---|
| 42 | alias: 'keyword'
|
---|
| 43 | }
|
---|
| 44 | var args = {
|
---|
| 45 | function: func,
|
---|
| 46 | 'arg-value': {
|
---|
| 47 | pattern: /(=\s*)[A-Z\.]+/i,
|
---|
| 48 | lookbehind: true
|
---|
| 49 | },
|
---|
| 50 | operator: /=/,
|
---|
| 51 | 'macro-variable': macroVariable,
|
---|
| 52 | arg: {
|
---|
| 53 | pattern: /[A-Z]+/i,
|
---|
| 54 | alias: 'keyword'
|
---|
| 55 | },
|
---|
| 56 | number: number,
|
---|
| 57 | 'numeric-constant': numericConstant,
|
---|
| 58 | punctuation: punctuation,
|
---|
| 59 | string: string
|
---|
| 60 | }
|
---|
| 61 | var format = {
|
---|
| 62 | pattern: /\b(?:format|put)\b=?[\w'$.]+/i,
|
---|
| 63 | inside: {
|
---|
| 64 | keyword: /^(?:format|put)(?==)/i,
|
---|
| 65 | equals: /=/,
|
---|
| 66 | format: {
|
---|
| 67 | pattern: /(?:\w|\$\d)+\.\d?/,
|
---|
| 68 | alias: 'number'
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | var altformat = {
|
---|
| 73 | pattern: /\b(?:format|put)\s+[\w']+(?:\s+[$.\w]+)+(?=;)/i,
|
---|
| 74 | inside: {
|
---|
| 75 | keyword: /^(?:format|put)/i,
|
---|
| 76 | format: {
|
---|
| 77 | pattern: /[\w$]+\.\d?/,
|
---|
| 78 | alias: 'number'
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | var globalStatements = {
|
---|
| 83 | pattern:
|
---|
| 84 | /((?:^|\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,
|
---|
| 85 | lookbehind: true,
|
---|
| 86 | alias: 'keyword'
|
---|
| 87 | }
|
---|
| 88 | var submitStatement = {
|
---|
| 89 | pattern: /(^|\s)(?:submit(?:\s+(?:load|norun|parseonly))?|endsubmit)\b/i,
|
---|
| 90 | lookbehind: true,
|
---|
| 91 | alias: 'keyword'
|
---|
| 92 | }
|
---|
| 93 | var actionSets =
|
---|
| 94 | /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/
|
---|
| 95 | .source
|
---|
| 96 | var casActions = {
|
---|
| 97 | pattern: RegExp(
|
---|
| 98 | /(^|\s)(?:action\s+)?(?:<act>)\.[a-z]+\b[^;]+/.source.replace(
|
---|
| 99 | /<act>/g,
|
---|
| 100 | function () {
|
---|
| 101 | return actionSets
|
---|
| 102 | }
|
---|
| 103 | ),
|
---|
| 104 | 'i'
|
---|
| 105 | ),
|
---|
| 106 | lookbehind: true,
|
---|
| 107 | inside: {
|
---|
| 108 | keyword: RegExp(
|
---|
| 109 | /(?:<act>)\.[a-z]+\b/.source.replace(/<act>/g, function () {
|
---|
| 110 | return actionSets
|
---|
| 111 | }),
|
---|
| 112 | 'i'
|
---|
| 113 | ),
|
---|
| 114 | action: {
|
---|
| 115 | pattern: /(?:action)/i,
|
---|
| 116 | alias: 'keyword'
|
---|
| 117 | },
|
---|
| 118 | comment: comment,
|
---|
| 119 | function: func,
|
---|
| 120 | 'arg-value': args['arg-value'],
|
---|
| 121 | operator: args.operator,
|
---|
| 122 | argument: args.arg,
|
---|
| 123 | number: number,
|
---|
| 124 | 'numeric-constant': numericConstant,
|
---|
| 125 | punctuation: punctuation,
|
---|
| 126 | string: string
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
| 129 | var keywords = {
|
---|
| 130 | pattern:
|
---|
| 131 | /((?:^|\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,
|
---|
| 132 | lookbehind: true
|
---|
| 133 | }
|
---|
| 134 | Prism.languages.sas = {
|
---|
| 135 | datalines: {
|
---|
| 136 | pattern: /^([ \t]*)(?:cards|(?:data)?lines);[\s\S]+?^[ \t]*;/im,
|
---|
| 137 | lookbehind: true,
|
---|
| 138 | alias: 'string',
|
---|
| 139 | inside: {
|
---|
| 140 | keyword: {
|
---|
| 141 | pattern: /^(?:cards|(?:data)?lines)/i
|
---|
| 142 | },
|
---|
| 143 | punctuation: /;/
|
---|
| 144 | }
|
---|
| 145 | },
|
---|
| 146 | 'proc-sql': {
|
---|
| 147 | pattern:
|
---|
| 148 | /(^proc\s+(?:fed)?sql(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|data|quit|run);|(?![\s\S]))/im,
|
---|
| 149 | lookbehind: true,
|
---|
| 150 | inside: {
|
---|
| 151 | sql: {
|
---|
| 152 | pattern: RegExp(
|
---|
| 153 | /^[ \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(
|
---|
| 154 | /<str>/g,
|
---|
| 155 | function () {
|
---|
| 156 | return stringPattern
|
---|
| 157 | }
|
---|
| 158 | ),
|
---|
| 159 | 'im'
|
---|
| 160 | ),
|
---|
| 161 | alias: 'language-sql',
|
---|
| 162 | inside: Prism.languages.sql
|
---|
| 163 | },
|
---|
| 164 | 'global-statements': globalStatements,
|
---|
| 165 | 'sql-statements': {
|
---|
| 166 | pattern:
|
---|
| 167 | /(^|\s)(?:disconnect\s+from|begin|commit|exec(?:ute)?|reset|rollback|validate)\b/i,
|
---|
| 168 | lookbehind: true,
|
---|
| 169 | alias: 'keyword'
|
---|
| 170 | },
|
---|
| 171 | number: number,
|
---|
| 172 | 'numeric-constant': numericConstant,
|
---|
| 173 | punctuation: punctuation,
|
---|
| 174 | string: string
|
---|
| 175 | }
|
---|
| 176 | },
|
---|
| 177 | 'proc-groovy': {
|
---|
| 178 | pattern:
|
---|
| 179 | /(^proc\s+groovy(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|data|quit|run);|(?![\s\S]))/im,
|
---|
| 180 | lookbehind: true,
|
---|
| 181 | inside: {
|
---|
| 182 | comment: comment,
|
---|
| 183 | groovy: {
|
---|
| 184 | pattern: RegExp(
|
---|
| 185 | /(^[ \t]*submit(?:\s+(?:load|norun|parseonly))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(
|
---|
| 186 | /<str>/g,
|
---|
| 187 | function () {
|
---|
| 188 | return stringPattern
|
---|
| 189 | }
|
---|
| 190 | ),
|
---|
| 191 | 'im'
|
---|
| 192 | ),
|
---|
| 193 | lookbehind: true,
|
---|
| 194 | alias: 'language-groovy',
|
---|
| 195 | inside: Prism.languages.groovy
|
---|
| 196 | },
|
---|
| 197 | keyword: keywords,
|
---|
| 198 | 'submit-statement': submitStatement,
|
---|
| 199 | 'global-statements': globalStatements,
|
---|
| 200 | number: number,
|
---|
| 201 | 'numeric-constant': numericConstant,
|
---|
| 202 | punctuation: punctuation,
|
---|
| 203 | string: string
|
---|
| 204 | }
|
---|
| 205 | },
|
---|
| 206 | 'proc-lua': {
|
---|
| 207 | pattern:
|
---|
| 208 | /(^proc\s+lua(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|data|quit|run);|(?![\s\S]))/im,
|
---|
| 209 | lookbehind: true,
|
---|
| 210 | inside: {
|
---|
| 211 | comment: comment,
|
---|
| 212 | lua: {
|
---|
| 213 | pattern: RegExp(
|
---|
| 214 | /(^[ \t]*submit(?:\s+(?:load|norun|parseonly))?)(?:<str>|[^"'])+?(?=endsubmit;)/.source.replace(
|
---|
| 215 | /<str>/g,
|
---|
| 216 | function () {
|
---|
| 217 | return stringPattern
|
---|
| 218 | }
|
---|
| 219 | ),
|
---|
| 220 | 'im'
|
---|
| 221 | ),
|
---|
| 222 | lookbehind: true,
|
---|
| 223 | alias: 'language-lua',
|
---|
| 224 | inside: Prism.languages.lua
|
---|
| 225 | },
|
---|
| 226 | keyword: keywords,
|
---|
| 227 | 'submit-statement': submitStatement,
|
---|
| 228 | 'global-statements': globalStatements,
|
---|
| 229 | number: number,
|
---|
| 230 | 'numeric-constant': numericConstant,
|
---|
| 231 | punctuation: punctuation,
|
---|
| 232 | string: string
|
---|
| 233 | }
|
---|
| 234 | },
|
---|
| 235 | 'proc-cas': {
|
---|
| 236 | pattern:
|
---|
| 237 | /(^proc\s+cas(?:\s+[\w|=]+)?;)[\s\S]+?(?=^(?:proc\s+\w+|quit|data);|(?![\s\S]))/im,
|
---|
| 238 | lookbehind: true,
|
---|
| 239 | inside: {
|
---|
| 240 | comment: comment,
|
---|
| 241 | 'statement-var': {
|
---|
| 242 | pattern: /((?:^|\s)=?)saveresult\s[^;]+/im,
|
---|
| 243 | lookbehind: true,
|
---|
| 244 | inside: {
|
---|
| 245 | statement: {
|
---|
| 246 | pattern: /^saveresult\s+\S+/i,
|
---|
| 247 | inside: {
|
---|
| 248 | keyword: /^(?:saveresult)/i
|
---|
| 249 | }
|
---|
| 250 | },
|
---|
| 251 | rest: args
|
---|
| 252 | }
|
---|
| 253 | },
|
---|
| 254 | 'cas-actions': casActions,
|
---|
| 255 | statement: {
|
---|
| 256 | pattern:
|
---|
| 257 | /((?:^|\s)=?)(?:default|(?:un)?set|on|output|upload)[^;]+/im,
|
---|
| 258 | lookbehind: true,
|
---|
| 259 | inside: args
|
---|
| 260 | },
|
---|
| 261 | step: step,
|
---|
| 262 | keyword: keywords,
|
---|
| 263 | function: func,
|
---|
| 264 | format: format,
|
---|
| 265 | altformat: altformat,
|
---|
| 266 | 'global-statements': globalStatements,
|
---|
| 267 | number: number,
|
---|
| 268 | 'numeric-constant': numericConstant,
|
---|
| 269 | punctuation: punctuation,
|
---|
| 270 | string: string
|
---|
| 271 | }
|
---|
| 272 | },
|
---|
| 273 | 'proc-args': {
|
---|
| 274 | pattern: RegExp(
|
---|
| 275 | /(^proc\s+\w+\s+)(?!\s)(?:[^;"']|<str>)+;/.source.replace(
|
---|
| 276 | /<str>/g,
|
---|
| 277 | function () {
|
---|
| 278 | return stringPattern
|
---|
| 279 | }
|
---|
| 280 | ),
|
---|
| 281 | 'im'
|
---|
| 282 | ),
|
---|
| 283 | lookbehind: true,
|
---|
| 284 | inside: args
|
---|
| 285 | },
|
---|
| 286 | /*Special keywords within macros*/
|
---|
| 287 | 'macro-keyword': macroKeyword,
|
---|
| 288 | 'macro-variable': macroVariable,
|
---|
| 289 | 'macro-string-functions': {
|
---|
| 290 | pattern:
|
---|
| 291 | /((?:^|\s|=))%(?:BQUOTE|NRBQUOTE|NRQUOTE|NRSTR|QUOTE|STR)\(.*?(?:[^%]\))/i,
|
---|
| 292 | lookbehind: true,
|
---|
| 293 | inside: {
|
---|
| 294 | function: {
|
---|
| 295 | pattern: /%(?:BQUOTE|NRBQUOTE|NRQUOTE|NRSTR|QUOTE|STR)/i,
|
---|
| 296 | alias: 'keyword'
|
---|
| 297 | },
|
---|
| 298 | 'macro-keyword': macroKeyword,
|
---|
| 299 | 'macro-variable': macroVariable,
|
---|
| 300 | 'escaped-char': {
|
---|
| 301 | pattern: /%['"()<>=¬^~;,#]/
|
---|
| 302 | },
|
---|
| 303 | punctuation: punctuation
|
---|
| 304 | }
|
---|
| 305 | },
|
---|
| 306 | 'macro-declaration': {
|
---|
| 307 | pattern: /^%macro[^;]+(?=;)/im,
|
---|
| 308 | inside: {
|
---|
| 309 | keyword: /%macro/i
|
---|
| 310 | }
|
---|
| 311 | },
|
---|
| 312 | 'macro-end': {
|
---|
| 313 | pattern: /^%mend[^;]+(?=;)/im,
|
---|
| 314 | inside: {
|
---|
| 315 | keyword: /%mend/i
|
---|
| 316 | }
|
---|
| 317 | },
|
---|
| 318 | /*%_zscore(headcir, _lhc, _mhc, _shc, headcz, headcpct, _Fheadcz); */
|
---|
| 319 | macro: {
|
---|
| 320 | pattern: /%_\w+(?=\()/,
|
---|
| 321 | alias: 'keyword'
|
---|
| 322 | },
|
---|
| 323 | input: {
|
---|
| 324 | pattern: /\binput\s[-\w\s/*.$&]+;/i,
|
---|
| 325 | inside: {
|
---|
| 326 | input: {
|
---|
| 327 | alias: 'keyword',
|
---|
| 328 | pattern: /^input/i
|
---|
| 329 | },
|
---|
| 330 | comment: comment,
|
---|
| 331 | number: number,
|
---|
| 332 | 'numeric-constant': numericConstant
|
---|
| 333 | }
|
---|
| 334 | },
|
---|
| 335 | 'options-args': {
|
---|
| 336 | pattern: /(^options)[-'"|/\\<>*+=:()\w\s]*(?=;)/im,
|
---|
| 337 | lookbehind: true,
|
---|
| 338 | inside: args
|
---|
| 339 | },
|
---|
| 340 | 'cas-actions': casActions,
|
---|
| 341 | comment: comment,
|
---|
| 342 | function: func,
|
---|
| 343 | format: format,
|
---|
| 344 | altformat: altformat,
|
---|
| 345 | 'numeric-constant': numericConstant,
|
---|
| 346 | datetime: {
|
---|
| 347 | // '1jan2013'd, '9:25:19pm't, '18jan2003:9:27:05am'dt
|
---|
| 348 | pattern: RegExp(stringPattern + '(?:dt?|t)'),
|
---|
| 349 | alias: 'number'
|
---|
| 350 | },
|
---|
| 351 | string: string,
|
---|
| 352 | step: step,
|
---|
| 353 | keyword: keywords,
|
---|
| 354 | // In SAS Studio syntax highlighting, these operators are styled like keywords
|
---|
| 355 | 'operator-keyword': {
|
---|
| 356 | pattern: /\b(?:eq|ge|gt|in|le|lt|ne|not)\b/i,
|
---|
| 357 | alias: 'operator'
|
---|
| 358 | },
|
---|
| 359 | // Decimal (1.2e23), hexadecimal (0c1x)
|
---|
| 360 | number: number,
|
---|
| 361 | operator: /\*\*?|\|\|?|!!?|¦¦?|<[>=]?|>[<=]?|[-+\/=&]|[~¬^]=?/,
|
---|
| 362 | punctuation: punctuation
|
---|
| 363 | }
|
---|
| 364 | })(Prism)
|
---|
| 365 | }
|
---|