3 " Maintainer: James Kidd <james.kidd@covance.com>
4 " Last Change: 18 Jul 2008 by Paulo Tanimoto <ptanimoto@gmail.com>
5 " Fixed comments with * taking multiple lines.
6 " Fixed highlighting of macro keywords.
7 " Added words to cases that didn't fit anywhere.
9 " Added highlighting for additional keywords and such;
10 " Attempted to match SAS default syntax colors;
11 " Changed syncing so it doesn't lose colors on large blocks;
12 " Much thanks to Bob Heckel for knowledgeable tweaking.
13 " For version 5.x: Clear all syntax items
14 " For version 6.x: Quit when a syntax file was already loaded
17 elseif exists("b:current_syntax")
23 syn region sasString start=+"+ skip=+\\\\\|\\"+ end=+"+
24 syn region sasString start=+'+ skip=+\\\\\|\\"+ end=+'+
26 " Want region from 'cards;' to ';' to be captured (Bob Heckel)
27 syn region sasCards start="^\s*CARDS.*" end="^\s*;\s*$"
28 syn region sasCards start="^\s*DATALINES.*" end="^\s*;\s*$"
30 syn match sasNumber "-\=\<\d*\.\=[0-9_]\>"
33 syn region sasComment start="/\*" end="\*/" contains=sasTodo
35 " Ignore misleading //JCL SYNTAX... (Bob Heckel)
36 syn region sasComment start="[^/][^/]/\*" end="\*/" contains=sasTodo
38 " Previous code for comments was written by Bob Heckel
39 " Comments with * may take multiple lines (Paulo Tanimoto)
40 syn region sasComment start=";\s*\*"hs=s+1 end=";" contains=sasTodo
42 " Comments with * starting after a semicolon (Paulo Tanimoto)
43 syn region sasComment start="^\s*\*" end=";" contains=sasTodo
45 " This line defines macro variables in code. HiLink at end of file
46 " defines the color scheme. Begin region with ampersand and end with
47 " any non-word character offset by -1; put ampersand in the skip list
48 " just in case it is used to concatenate macro variable values.
50 " Thanks to ronald höllwarth for this fix to an intra-versioning
51 " problem with this little feature
54 syn region sasMacroVar start="\&" skip="[_&]" end="\W"he=e-1
55 else " for the older Vim's just do it their way ...
56 syn region sasMacroVar start="&" skip="[_&]" end="\W"he=e-1
60 " I dont think specific PROCs need to be listed if use this line (Bob Heckel).
61 syn match sasProc "^\s*PROC \w\+"
62 syn keyword sasStep RUN QUIT DATA
65 " Base SAS Procs - version 8.1
67 syn keyword sasConditional DO ELSE END IF THEN UNTIL WHILE
69 syn keyword sasStatement ABORT ARRAY ATTRIB BY CALL CARDS CARDS4 CATNAME
70 syn keyword sasStatement CONTINUE DATALINES DATALINES4 DELETE DISPLAY
71 syn keyword sasStatement DM DROP ENDSAS ERROR FILE FILENAME FOOTNOTE
72 syn keyword sasStatement FORMAT GOTO INFILE INFORMAT INPUT KEEP
73 syn keyword sasStatement LABEL LEAVE LENGTH LIBNAME LINK LIST LOSTCARD
74 syn keyword sasStatement MERGE MISSING MODIFY OPTIONS OUTPUT PAGE
75 syn keyword sasStatement PUT REDIRECT REMOVE RENAME REPLACE RETAIN
76 syn keyword sasStatement RETURN SELECT SET SKIP STARTSAS STOP TITLE
77 syn keyword sasStatement UPDATE WAITSAS WHERE WINDOW X SYSTASK
79 " Keywords that are used in Proc SQL
80 " I left them as statements because SAS's enhanced editor highlights
81 " them the same as normal statements used in data steps (Jim Kidd)
83 syn keyword sasStatement ADD AND ALTER AS CASCADE CHECK CREATE
84 syn keyword sasStatement DELETE DESCRIBE DISTINCT DROP FOREIGN
85 syn keyword sasStatement FROM GROUP HAVING INDEX INSERT INTO IN
86 syn keyword sasStatement KEY LIKE MESSAGE MODIFY MSGTYPE NOT
87 syn keyword sasStatement NULL ON OR ORDER PRIMARY REFERENCES
88 syn keyword sasStatement RESET RESTRICT SELECT SET TABLE
89 syn keyword sasStatement UNIQUE UPDATE VALIDATE VIEW WHERE
91 " Match declarations have to appear one per line (Paulo Tanimoto)
92 syn match sasStatement "FOOTNOTE\d"
93 syn match sasStatement "TITLE\d"
95 " Match declarations have to appear one per line (Paulo Tanimoto)
96 syn match sasMacro "%BQUOTE"
97 syn match sasMacro "%NRBQUOTE"
98 syn match sasMacro "%CMPRES"
99 syn match sasMacro "%QCMPRES"
100 syn match sasMacro "%COMPSTOR"
101 syn match sasMacro "%DATATYP"
102 syn match sasMacro "%DISPLAY"
103 syn match sasMacro "%DO"
104 syn match sasMacro "%ELSE"
105 syn match sasMacro "%END"
106 syn match sasMacro "%EVAL"
107 syn match sasMacro "%GLOBAL"
108 syn match sasMacro "%GOTO"
109 syn match sasMacro "%IF"
110 syn match sasMacro "%INDEX"
111 syn match sasMacro "%INPUT"
112 syn match sasMacro "%KEYDEF"
113 syn match sasMacro "%LABEL"
114 syn match sasMacro "%LEFT"
115 syn match sasMacro "%LENGTH"
116 syn match sasMacro "%LET"
117 syn match sasMacro "%LOCAL"
118 syn match sasMacro "%LOWCASE"
119 syn match sasMacro "%MACRO"
120 syn match sasMacro "%MEND"
121 syn match sasMacro "%NRBQUOTE"
122 syn match sasMacro "%NRQUOTE"
123 syn match sasMacro "%NRSTR"
124 syn match sasMacro "%PUT"
125 syn match sasMacro "%QCMPRES"
126 syn match sasMacro "%QLEFT"
127 syn match sasMacro "%QLOWCASE"
128 syn match sasMacro "%QSCAN"
129 syn match sasMacro "%QSUBSTR"
130 syn match sasMacro "%QSYSFUNC"
131 syn match sasMacro "%QTRIM"
132 syn match sasMacro "%QUOTE"
133 syn match sasMacro "%QUPCASE"
134 syn match sasMacro "%SCAN"
135 syn match sasMacro "%STR"
136 syn match sasMacro "%SUBSTR"
137 syn match sasMacro "%SUPERQ"
138 syn match sasMacro "%SYSCALL"
139 syn match sasMacro "%SYSEVALF"
140 syn match sasMacro "%SYSEXEC"
141 syn match sasMacro "%SYSFUNC"
142 syn match sasMacro "%SYSGET"
143 syn match sasMacro "%SYSLPUT"
144 syn match sasMacro "%SYSPROD"
145 syn match sasMacro "%SYSRC"
146 syn match sasMacro "%SYSRPUT"
147 syn match sasMacro "%THEN"
148 syn match sasMacro "%TO"
149 syn match sasMacro "%TRIM"
150 syn match sasMacro "%UNQUOTE"
151 syn match sasMacro "%UNTIL"
152 syn match sasMacro "%UPCASE"
153 syn match sasMacro "%VERIFY"
154 syn match sasMacro "%WHILE"
155 syn match sasMacro "%WINDOW"
159 syn keyword sasFunction ABS ADDR AIRY ARCOS ARSIN ATAN ATTRC ATTRN
160 syn keyword sasFunction BAND BETAINV BLSHIFT BNOT BOR BRSHIFT BXOR
161 syn keyword sasFunction BYTE CDF CEIL CEXIST CINV CLOSE CNONCT COLLATE
162 syn keyword sasFunction COMPBL COMPOUND COMPRESS COS COSH CSS CUROBS
163 syn keyword sasFunction CV DACCDB DACCDBSL DACCSL DACCSYD DACCTAB
164 syn keyword sasFunction DAIRY DATE DATEJUL DATEPART DATETIME DAY
165 syn keyword sasFunction DCLOSE DEPDB DEPDBSL DEPDBSL DEPSL DEPSL
166 syn keyword sasFunction DEPSYD DEPSYD DEPTAB DEPTAB DEQUOTE DHMS
167 syn keyword sasFunction DIF DIGAMMA DIM DINFO DNUM DOPEN DOPTNAME
168 syn keyword sasFunction DOPTNUM DREAD DROPNOTE DSNAME ERF ERFC EXIST
169 syn keyword sasFunction EXP FAPPEND FCLOSE FCOL FDELETE FETCH FETCHOBS
170 syn keyword sasFunction FEXIST FGET FILEEXIST FILENAME FILEREF FINFO
171 syn keyword sasFunction FINV FIPNAME FIPNAMEL FIPSTATE FLOOR FNONCT
172 syn keyword sasFunction FNOTE FOPEN FOPTNAME FOPTNUM FPOINT FPOS
173 syn keyword sasFunction FPUT FREAD FREWIND FRLEN FSEP FUZZ FWRITE
174 syn keyword sasFunction GAMINV GAMMA GETOPTION GETVARC GETVARN HBOUND
175 syn keyword sasFunction HMS HOSTHELP HOUR IBESSEL INDEX INDEXC
176 syn keyword sasFunction INDEXW INPUT INPUTC INPUTN INT INTCK INTNX
177 syn keyword sasFunction INTRR IRR JBESSEL JULDATE KURTOSIS LAG LBOUND
178 syn keyword sasFunction LEFT LENGTH LGAMMA LIBNAME LIBREF LOG LOG10
179 syn keyword sasFunction LOG2 LOGPDF LOGPMF LOGSDF LOWCASE MAX MDY
180 syn keyword sasFunction MEAN MIN MINUTE MOD MONTH MOPEN MORT N
181 syn keyword sasFunction NETPV NMISS NORMAL NOTE NPV OPEN ORDINAL
182 syn keyword sasFunction PATHNAME PDF PEEK PEEKC PMF POINT POISSON POKE
183 syn keyword sasFunction PROBBETA PROBBNML PROBCHI PROBF PROBGAM
184 syn keyword sasFunction PROBHYPR PROBIT PROBNEGB PROBNORM PROBT PUT
185 syn keyword sasFunction PUTC PUTN QTR QUOTE RANBIN RANCAU RANEXP
186 syn keyword sasFunction RANGAM RANGE RANK RANNOR RANPOI RANTBL RANTRI
187 syn keyword sasFunction RANUNI REPEAT RESOLVE REVERSE REWIND RIGHT
188 syn keyword sasFunction ROUND SAVING SCAN SDF SECOND SIGN SIN SINH
189 syn keyword sasFunction SKEWNESS SOUNDEX SPEDIS SQRT STD STDERR STFIPS
190 syn keyword sasFunction STNAME STNAMEL SUBSTR SUM SYMGET SYSGET SYSMSG
191 syn keyword sasFunction SYSPROD SYSRC SYSTEM TAN TANH TIME TIMEPART
192 syn keyword sasFunction TINV TNONCT TODAY TRANSLATE TRANWRD TRIGAMMA
193 syn keyword sasFunction TRIM TRIMN TRUNC UNIFORM UPCASE USS VAR
194 syn keyword sasFunction VARFMT VARINFMT VARLABEL VARLEN VARNAME
195 syn keyword sasFunction VARNUM VARRAY VARRAYX VARTYPE VERIFY VFORMAT
196 syn keyword sasFunction VFORMATD VFORMATDX VFORMATN VFORMATNX VFORMATW
197 syn keyword sasFunction VFORMATWX VFORMATX VINARRAY VINARRAYX VINFORMAT
198 syn keyword sasFunction VINFORMATD VINFORMATDX VINFORMATN VINFORMATNX
199 syn keyword sasFunction VINFORMATW VINFORMATWX VINFORMATX VLABEL
200 syn keyword sasFunction VLABELX VLENGTH VLENGTHX VNAME VNAMEX VTYPE
201 syn keyword sasFunction VTYPEX WEEKDAY YEAR YYQ ZIPFIPS ZIPNAME ZIPNAMEL
202 syn keyword sasFunction ZIPSTATE
204 " Handy settings for using vim with log files
205 syn keyword sasLogMsg NOTE
206 syn keyword sasWarnMsg WARNING
207 syn keyword sasErrMsg ERROR
209 " Always contained in a comment (Bob Heckel)
210 syn keyword sasTodo TODO TBD FIXME contained
212 " These don't fit anywhere else (Bob Heckel).
213 " Added others that were missing.
214 syn match sasUnderscore "_ALL_"
215 syn match sasUnderscore "_AUTOMATIC_"
216 syn match sasUnderscore "_CHARACTER_"
217 syn match sasUnderscore "_INFILE_"
218 syn match sasUnderscore "_N_"
219 syn match sasUnderscore "_NAME_"
220 syn match sasUnderscore "_NULL_"
221 syn match sasUnderscore "_NUMERIC_"
222 syn match sasUnderscore "_USER_"
223 syn match sasUnderscore "_WEBOUT_"
225 " End of SAS Functions
227 " Define the default highlighting.
228 " For version 5.7 and earlier: only when not done already
229 " For version 5.8 and later: only when an item doesn't have highlighting yet
231 if version >= 508 || !exists("did_sas_syntax_inits")
233 let did_sas_syntax_inits = 1
234 command -nargs=+ HiLink hi link <args>
236 command -nargs=+ HiLink hi def link <args>
239 " Default sas enhanced editor color syntax
240 hi sComment term=bold cterm=NONE ctermfg=Green ctermbg=Black gui=NONE guifg=DarkGreen guibg=White
241 hi sCard term=bold cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Black guibg=LightYellow
242 hi sDate_Time term=NONE cterm=bold ctermfg=Green ctermbg=Black gui=bold guifg=SeaGreen guibg=White
243 hi sKeyword term=NONE cterm=NONE ctermfg=Blue ctermbg=Black gui=NONE guifg=Blue guibg=White
244 hi sFmtInfmt term=NONE cterm=NONE ctermfg=LightGreen ctermbg=Black gui=NONE guifg=SeaGreen guibg=White
245 hi sString term=NONE cterm=NONE ctermfg=Magenta ctermbg=Black gui=NONE guifg=Purple guibg=White
246 hi sText term=NONE cterm=NONE ctermfg=White ctermbg=Black gui=bold guifg=Black guibg=White
247 hi sNumber term=NONE cterm=bold ctermfg=Green ctermbg=Black gui=bold guifg=SeaGreen guibg=White
248 hi sProc term=NONE cterm=bold ctermfg=Blue ctermbg=Black gui=bold guifg=Navy guibg=White
249 hi sSection term=NONE cterm=bold ctermfg=Blue ctermbg=Black gui=bold guifg=Navy guibg=White
250 hi mDefine term=NONE cterm=bold ctermfg=White ctermbg=Black gui=bold guifg=Black guibg=White
251 hi mKeyword term=NONE cterm=NONE ctermfg=Blue ctermbg=Black gui=NONE guifg=Blue guibg=White
252 hi mReference term=NONE cterm=bold ctermfg=White ctermbg=Black gui=bold guifg=Blue guibg=White
253 hi mSection term=NONE cterm=NONE ctermfg=Blue ctermbg=Black gui=bold guifg=Navy guibg=White
254 hi mText term=NONE cterm=NONE ctermfg=White ctermbg=Black gui=bold guifg=Black guibg=White
256 " Colors that closely match SAS log colors for default color scheme
257 hi lError term=NONE cterm=NONE ctermfg=Red ctermbg=Black gui=none guifg=Red guibg=White
258 hi lWarning term=NONE cterm=NONE ctermfg=Green ctermbg=Black gui=none guifg=Green guibg=White
259 hi lNote term=NONE cterm=NONE ctermfg=Cyan ctermbg=Black gui=none guifg=Blue guibg=White
262 " Special hilighting for the SAS proc section
264 HiLink sasComment sComment
265 HiLink sasConditional sKeyword
266 HiLink sasStep sSection
267 HiLink sasFunction sKeyword
268 HiLink sasMacro mKeyword
269 HiLink sasMacroVar NonText
270 HiLink sasNumber sNumber
271 HiLink sasStatement sKeyword
272 HiLink sasString sString
276 HiLink sasErrMsg lError
277 HiLink sasWarnMsg lWarning
278 HiLink sasLogMsg lNote
279 HiLink sasCards sCard
281 HiLink sasUnderscore PreProc
285 " Syncronize from beginning to keep large blocks from losing
286 " syntax coloring while moving through code.
289 let b:current_syntax = "sas"