l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

sas.js (5762B)


      1 /*
      2 Language: SAS
      3 Author: Mauricio Caceres <mauricio.caceres.bravo@gmail.com>
      4 Description: Syntax Highlighting for SAS
      5 */
      6 
      7 function sas(hljs) {
      8 
      9     // Data step and PROC SQL statements
     10     var SAS_KEYWORDS = ''+
     11         'do if then else end until while '+
     12         ''+
     13         'abort array attrib by call cards cards4 catname continue '+
     14         'datalines datalines4 delete delim delimiter display dm drop '+
     15         'endsas error file filename footnote format goto in infile '+
     16         'informat input keep label leave length libname link list '+
     17         'lostcard merge missing modify options output out page put '+
     18         'redirect remove rename replace retain return select set skip '+
     19         'startsas stop title update waitsas where window x systask '+
     20         ''+
     21         'add and alter as cascade check create delete describe '+
     22         'distinct drop foreign from group having index insert into in '+
     23         'key like message modify msgtype not null on or order primary '+
     24         'references reset restrict select set table unique update '+
     25         'validate view where';
     26 
     27     // Built-in SAS functions
     28     var SAS_FUN = ''+
     29         'abs|addr|airy|arcos|arsin|atan|attrc|attrn|band|'+
     30         'betainv|blshift|bnot|bor|brshift|bxor|byte|cdf|ceil|'+
     31         'cexist|cinv|close|cnonct|collate|compbl|compound|'+
     32         'compress|cos|cosh|css|curobs|cv|daccdb|daccdbsl|'+
     33         'daccsl|daccsyd|dacctab|dairy|date|datejul|datepart|'+
     34         'datetime|day|dclose|depdb|depdbsl|depdbsl|depsl|'+
     35         'depsl|depsyd|depsyd|deptab|deptab|dequote|dhms|dif|'+
     36         'digamma|dim|dinfo|dnum|dopen|doptname|doptnum|dread|'+
     37         'dropnote|dsname|erf|erfc|exist|exp|fappend|fclose|'+
     38         'fcol|fdelete|fetch|fetchobs|fexist|fget|fileexist|'+
     39         'filename|fileref|finfo|finv|fipname|fipnamel|'+
     40         'fipstate|floor|fnonct|fnote|fopen|foptname|foptnum|'+
     41         'fpoint|fpos|fput|fread|frewind|frlen|fsep|fuzz|'+
     42         'fwrite|gaminv|gamma|getoption|getvarc|getvarn|hbound|'+
     43         'hms|hosthelp|hour|ibessel|index|indexc|indexw|input|'+
     44         'inputc|inputn|int|intck|intnx|intrr|irr|jbessel|'+
     45         'juldate|kurtosis|lag|lbound|left|length|lgamma|'+
     46         'libname|libref|log|log10|log2|logpdf|logpmf|logsdf|'+
     47         'lowcase|max|mdy|mean|min|minute|mod|month|mopen|'+
     48         'mort|n|netpv|nmiss|normal|note|npv|open|ordinal|'+
     49         'pathname|pdf|peek|peekc|pmf|point|poisson|poke|'+
     50         'probbeta|probbnml|probchi|probf|probgam|probhypr|'+
     51         'probit|probnegb|probnorm|probt|put|putc|putn|qtr|'+
     52         'quote|ranbin|rancau|ranexp|rangam|range|rank|rannor|'+
     53         'ranpoi|rantbl|rantri|ranuni|repeat|resolve|reverse|'+
     54         'rewind|right|round|saving|scan|sdf|second|sign|'+
     55         'sin|sinh|skewness|soundex|spedis|sqrt|std|stderr|'+
     56         'stfips|stname|stnamel|substr|sum|symget|sysget|'+
     57         'sysmsg|sysprod|sysrc|system|tan|tanh|time|timepart|'+
     58         'tinv|tnonct|today|translate|tranwrd|trigamma|'+
     59         'trim|trimn|trunc|uniform|upcase|uss|var|varfmt|'+
     60         'varinfmt|varlabel|varlen|varname|varnum|varray|'+
     61         'varrayx|vartype|verify|vformat|vformatd|vformatdx|'+
     62         'vformatn|vformatnx|vformatw|vformatwx|vformatx|'+
     63         'vinarray|vinarrayx|vinformat|vinformatd|vinformatdx|'+
     64         'vinformatn|vinformatnx|vinformatw|vinformatwx|'+
     65         'vinformatx|vlabel|vlabelx|vlength|vlengthx|vname|'+
     66         'vnamex|vtype|vtypex|weekday|year|yyq|zipfips|zipname|'+
     67         'zipnamel|zipstate';
     68 
     69     // Built-in macro functions
     70     var SAS_MACRO_FUN = 'bquote|nrbquote|cmpres|qcmpres|compstor|'+
     71         'datatyp|display|do|else|end|eval|global|goto|'+
     72         'if|index|input|keydef|label|left|length|let|'+
     73         'local|lowcase|macro|mend|nrbquote|nrquote|'+
     74         'nrstr|put|qcmpres|qleft|qlowcase|qscan|'+
     75         'qsubstr|qsysfunc|qtrim|quote|qupcase|scan|str|'+
     76         'substr|superq|syscall|sysevalf|sysexec|sysfunc|'+
     77         'sysget|syslput|sysprod|sysrc|sysrput|then|to|'+
     78         'trim|unquote|until|upcase|verify|while|window';
     79 
     80     return {
     81         name: 'SAS',
     82         aliases: ['sas', 'SAS'],
     83         case_insensitive: true, // SAS is case-insensitive
     84         keywords: {
     85             literal:
     86                 'null missing _all_ _automatic_ _character_ _infile_ '+
     87                 '_n_ _name_ _null_ _numeric_ _user_ _webout_',
     88             meta:
     89                 SAS_KEYWORDS
     90         },
     91         contains: [
     92             {
     93                 // Distinct highlight for proc <proc>, data, run, quit
     94                 className: 'keyword',
     95                 begin: /^\s*(proc [\w\d_]+|data|run|quit)[\s\;]/
     96             },
     97             {
     98                 // Macro variables
     99                 className: 'variable',
    100                 begin: /\&[a-zA-Z_\&][a-zA-Z0-9_]*\.?/
    101             },
    102             {
    103                 // Special emphasis for datalines|cards
    104                 className: 'emphasis',
    105                 begin: /^\s*datalines|cards.*;/,
    106                 end: /^\s*;\s*$/
    107             },
    108             {   // Built-in macro variables take precedence
    109                 className: 'built_in',
    110                 begin: '%(' + SAS_MACRO_FUN + ')'
    111             },
    112             {
    113                 // User-defined macro functions highlighted after
    114                 className: 'name',
    115                 begin: /%[a-zA-Z_][a-zA-Z_0-9]*/
    116             },
    117             {
    118                 className: 'meta',
    119                 begin: '[^%](' + SAS_FUN + ')[\(]'
    120             },
    121             {
    122                 className: 'string',
    123                 variants: [
    124                     hljs.APOS_STRING_MODE,
    125                     hljs.QUOTE_STRING_MODE
    126                 ]
    127             },
    128             hljs.COMMENT('\\*', ';'),
    129             hljs.C_BLOCK_COMMENT_MODE
    130         ]
    131     };
    132 }
    133 
    134 module.exports = sas;