~ubuntu-branches/ubuntu/natty/ess/natty

« back to all changes in this revision

Viewing changes to lisp/essl-sas.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-04-28 16:27:11 UTC
  • mto: (3.1.1 etch) (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060428162711-u9n7jsygfnd59r3i
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
239
239
(modify-syntax-entry ?/  ". 14"  SAS-syntax-table) ; comment character
240
240
(modify-syntax-entry ?.  "w"  SAS-syntax-table))
241
241
 
242
 
(if (or window-system
243
 
        noninteractive) ; compilation!
244
 
    (progn
245
 
      (require 'font-lock)
246
 
 
247
 
      (defvar SAS-mode-font-lock-keywords
248
 
        (if ess-sas-run-make-regexp
249
 
        (list
250
 
         ;; SAS comments
251
 
         (cons "^[ \t]*%?\\*.*;"                font-lock-comment-face)
252
 
         (cons ";[ \t]*%?\\*.*;"                font-lock-comment-face)
253
 
         (list "/\\*\\([^*/]\\)*\\*/"      0  font-lock-comment-face t)
254
 
 
255
 
         ;; SAS execution blocks, DATA/RUN, PROC/RUN, %MACRO/%MEND
256
 
         (cons "\\<\\(data\\|run\\|%macro\\|%mend\\)\\>" font-lock-reference-face)
257
 
         (cons "\\<proc[ \t]+[a-z][a-z_0-9]+"            font-lock-reference-face)
258
 
 
259
 
         ;; SAS statements
260
 
 
261
 
         (cons (concat
262
 
                "\\<"
263
 
                "%?do[ \t]*" (make-regexp '("over" "%?until" "%?while") t) "?"
264
 
                "\\>")
265
 
               font-lock-keyword-face)
266
 
 
267
 
         (cons (concat
268
 
                "\\<"
269
 
                (make-regexp
270
 
                 '(
271
 
                   "abort" "array" "attrib" "by" "delete" "display" "dm"
272
 
                   "drop" "error" "file" "filename" "footnote\\(10?\\|[2-9]\\)?"
273
 
                   "format"
274
 
                   "%go[ \t]*to" "%if" "%then" "%else"
275
 
                   "go[ \t]*to" "if" "then" "else"
276
 
                   "infile" "informat" "input" "%input" "keep" "label"
277
 
                   "length" "libname" "link"
278
 
                   "merge" "missing" "modify" "note" "options" "goptions" "output"
279
 
                   "otherwise" "put" "%put" "rename" "retain" "select" "when" "set"
280
 
                   "skip" "title\\(10?\\|[2-9]\\)?" "where" "window" "update" "out"
281
 
                   "change" "class" "exchange" "exclude" "freq" "id" "index"
282
 
                   "model" "plot" "save" "sum" "tables?" "var" "weight" "with"
283
 
                   "manova" "repeated" "value" "random" "means" "lsmeans"
284
 
                   ;; SAS macro statements not handled above
285
 
                   "%global" "%include" "%local" "%let" "%sysexec"
286
 
                   ) t) "\\>")
287
 
               font-lock-keyword-face)
288
 
 
289
 
         ;; SAS statements that must be followed by a semi-colon
290
 
         (cons (concat
291
 
                "\\<"
292
 
                (make-regexp
293
 
                 '(
294
 
                   "cards4?" "end" "%end" "endsas" "list" "lostcard" "page"
295
 
                   "return" "stop"
296
 
                   ) t) "\\>" "[ \t]*;")
297
 
               font-lock-keyword-face)
298
 
 
299
 
         ;; SAS/GRAPH statements not handled above
300
 
         (cons (concat
301
 
                "\\<"
302
 
                (make-regexp
303
 
                 '("axis" "legend" "pattern" "symbol") t) "\\([1-9][0-9]?\\)?"
304
 
                "\\>")
305
 
               font-lock-keyword-face)
306
 
 
307
 
         ;; SAS functions and SAS macro functions
308
 
         (cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
309
 
               font-lock-function-name-face)
310
 
         (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
311
 
               font-lock-function-name-face)
312
 
 
313
 
         (cons (concat
314
 
                "\\<"
315
 
                (make-regexp
316
 
                 '(
317
 
                   "abs" "arcos" "arsin" "atan" "betainv" "byte" "ceil" "cinv"
318
 
                   "collate" "compress" "cosh?" "css" "cv"
319
 
                   "daccdb" "daccdbsl" "daccsl" "daccsyd" "dacctab"
320
 
                   "depdb" "depdbsl" "depsl" "depsyd" "deptab"
321
 
                   "date" "datejul" "datepart" "datetime" "day" "hms" "dhms" "dif"
322
 
                   "digamma" "dim" "erfc?" "exp" "finv"
323
 
                   "fipnamel?" "fipstate" "floor" "fuzz" "gaminv" "gamma"
324
 
                   "hbound" "hour" "indexc?" "input" "int" "intck" "intnx" "intrr"
325
 
                   "irr" "juldate" "kurtosis" "lag" "lbound" "left" "length"
326
 
                   "lgamma" "log" "log10" "log2" "max" "mdy" "mean" "min" "minute"
327
 
                   "mod" "month" "mort" "n" "netpv" "nmiss" "normal" "npv"
 
242
(require 'font-lock); fontification also works in terminals!
 
243
;; (if (or window-system
 
244
;;      noninteractive) ; compilation!
 
245
;;; ...
 
246
 
 
247
 
 
248
(defvar SAS-mode-font-lock-keywords
 
249
  (if ess-sas-run-make-regexp
 
250
      (list
 
251
       ;; SAS comments
 
252
       (cons "^[ \t]*%?\\*.*;"          font-lock-comment-face)
 
253
       (cons ";[ \t]*%?\\*.*;"          font-lock-comment-face)
 
254
       (list "/\\*\\([^*/]\\)*\\*/"      0  font-lock-comment-face t)
 
255
 
 
256
       ;; SAS execution blocks, DATA/RUN, PROC/RUN, %MACRO/%MEND
 
257
       (cons "\\<\\(data\\|run\\|%macro\\|%mend\\)\\>" font-lock-constant-face)
 
258
       (cons "\\<proc[ \t]+[a-z][a-z_0-9]+"            font-lock-constant-face)
 
259
 
 
260
       ;; SAS statements
 
261
 
 
262
       (cons (concat
 
263
              "\\<"
 
264
              "%?do[ \t]*" (make-regexp '("over" "%?until" "%?while") t) "?"
 
265
              "\\>")
 
266
             font-lock-keyword-face)
 
267
 
 
268
       (cons (concat
 
269
              "\\<"
 
270
              (make-regexp
 
271
               '(
 
272
                 "abort" "array" "attrib" "by" "delete" "display" "dm"
 
273
                 "drop" "error" "file" "filename" "footnote\\(10?\\|[2-9]\\)?"
 
274
                 "format"
 
275
                 "%go[ \t]*to" "%if" "%then" "%else"
 
276
                 "go[ \t]*to" "if" "then" "else"
 
277
                 "infile" "informat" "input" "%input" "keep" "label"
 
278
                 "length" "libname" "link"
 
279
                 "merge" "missing" "modify" "note" "options" "goptions" "output"
 
280
                 "otherwise" "put" "%put" "rename" "retain" "select" "when" "set"
 
281
                 "skip" "title\\(10?\\|[2-9]\\)?" "where" "window" "update" "out"
 
282
                 "change" "class" "exchange" "exclude" "freq" "id" "index"
 
283
                 "model" "plot" "save" "sum" "tables?" "var" "weight" "with"
 
284
                 "manova" "repeated" "value" "random" "means" "lsmeans"
 
285
                 ;; SAS macro statements not handled above
 
286
                 "%global" "%include" "%local" "%let" "%sysexec"
 
287
                 ) t) "\\>")
 
288
             font-lock-keyword-face)
 
289
 
 
290
       ;; SAS statements that must be followed by a semi-colon
 
291
       (cons (concat
 
292
              "\\<"
 
293
              (make-regexp
 
294
               '(
 
295
                 "cards4?" "end" "%end" "endsas" "list" "lostcard" "page"
 
296
                 "return" "stop"
 
297
                 ) t) "\\>" "[ \t]*;")
 
298
             font-lock-keyword-face)
 
299
 
 
300
       ;; SAS/GRAPH statements not handled above
 
301
       (cons (concat
 
302
              "\\<"
 
303
              (make-regexp
 
304
               '("axis" "legend" "pattern" "symbol") t) "\\([1-9][0-9]?\\)?"
 
305
              "\\>")
 
306
             font-lock-keyword-face)
 
307
 
 
308
       ;; SAS functions and SAS macro functions
 
309
       (cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
 
310
             font-lock-function-name-face)
 
311
       (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
 
312
             font-lock-function-name-face)
 
313
 
 
314
       (cons (concat
 
315
              "\\<"
 
316
              (make-regexp
 
317
               '(
 
318
                 "abs" "arcos" "arsin" "atan" "betainv" "byte" "ceil" "cinv"
 
319
                 "collate" "compress" "cosh?" "css" "cv"
 
320
                 "daccdb" "daccdbsl" "daccsl" "daccsyd" "dacctab"
 
321
                 "depdb" "depdbsl" "depsl" "depsyd" "deptab"
 
322
                 "date" "datejul" "datepart" "datetime" "day" "hms" "dhms" "dif"
 
323
                 "digamma" "dim" "erfc?" "exp" "finv"
 
324
                 "fipnamel?" "fipstate" "floor" "fuzz" "gaminv" "gamma"
 
325
                 "hbound" "hour" "indexc?" "input" "int" "intck" "intnx" "intrr"
 
326
                 "irr" "juldate" "kurtosis" "lag" "lbound" "left" "length"
 
327
                 "lgamma" "log" "log10" "log2" "max" "mdy" "mean" "min" "minute"
 
328
                 "mod" "month" "mort" "n" "netpv" "nmiss" "normal" "npv"
328
329
;;;) t) "\\>" "[ \t]*(")
329
330
;;;      font-lock-function-name-face)
330
331
;;;
331
332
;;;    (cons (concat "\\<"
332
333
;;;(make-regexp '(
333
 
                   "probbeta" "probbnml" "probchi" "probf" "probgam" "probhypr"
334
 
                   "probit" "probnegb" "probnorm" "probt"
335
 
                   "ordinal" "poisson" "put" "qtr" "range" "rank" "repeat"
336
 
                   "ranbin" "rancau" "ranexp" "rangam" "rannor" "ranpoi"
337
 
                   "rantbl" "rantri" "ranuni"
338
 
                   "reverse" "right" "round" "saving" "scan" "second" "sign" "sinh?"
339
 
                   "sqrt" "std" "stderr" "stfips" "stnamel?" "substr" "sum"
340
 
                   "symget" "tanh?" "time" "timepart" "tinv" "today" "translate"
341
 
                   "trigamma" "trim" "trunc" "uniform" "upcase" "uss" "var"
342
 
                   "verify" "weekday" "year" "yyq"
343
 
                   "zipfips" "zipnamel?" "zipstate"
 
334
                 "probbeta" "probbnml" "probchi" "probf" "probgam" "probhypr"
 
335
                 "probit" "probnegb" "probnorm" "probt"
 
336
                 "ordinal" "poisson" "put" "qtr" "range" "rank" "repeat"
 
337
                 "ranbin" "rancau" "ranexp" "rangam" "rannor" "ranpoi"
 
338
                 "rantbl" "rantri" "ranuni"
 
339
                 "reverse" "right" "round" "saving" "scan" "second" "sign" "sinh?"
 
340
                 "sqrt" "std" "stderr" "stfips" "stnamel?" "substr" "sum"
 
341
                 "symget" "tanh?" "time" "timepart" "tinv" "today" "translate"
 
342
                 "trigamma" "trim" "trunc" "uniform" "upcase" "uss" "var"
 
343
                 "verify" "weekday" "year" "yyq"
 
344
                 "zipfips" "zipnamel?" "zipstate"
344
345
;;;) t) "\\>" "[ \t]*(")
345
346
;;;      font-lock-function-name-face)
346
347
;;;
349
350
;;;    ;; SCL functions that are known to work with SAS macro function %sysfunc
350
351
;;;    (cons (concat "\\<"
351
352
;;;(make-regexp '(
352
 
                   "airy" "band" "blshift" "brshift" "bnot" "bor" "bxor"
353
 
                   "cnonct" "fnonct" "tnonct" "compbl" "dairy" "dequote"
354
 
                   "ibessel" "jbessel"
355
 
                   "indexw" "inputc" "inputn"  "lowcase"
356
 
                   "putc" "putn" "quote" "resolve" "soundex" "sysprod"
357
 
                   "tranwrd" "trimn"
358
 
                   "%sysfunc" "attrc" "attrn" "cexist" "close" "dclose" "dnum"
359
 
                   "dopen" "dread" "exist" "fclose" "fetchobs" "fileexist"
360
 
                   "finfo" "fopen" "fput" "fwrite" "getoption"
361
 
                   "getvarc" "getvarn" "libname" "libref" "open" "optgetn" "optsetn"
362
 
                   "pathname" "sysmsg" "varfmt" "varlabel" "varnum" "vartype"
363
 
                   ) t) "\\>" "[ \t]*(")
364
 
               font-lock-function-name-face)
365
 
         )
366
 
        (list
367
 
         ;; .log NOTE: messages
368
 
         (cons "^NOTE: .*$"                         font-lock-reference-face)
369
 
 
370
 
         ;; .log ERROR: messages
371
 
         (cons "^ERROR: .*$"                        font-lock-keyword-face)
372
 
 
373
 
         ;; .log WARNING: messages
374
 
         (cons "^WARNING: .*$"                      font-lock-function-name-face)
375
 
 
376
 
         ;; SAS comments
377
 
;; /* */ handled by grammar above
378
 
;;       (list "/\\*.*\\*/"                      0  font-lock-comment-face t)
379
 
         (cons "\\(^[0-9]*\\|;\\)[ \t]*\\(%?\\*\\|comment\\).*\\(;\\|$\\)" font-lock-comment-face)
380
 
 
381
 
         ;; SAS execution blocks, DATA/RUN, PROC/RUN, SAS Macro Statements
382
 
         (cons "\\<%do[ \t]*\\(%until\\|%while\\)?\\>"
383
 
                                                    font-lock-reference-face)
384
 
         ;;(cons (concat "\\(^[0-9]*\\|;\\)[ \t]*"
385
 
                ;;"%\\(end\\|global\\|local\\|m\\(acro\\|end\\)\\)"
386
 
                ;;"\\>")                                    font-lock-reference-face)
387
 
         (cons "\\<%\\(end\\|global\\|local\\|m\\(acro\\|end\\)\\)\\>"
388
 
                                                    font-lock-reference-face)
389
 
 
390
 
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
391
 
                "\\(data\\|endsas\\|finish\\|quit\\|run\\|start\\)[ \t\n;]")
392
 
                                                    font-lock-reference-face)
393
 
         (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
394
 
                "proc[ \t]+[a-z][a-z_0-9]+")        font-lock-reference-face)
395
 
 
396
 
         ;;(cons (concat "\\(^[0-9]*\\|;\\|%then\\|%else\\)[ \t]*"
397
 
                ;;"\\(%\\(go[ \t]*to\\|i\\(f\\|n\\(clude\\|put\\)\\)\\|let\\|put\\|sysexec\\)\\)"
398
 
                ;;"\\>")                                    font-lock-reference-face)
399
 
         (cons "\\<%\\(go[ \t]*to\\|i\\(f\\|n\\(clude\\|put\\)\\)\\|let\\|put\\|sysexec\\)\\>"
400
 
                                                    font-lock-reference-face)
401
 
 
402
 
         (cons "\\<%\\(by\\|else\\|t\\(o\\|hen\\)\\)\\>"
403
 
                                                    font-lock-reference-face)
404
 
 
405
 
         ;; SAS dataset options/PROC statements followed by an equal sign/left parentheses
406
 
 
407
 
         (cons (concat
408
 
                "[ \t(,]"
409
 
                "\\(attrib\\|by\\|compress\\|d\\(ata\\|rop\\)\\|f\\(irstobs\\|ormat\\)"
410
 
                "\\|i\\(d\\|f\\|n\\)\\|ke\\(ep\\|y\\)\\|l\\(abel\\|ength\\)"
411
 
                "\\|o\\(bs\\|rder\\|ut\\)\\|rename\\|s\\(ortedby\\|plit\\)"
412
 
                "\\|var\\|where\\)"
413
 
                "[ \t]*=")
414
 
                                                    font-lock-keyword-face)
415
 
         (cons "\\<\\(in\\(:\\|dex[ \t]*=\\)?\\|until\\|wh\\(en\\|ile\\)\\)[ \t]*("
416
 
                                                    font-lock-keyword-face)
417
 
 
418
 
         ;; SAS statements
419
 
         (cons (concat
420
 
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
421
 
                "\\(a\\(bort\\|rray\\|ttrib\\)\\|by"
422
 
                "\\|c\\(hange\\|lass\\|ontrast\\)"
423
 
                "\\|d\\(elete\\|isplay\\|m\\|o\\([ \t]+\\(data\\|over\\)\\)?\\|rop\\)"
424
 
                "\\|e\\(rror\\|stimate\\|xc\\(hange\\|lude\\)\\)"
425
 
                "\\|f\\(ile\\(name\\)?\\|o\\(otnote\\(10?\\|[2-9]\\)?\\|rmat\\)\\|req\\)"
426
 
                "\\|go\\([ \t]*to\\|ptions\\)"
427
 
                "\\|i\\(d\\|f\\|n\\(dex\\|f\\(ile\\|ormat\\)\\|put\\|value\\)\\)"
428
 
                "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\|st\\)\\|smeans\\)"
429
 
                "\\|m\\(anova\\|e\\(ans\\|rge\\)\\|issing\\|od\\(el\\|ify\\)\\)\\|note"
430
 
                "\\|o\\(ptions\\|therwise\\|utput\\)\\|p\\(arms\\|lot\\|ut\\)"
431
 
                "\\|r\\(andom\\|e\\(name\\|peated\\|tain\\)\\)"
432
 
                "\\|s\\(ave\\|e\\(lect\\|t\\)\\|kip\\|trata\\|umby\\)"
433
 
                "\\|t\\(ables?\\|i\\(me\\|tle\\(10?\\|[2-9]\\)?\\)\\)\\|update"
434
 
                "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)"
435
 
 
436
 
        ;; IML statements that are not also SAS statements
437
 
                "\\|append\\|c\\(lose\\(file\\)?\\|reate\\)\\|edit\\|f\\(ind\\|orce\\|ree\\)"
438
 
                "\\|insert\\|load\\|mattrib\\|p\\(a[ru]se\\|rint\\|urge\\)"
439
 
                "\\|re\\(move\\|peat\\|place\\|set\\|sume\\)"
440
 
                "\\|s\\(et\\(in\\|out\\)\\|how\\|ort\\|tore\\|ummary\\)\\|use\\)?"
441
 
 
442
 
                "\\>")                              font-lock-keyword-face)
443
 
 
444
 
 
445
 
 
446
 
;;       (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
447
 
;;                                                  font-lock-keyword-face)
448
 
 
449
 
         ;; SAS statements that must be followed by a semi-colon
450
 
         (cons (concat
451
 
                "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
452
 
                "\\(cards4?\\|datalines\\|end\\|l\\(ostcard\\)\\|page\\|return\\|stop\\)?"
453
 
                "[ \t]*;")                          font-lock-keyword-face)
454
 
 
455
 
         ;; SAS/GRAPH statements not handled above
456
 
         (cons (concat
457
 
                "\\(^[0-9]*\\|):\\|[;,]\\)[ \t]*"
458
 
                "\\(axis\\|legend\\|pattern\\|symbol\\)"
459
 
                "\\([1-9][0-9]?\\)?\\>")            font-lock-keyword-face)
460
 
 
461
 
         ;; SAS Datastep functions and SAS macro functions
462
 
         ;(cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
463
 
         ;; SAS macro functions occasionally defined with no arguments
464
 
         (cons "%[a-z_][a-z_0-9]*[ \t();,]"
465
 
                                                    font-lock-function-name-face)
466
 
         (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
467
 
                                                    font-lock-function-name-face)
468
 
 
469
 
         (cons (concat
470
 
                "\\<"
471
 
                "\\(a\\(bs\\|r\\(cos\\|sin\\)\\|tan\\)\\|b\\(etainv\\|yte\\)"
472
 
                "\\|c\\(eil\\|inv\\|o\\(llate\\|mpress\\|sh?\\)\\|ss\\|v\\)"
473
 
                "\\|dacc\\(db\\(\\|sl\\)\\|s\\(l\\|yd\\)\\|tab\\)"
474
 
                "\\|dep\\(db\\(\\|sl\\)\\|s\\(l\\|yd\\)\\|tab\\)"
475
 
                "\\|d\\(a\\(te\\(\\|jul\\|part\\|time\\)\\|y\\)\\|hms\\|i\\([fm]\\|gamma\\)\\)"
476
 
                "\\|e\\(rfc?\\|xp\\)"
477
 
                "\\|f\\(i\\(nv\\|p\\(namel?\\|state\\)\\)\\|loor\\|uzz\\)\\|gam\\(inv\\|ma\\)"
478
 
                "\\|h\\(bound\\|ms\\|our\\)\\|i\\(n\\(dexc?\\|put\\|t\\(\\|ck\\|nx\\|rr\\)\\)\\|rr\\)"
479
 
                "\\|juldate\\|kurtosis\\|l\\(ag\\|bound\\|e\\(ft\\|ngth\\)\\|gamma\\|og\\(\\|10\\|2\\)\\)"
480
 
                "\\|m\\(ax\\|dy\\|ean\\|in\\(\\|ute\\)\\|o\\(d\\|nth\\|rt\\)\\)\\|n\\(\\|etpv\\|miss\\|ormal\\|pv\\)"
481
 
                "\\|prob\\([ft]\\|b\\(eta\\|nml\\)\\|chi\\|gam\\|hypr\\|it\\|n\\(egb\\|orm\\)\\)"
482
 
                "\\|ordinal\\|p\\(oisson\\|ut\\)\\|qtr\\|r\\(e\\(peat\\|verse\\)\\|ight\\|ound\\)"
483
 
                "\\|ran\\(bin\\|cau\\|exp\\|g\\(am\\|e\\)\\|k\\|nor\\|poi\\|t\\(bl\\|ri\\)\\|uni\\)"
484
 
                "\\|s\\(aving\\|can\\|econd\\|i\\(gn\\|nh?\\)\\|qrt\\|t\\(d\\(\\|err\\)\\|fips\\|namel?\\)\\|u\\(bstr\\|m\\)\\|ymget\\)"
485
 
                "\\|t\\(anh?\\|i\\(me\\(\\|part\\)\\|nv\\)\\|oday\\|r\\(anslate\\|i\\(gamma\\|m\\)\\|unc\\)\\)"
486
 
                "\\|u\\(niform\\|pcase\\|ss\\)\\|v\\(ar\\|erify\\)"
487
 
                "\\|weekday\\|y\\(ear\\|yq\\)\\|zip\\(fips\\|namel?\\|state\\)"
 
353
                 "airy" "band" "blshift" "brshift" "bnot" "bor" "bxor"
 
354
                 "cnonct" "fnonct" "tnonct" "compbl" "dairy" "dequote"
 
355
                 "ibessel" "jbessel"
 
356
                 "indexw" "inputc" "inputn"  "lowcase"
 
357
                 "putc" "putn" "quote" "resolve" "soundex" "sysprod"
 
358
                 "tranwrd" "trimn"
 
359
                 "%sysfunc" "attrc" "attrn" "cexist" "close" "dclose" "dnum"
 
360
                 "dopen" "dread" "exist" "fclose" "fetchobs" "fileexist"
 
361
                 "finfo" "fopen" "fput" "fwrite" "getoption"
 
362
                 "getvarc" "getvarn" "libname" "libref" "open" "optgetn" "optsetn"
 
363
                 "pathname" "sysmsg" "varfmt" "varlabel" "varnum" "vartype"
 
364
                 ) t) "\\>" "[ \t]*(")
 
365
             font-lock-function-name-face)
 
366
       )
 
367
    (list
 
368
     ;; .log NOTE: messages
 
369
     (cons "^NOTE: .*$"                         font-lock-constant-face)
 
370
 
 
371
     ;; .log ERROR: messages
 
372
     (cons "^ERROR: .*$"                        font-lock-keyword-face)
 
373
 
 
374
     ;; .log WARNING: messages
 
375
     (cons "^WARNING: .*$"                      font-lock-function-name-face)
 
376
 
 
377
     ;; SAS comments
 
378
     ;; /* */ handled by grammar above
 
379
     ;;  (list "/\\*.*\\*/"                      0  font-lock-comment-face t)
 
380
     (cons "\\(^[0-9]*\\|;\\)[ \t]*\\(%?\\*\\|comment\\).*\\(;\\|$\\)" font-lock-comment-face)
 
381
 
 
382
     ;; SAS execution blocks, DATA/RUN, PROC/RUN, SAS Macro Statements
 
383
     (cons "\\<%do[ \t]*\\(%until\\|%while\\)?\\>"
 
384
           font-lock-constant-face)
 
385
     ;;(cons (concat "\\(^[0-9]*\\|;\\)[ \t]*"
 
386
     ;;"%\\(end\\|global\\|local\\|m\\(acro\\|end\\)\\)"
 
387
     ;;"\\>")                               font-lock-constant-face)
 
388
     (cons "\\<%\\(end\\|global\\|local\\|m\\(acro\\|end\\)\\)\\>"
 
389
           font-lock-constant-face)
 
390
 
 
391
     (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
 
392
                   "\\(data\\|endsas\\|finish\\|quit\\|run\\|start\\)[ \t\n;]")
 
393
           font-lock-constant-face)
 
394
     (cons (concat "\\(^[0-9]*\\|;\\|):\\|%then\\|%else\\)[ \t]*"
 
395
                   ;;"proc[ \t]+[a-z][a-z_0-9]+")        font-lock-constant-face)
 
396
                   "proc[ \t]+"
 
397
                   ;;SAS/Base, SAS/Graph, SAS/FSP and common add-ons
 
398
                   "\\(append"
 
399
                   "\\|c\\(a\\(lendar\\|talog\\)\\|port\\|o\\(mpare\\|ntents\\|py\\|rr\\)\\)"
 
400
                   "\\|d\\(atasets\\|bcstab\\|isplay\\)\\|ex\\(plode\\|port\\)"
 
401
                   "\\|f\\(orm\\(at\\|s\\)\\|req\\|s\\(browse\\|edit\\|l\\(etter\\|ist\\)\\|view\\)\\)"
 
402
                   "\\|g?\\(chart\\|p\\(lot\\|rint\\)\\)"
 
403
                   "\\|g\\(anno\\|contour\\|device\\|font\\|\\(key\\)?map\\|options\\|project"
 
404
                   "\\|re\\(duce\\|move\\|play\\)\\|slide\\|testit\\|3\\(d\\|grid\\)\\)"
 
405
                   "\\|[cg]?import\\|i\\(ml\\|nsight\\)\\|means\\|options\\|p\\(menu\\|rintto\\)"
 
406
                   "\\|r\\(ank\\|e\\(gistry\\|port\\)\\)"
 
407
                   "\\|s\\(ort\\|ql\\|tandard\\|ummary\\)"
 
408
                   "\\|t\\(abulate\\|imeplot\\|ran\\(spose\\|tab\\)\\)\\|univariate"
 
409
                   ;;SAS/Stat and SAS/ETS
 
410
                   "\\|a\\(ceclus\\|nova\\|rima\\|utoreg\\)\\|boxplot"
 
411
                   "\\|c\\(a\\(lis\\|n\\(corr\\|disc\\)\\|tmod\\)\\|itibase\\|luster\\|o\\(mputab\\|rresp\\)\\)"
 
412
                   "\\|discrim\\|expand\\|f\\(a\\(ctor\\|stclus\\)\\|orecast\\|req\\)"
 
413
                   "\\|g\\(enmod\\|lm\\(mod\\|power\\)?\\)\\|inbreed\\|k\\(de\\|rige2d\\)"
 
414
                   "\\|l\\(attice\\|ife\\(reg\\|test\\)\\|o\\(ess\\|gistic\\)\\)"
 
415
                   "\\|m\\(ds\\|ixed\\|o\\(de\\(clus\\|l\\)\\|rtgage\\)\\|ulttest\\)"
 
416
                   "\\|n\\(ested\\|l\\(in\\|mixed\\)\\|par1way\\)\\|orthoreg"
 
417
                   "\\|p\\(dlreg\\|hreg\\|l\\(an\\|s\\)\\|ower\\|r\\(in\\(comp\\|qual\\)\\|obit\\)\\)\\|rs?reg"
 
418
                   "\\|s\\(core\\|im\\(2d\\|lin\\)\\|pectra\\|t\\(atespace\\|dize\\|epdisc\\)\\|urvey\\(means\\|reg\\|select\\)\\|yslin\\)"
 
419
                   "\\|t\\(phreg\\|pspline\\|r\\(ansreg\\|ee\\)\\|test\\)"
 
420
                   "\\|var\\(clus\\|comp\\|iogram\\)\\|x11"
 
421
                   "\\)")        font-lock-constant-face)
 
422
 
 
423
     ;;(cons (concat "\\(^[0-9]*\\|;\\|%then\\|%else\\)[ \t]*"
 
424
     ;;"\\(%\\(go[ \t]*to\\|i\\(f\\|n\\(clude\\|put\\)\\)\\|let\\|put\\|sysexec\\)\\)"
 
425
     ;;"\\>")                               font-lock-constant-face)
 
426
     (cons "\\<%\\(go[ \t]*to\\|i\\(f\\|n\\(clude\\|put\\)\\)\\|let\\|put\\|sysexec\\)\\>"
 
427
           font-lock-constant-face)
 
428
 
 
429
     (cons "\\<%\\(by\\|else\\|t\\(o\\|hen\\)\\)\\>"
 
430
           font-lock-constant-face)
 
431
 
 
432
     ;; SAS dataset options/PROC statements followed by an equal sign/left parentheses
 
433
 
 
434
     (cons (concat
 
435
            "[ \t(,]"
 
436
            "\\(attrib\\|by\\|compress\\|d\\(ata\\|rop\\)\\|f\\(irstobs\\|ormat\\)"
 
437
            "\\|i\\(d\\|f\\|n\\)\\|ke\\(ep\\|y\\)\\|l\\(abel\\|ength\\)"
 
438
            "\\|o\\(bs\\|rder\\|ut\\)\\|rename\\|s\\(ortedby\\|plit\\)"
 
439
            "\\|var\\|where\\)"
 
440
            "[ \t]*=")
 
441
           font-lock-keyword-face)
 
442
     (cons "\\<\\(in\\(:\\|dex[ \t]*=\\)?\\|until\\|wh\\(en\\|ile\\)\\)[ \t]*("
 
443
           font-lock-keyword-face)
 
444
 
 
445
     ;; SAS statements
 
446
     (cons (concat
 
447
            "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
 
448
            "\\(a\\(bort\\|rray\\|ttrib\\)\\|by"
 
449
            "\\|c\\(hange\\|lass\\|ontrast\\)"
 
450
            "\\|d\\(elete\\|isplay\\|m\\|o\\([ \t]+\\(data\\|over\\)\\)?\\|rop\\)"
 
451
            "\\|e\\(rror\\|stimate\\|xc\\(hange\\|lude\\)\\)"
 
452
            "\\|f\\(ile\\(name\\)?\\|o\\(otnote\\(10?\\|[2-9]\\)?\\|rmat\\)\\|req\\)"
 
453
            "\\|go\\([ \t]*to\\|ptions\\)"
 
454
            "\\|[hv]bar\\(3d\\)?"
 
455
            "\\|i\\(d\\|f\\|n\\(dex\\|f\\(ile\\|ormat\\)\\|put\\|value\\)\\)"
 
456
            "\\|keep\\|l\\(abel\\|ength\\|i\\(bname\\|nk\\|st\\)\\|smeans\\)"
 
457
            "\\|m\\(anova\\|e\\(ans\\|rge\\)\\|issing\\|od\\(el\\|ify\\)\\)\\|note"
 
458
            "\\|o\\(ptions\\|therwise\\|utput\\)\\|p\\(arms\\|lot2?\\|ut\\)"
 
459
            "\\|r\\(andom\\|e\\(name\\|peated\\|tain\\)\\)"
 
460
            "\\|s\\(ave\\|e\\(lect\\|t\\)\\|kip\\|trata\\|umby\\)"
 
461
            "\\|t\\(ables?\\|i\\(me\\|tle\\(10?\\|[2-9]\\)?\\)\\)\\|update"
 
462
            "\\|va\\(lue\\|r\\)\\|w\\(eight\\|here\\|i\\(ndow\\|th\\)\\)"
 
463
 
 
464
            ;; IML statements that are not also SAS statements
 
465
            "\\|append\\|c\\(lose\\(file\\)?\\|reate\\)\\|edit\\|f\\(ind\\|orce\\|ree\\)"
 
466
            "\\|insert\\|load\\|mattrib\\|p\\(a[ru]se\\|rint\\|urge\\)"
 
467
            "\\|re\\(move\\|peat\\|place\\|set\\|sume\\)"
 
468
            "\\|s\\(et\\(in\\|out\\)\\|how\\|ort\\|tore\\|ummary\\)\\|use\\)?"
 
469
 
 
470
            "\\>")                                  font-lock-keyword-face)
 
471
 
 
472
 
 
473
 
 
474
     ;;  (cons "\\<\\(\\(then\\|else\\)[ \t]*\\)?\\(do\\([ \t]*over\\)?\\|else\\)\\>"
 
475
     ;;                                             font-lock-keyword-face)
 
476
 
 
477
     ;; SAS statements that must be followed by a semi-colon
 
478
     (cons (concat
 
479
            "\\(^[0-9]*\\|):\\|[;,]\\|then\\|else\\)[ \t]*"
 
480
            "\\(cards4?\\|datalines\\|end\\|l\\(ostcard\\)\\|page\\|return\\|stop\\)?"
 
481
            "[ \t]*;")                      font-lock-keyword-face)
 
482
 
 
483
     ;; SAS/GRAPH statements not handled above
 
484
     (cons (concat
 
485
            "\\(^[0-9]*\\|):\\|[;,]\\)[ \t]*"
 
486
            "\\(axis\\|legend\\|pattern\\|symbol\\)"
 
487
            "\\([1-9][0-9]?\\)?\\>")        font-lock-keyword-face)
 
488
 
 
489
     ;; SAS Datastep functions and SAS macro functions
 
490
                                        ;(cons "%[a-z_][a-z_0-9]*[ \t]*[(;]"
 
491
     ;; SAS macro functions occasionally defined with no arguments
 
492
     ;; which means they can be followed by any character that can
 
493
     ;; separate tokens, however, they are most likely to be followed
 
494
     ;; by operat-ions/ors
 
495
     (cons "%[a-z_][a-z_0-9]*[- \t();,+*/=<>]"
 
496
           font-lock-function-name-face)
 
497
     (cons "\\<call[ \t]+[a-z_][a-z_0-9]*[ \t]*("
 
498
           font-lock-function-name-face)
 
499
 
 
500
     (cons (concat
 
501
            "\\<"
 
502
            "\\(a\\(bs\\|r\\(cos\\|sin\\)\\|tan\\)\\|b\\(etainv\\|yte\\)"
 
503
            "\\|c\\(eil\\|inv\\|o\\(llate\\|mpress\\|sh?\\)\\|ss\\|v\\)"
 
504
            "\\|dacc\\(db\\(\\|sl\\)\\|s\\(l\\|yd\\)\\|tab\\)"
 
505
            "\\|dep\\(db\\(\\|sl\\)\\|s\\(l\\|yd\\)\\|tab\\)"
 
506
            "\\|d\\(a\\(te\\(\\|jul\\|part\\|time\\)\\|y\\)\\|hms\\|i\\(f[0-9]*\\|m\\|gamma\\)\\)"
 
507
            "\\|e\\(rfc?\\|xp\\)"
 
508
            "\\|f\\(i\\(nv\\|p\\(namel?\\|state\\)\\)\\|loor\\|uzz\\)\\|gam\\(inv\\|ma\\)"
 
509
            "\\|h\\(bound\\|ms\\|our\\)\\|i\\(n\\(dexc?\\|put\\|t\\(\\|ck\\|nx\\|rr\\)\\)\\|rr\\)"
 
510
            "\\|juldate\\|kurtosis\\|l\\(ag[0-9]*\\|bound\\|e\\(ft\\|ngth\\)\\|gamma\\|og\\(\\|10\\|2\\)\\)"
 
511
            "\\|m\\(ax\\|dy\\|ean\\|in\\(\\|ute\\)\\|o\\(d\\|nth\\|rt\\)\\)\\|n\\(\\|etpv\\|miss\\|ormal\\|pv\\)"
 
512
            "\\|prob\\([ft]\\|b\\(eta\\|nml\\)\\|chi\\|gam\\|hypr\\|it\\|n\\(egb\\|orm\\)\\)"
 
513
            "\\|ordinal\\|p\\(oisson\\|ut\\)\\|qtr\\|r\\(e\\(peat\\|verse\\)\\|ight\\|ound\\)"
 
514
            "\\|ran\\(bin\\|cau\\|exp\\|g\\(am\\|e\\)\\|k\\|nor\\|poi\\|t\\(bl\\|ri\\)\\|uni\\)"
 
515
            "\\|s\\(aving\\|can\\|econd\\|i\\(gn\\|nh?\\)\\|qrt\\|t\\(d\\(\\|err\\)\\|fips\\|namel?\\)\\|u\\(bstr\\|m\\)\\|ymget\\)"
 
516
            "\\|t\\(anh?\\|i\\(me\\(\\|part\\)\\|nv\\)\\|oday\\|r\\(anslate\\|i\\(gamma\\|m\\)\\|unc\\)\\)"
 
517
            "\\|u\\(niform\\|pcase\\|ss\\)\\|v\\(ar\\|erify\\)"
 
518
            "\\|weekday\\|y\\(ear\\|yq\\)\\|zip\\(fips\\|namel?\\|state\\)"
488
519
 
489
520
;;;    ;; SAS functions introduced in Technical Report P-222
490
521
 
491
 
                "\\|airy\\|b\\(and\\|lshift\\|not\\|or\\|rshift\\|xor\\)"
492
 
                "\\|c\\(nonct\\|ompbl\\)\\|d\\(airy\\|equote\\)\\|fnonct\\|tnonct"
493
 
                "\\|i\\(bessel\\|n\\(dexw\\|put[cn]\\)\\)\\|jbessel\\|put[cn]"
494
 
                "\\|lowcase\\|quote\\|resolve\\|s\\(oundex\\|ysprod\\)\\|tr\\(anwrd\\|imn\\)"
 
522
            "\\|airy\\|b\\(and\\|lshift\\|not\\|or\\|rshift\\|xor\\)"
 
523
            "\\|c\\(nonct\\|ompbl\\)\\|d\\(airy\\|equote\\)\\|fnonct\\|tnonct"
 
524
            "\\|i\\(bessel\\|n\\(dexw\\|put[cn]\\)\\)\\|jbessel\\|put[cn]"
 
525
            "\\|lowcase\\|quote\\|resolve\\|s\\(oundex\\|ysprod\\)\\|tr\\(anwrd\\|imn\\)"
495
526
 
496
527
;;;    ;; IML functions that are not also Datastep functions
497
 
                "\\|a\\(ll\\|ny\\|pply\\|rmasim\\)\\|b\\(lock\\|ranks\\|tran\\)"
498
 
                "\\|c\\(har\\|hoose\\|on\\(cat\\|tents\\|vexit\\|vmod\\)\\|ovlag\\|shape\\|usum\\|vexhull\\)"
499
 
                "\\|d\\(atasets\\|esignf?\\|et\\|iag\\|o\\|uration\\)"
500
 
                "\\|e\\(chelon\\|igv\\(al\\|ec\\)\\)\\|f\\(ft\\|orward\\)\\|ginv"
501
 
                "\\|h\\(alf\\|ankel\\|dir\\|ermite\\|omogen\\)"
502
 
                "\\|i\\(\\|fft\\|nsert\\|nv\\(updt\\)?\\)\\|j\\(\\|root\\)\\|loc\\|mad"
503
 
                "\\|n\\(ame\\|col\\|leng\\|row\\|um\\)\\|o\\(pscal\\|rpol\\)"
504
 
                "\\|p\\(olyroot\\|roduct\\|v\\)\\|r\\(anktie\\|ates\\|atio\\|emove\\|eturn\\|oot\\|owcatc?\\)"
505
 
                "\\|s\\(etdif\\|hape\\|olve\\|plinev\\|pot\\|qrsym\\|ssq\\|torage\\|weep\\|ymsqr\\)"
506
 
                "\\|t\\(\\|eigv\\(al\\|ec\\)\\|oeplitz\\|race\\|risolv\\|ype\\)"
507
 
                "\\|uni\\(on\\|que\\)\\|v\\(alue\\|ecdiag\\)\\|x\\(mult\\|sect\\)\\|yield"
 
528
            "\\|a\\(ll\\|ny\\|pply\\|rmasim\\)\\|b\\(lock\\|ranks\\|tran\\)"
 
529
            "\\|c\\(har\\|hoose\\|on\\(cat\\|tents\\|vexit\\|vmod\\)\\|ovlag\\|shape\\|usum\\|vexhull\\)"
 
530
            "\\|d\\(atasets\\|esignf?\\|et\\|iag\\|o\\|uration\\)"
 
531
            "\\|e\\(chelon\\|igv\\(al\\|ec\\)\\)\\|f\\(ft\\|orward\\)\\|ginv"
 
532
            "\\|h\\(alf\\|ankel\\|dir\\|ermite\\|omogen\\)"
 
533
            "\\|i\\(\\|fft\\|nsert\\|nv\\(updt\\)?\\)\\|j\\(\\|root\\)\\|loc\\|mad"
 
534
            "\\|n\\(ame\\|col\\|leng\\|row\\|um\\)\\|o\\(pscal\\|rpol\\)"
 
535
            "\\|p\\(olyroot\\|roduct\\|v\\)\\|r\\(anktie\\|ates\\|atio\\|emove\\|eturn\\|oot\\|owcatc?\\)"
 
536
            "\\|s\\(etdif\\|hape\\|olve\\|plinev\\|pot\\|qrsym\\|ssq\\|torage\\|weep\\|ymsqr\\)"
 
537
            "\\|t\\(\\|eigv\\(al\\|ec\\)\\|oeplitz\\|race\\|risolv\\|ype\\)"
 
538
            "\\|uni\\(on\\|que\\)\\|v\\(alue\\|ecdiag\\)\\|x\\(mult\\|sect\\)\\|yield"
508
539
 
509
540
;;;    ;; SCL functions that are known to work with SAS macro function %sysfunc
510
541
 
511
 
                "\\|attr[cn]\\|c\\(exist\\|lose\\)\\|d\\(close\\|num\\|open\\|read\\)"
512
 
                "\\|exist\\|f\\(close\\|etchobs\\|i\\(leexist\\|nfo\\)\\|open\\|put\\|write\\)"
513
 
                "\\|get\\(option\\|var[cn]\\)\\|lib\\(name\\|ref\\)\\|op\\(en\\|t\\(getn\\|setn\\)\\)"
514
 
                "\\|pathname\\|sysmsg\\|var\\(fmt\\|l\\(abel\\|en\\)\\|n\\(ame\\|um\\)\\|type\\)\\)"
515
 
                "[ \t]*(")                          font-lock-function-name-face)
516
 
         ))
517
 
        "Font Lock regexs for SAS.")
518
 
)
519
 
  (defvar SAS-mode-font-lock-keywords "") ;; empty if not window-system
520
 
); only if window-system
 
542
            "\\|attr[cn]\\|c\\(exist\\|lose\\)\\|d\\(close\\|num\\|open\\|read\\)"
 
543
            "\\|exist\\|f\\(close\\|etchobs\\|i\\(leexist\\|nfo\\)\\|open\\|put\\|write\\)"
 
544
            "\\|get\\(option\\|var[cn]\\)\\|lib\\(name\\|ref\\)\\|op\\(en\\|t\\(getn\\|setn\\)\\)"
 
545
            "\\|pathname\\|sysmsg\\|var\\(fmt\\|l\\(abel\\|en\\)\\|n\\(ame\\|um\\)\\|type\\)\\)"
 
546
            "[ \t]*(")                      font-lock-function-name-face)
 
547
     ))
 
548
  "Font Lock regexs for SAS.")
 
549
 
521
550
 
522
551
(defvar SAS-editing-alist
523
552
  '((sentence-end                 . ";[\t\n */]*")
529
558
    (indent-line-function         . 'sas-indent-line)
530
559
    ;;(indent-region-function       . 'sas-indent-region)
531
560
    (require-final-newline        . t)
532
 
    (comment-start                . "\\*\\|/\\*")
533
 
    (comment-start-skip           . "\\*+")
534
 
    (comment-end                  . ";\\|\\*/")
 
561
    (comment-start                . "** ")
 
562
    (comment-start-skip           . "[*][*] ")
 
563
    (comment-end                  . " **;")
 
564
    (comment-end-skip             . " [*][*];")
535
565
    (comment-column               . 40)
536
566
    ;;(comment-indent-function      . 'lisp-comment-indent)
537
567
    (parse-sexp-ignore-comments   . t)
538
568
    (ess-set-style                . ess-default-style)
539
569
    (ess-local-process-name       . nil)
540
570
    ;;(ess-keep-dump-files          . 'ask)
541
 
    (tab-stop-list                . ess-sas-tab-stop-alist)
 
571
    (tab-stop-list                . ess-sas-tab-stop-list)
542
572
    (ess-mode-syntax-table        . SAS-syntax-table)
543
573
    (font-lock-keywords-case-fold-search . t)
544
574
    (font-lock-defaults           . '(SAS-mode-font-lock-keywords)))