Skip to content

Commit

Permalink
SAS: Improved macro string functions (PrismJS#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedporter authored and quentinvernot committed Sep 11, 2020
1 parent 4e01518 commit f73499e
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 208 deletions.
31 changes: 18 additions & 13 deletions components/prism-sas.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
alias: 'number'
};

var macroVariable = {
pattern: /&[a-z_][a-z_0-9]*/i
};

var macroKeyword = {
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,
lookbehind: true,
alias: 'keyword'
};

var step = {
pattern: /(^|\s+)(?:proc\s+\w+|quit|run|data(?!\=))\b/i,
alias: 'keyword',
Expand Down Expand Up @@ -41,10 +51,7 @@
lookbehind: true
},
'operator': /=/,
'macro-variable': {
pattern: /&[^\.]*\./i,
alias: 'string'
},
'macro-variable': macroVariable,
'arg': {
pattern: /[A-Z]+/i,
alias: 'keyword'
Expand Down Expand Up @@ -237,6 +244,9 @@
lookbehind: true,
inside: args
},
/*Special keywords within macros*/
'macro-keyword': macroKeyword,
'macro-variable': macroVariable,
'macro-string-functions': {
pattern: /((?:^|\s|=))%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)\(.*?(?:[^%]\))/i,
lookbehind: true,
Expand All @@ -245,19 +255,14 @@
pattern: /%(?:NRBQUOTE|NRQUOTE|NRSTR|BQUOTE|QUOTE|STR)/i,
alias: 'keyword'
},
'string': {
pattern: /(\()[^)]+/,
lookbehind: true
'macro-keyword': macroKeyword,
'macro-variable': macroVariable,
'escaped-char': {
pattern: /%['"()<>=¬^~;,#]/i,
},
'punctuation': punctuation
}
},
/*Special keywords within macros*/
'macro-keyword': {
pattern: /((?:^|\s)=?)%(?:ABORT|BQUOTE|BY|CMS|COPY|DISPLAY|DO|ELSE|END|EVAL|GLOBAL|GO|GOTO|IF|INC|INCLUDE|INDEX|INPUT|KTRIM|LENGTH|LET|LIST|LOCAL|NRBQUOTE|NRQUOTE|NRSTR|PUT|QKTRIM|QSCAN|QSUBSTR|QSYSFUNC|QUOTE|QUPCASE|RETURN|RUN|SCAN|STR|SUBSTR|SUPERQ|SYMDEL|SYMGLOBL|SYMLOCAL|SYMEXIST|SYSCALL|SYSEVALF|SYSEXEC|SYSFUNC|SYSGET|SYSRPUT|THEN|TO|TSO|UNQUOTE|UNTIL|UPCASE|WHILE|WINDOW)\b/i,
lookbehind: true,
alias: 'keyword'
},
'macro-declaration': {
pattern: /^%macro[^;]+(?=;)/im,
inside: {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-sas.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f73499e

Please sign in to comment.