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