CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
sas.js558 linesDownload Raw Back to languages
1/*2Language: SAS3Author: Mauricio Caceres <mauricio.caceres.bravo@gmail.com>4Description: Syntax Highlighting for SAS5Category: scientific6*/7 8/** @type LanguageFn */9function sas(hljs) {10  const regex = hljs.regex;11  // Data step and PROC SQL statements12  const SAS_KEYWORDS = [13    "do",14    "if",15    "then",16    "else",17    "end",18    "until",19    "while",20    "abort",21    "array",22    "attrib",23    "by",24    "call",25    "cards",26    "cards4",27    "catname",28    "continue",29    "datalines",30    "datalines4",31    "delete",32    "delim",33    "delimiter",34    "display",35    "dm",36    "drop",37    "endsas",38    "error",39    "file",40    "filename",41    "footnote",42    "format",43    "goto",44    "in",45    "infile",46    "informat",47    "input",48    "keep",49    "label",50    "leave",51    "length",52    "libname",53    "link",54    "list",55    "lostcard",56    "merge",57    "missing",58    "modify",59    "options",60    "output",61    "out",62    "page",63    "put",64    "redirect",65    "remove",66    "rename",67    "replace",68    "retain",69    "return",70    "select",71    "set",72    "skip",73    "startsas",74    "stop",75    "title",76    "update",77    "waitsas",78    "where",79    "window",80    "x|0",81    "systask",82    "add",83    "and",84    "alter",85    "as",86    "cascade",87    "check",88    "create",89    "delete",90    "describe",91    "distinct",92    "drop",93    "foreign",94    "from",95    "group",96    "having",97    "index",98    "insert",99    "into",100    "in",101    "key",102    "like",103    "message",104    "modify",105    "msgtype",106    "not",107    "null",108    "on",109    "or",110    "order",111    "primary",112    "references",113    "reset",114    "restrict",115    "select",116    "set",117    "table",118    "unique",119    "update",120    "validate",121    "view",122    "where"123  ];124 125  // Built-in SAS functions126  const FUNCTIONS = [127    "abs",128    "addr",129    "airy",130    "arcos",131    "arsin",132    "atan",133    "attrc",134    "attrn",135    "band",136    "betainv",137    "blshift",138    "bnot",139    "bor",140    "brshift",141    "bxor",142    "byte",143    "cdf",144    "ceil",145    "cexist",146    "cinv",147    "close",148    "cnonct",149    "collate",150    "compbl",151    "compound",152    "compress",153    "cos",154    "cosh",155    "css",156    "curobs",157    "cv",158    "daccdb",159    "daccdbsl",160    "daccsl",161    "daccsyd",162    "dacctab",163    "dairy",164    "date",165    "datejul",166    "datepart",167    "datetime",168    "day",169    "dclose",170    "depdb",171    "depdbsl",172    "depdbsl",173    "depsl",174    "depsl",175    "depsyd",176    "depsyd",177    "deptab",178    "deptab",179    "dequote",180    "dhms",181    "dif",182    "digamma",183    "dim",184    "dinfo",185    "dnum",186    "dopen",187    "doptname",188    "doptnum",189    "dread",190    "dropnote",191    "dsname",192    "erf",193    "erfc",194    "exist",195    "exp",196    "fappend",197    "fclose",198    "fcol",199    "fdelete",200    "fetch",201    "fetchobs",202    "fexist",203    "fget",204    "fileexist",205    "filename",206    "fileref",207    "finfo",208    "finv",209    "fipname",210    "fipnamel",211    "fipstate",212    "floor",213    "fnonct",214    "fnote",215    "fopen",216    "foptname",217    "foptnum",218    "fpoint",219    "fpos",220    "fput",221    "fread",222    "frewind",223    "frlen",224    "fsep",225    "fuzz",226    "fwrite",227    "gaminv",228    "gamma",229    "getoption",230    "getvarc",231    "getvarn",232    "hbound",233    "hms",234    "hosthelp",235    "hour",236    "ibessel",237    "index",238    "indexc",239    "indexw",240    "input",241    "inputc",242    "inputn",243    "int",244    "intck",245    "intnx",246    "intrr",247    "irr",248    "jbessel",249    "juldate",250    "kurtosis",251    "lag",252    "lbound",253    "left",254    "length",255    "lgamma",256    "libname",257    "libref",258    "log",259    "log10",260    "log2",261    "logpdf",262    "logpmf",263    "logsdf",264    "lowcase",265    "max",266    "mdy",267    "mean",268    "min",269    "minute",270    "mod",271    "month",272    "mopen",273    "mort",274    "n",275    "netpv",276    "nmiss",277    "normal",278    "note",279    "npv",280    "open",281    "ordinal",282    "pathname",283    "pdf",284    "peek",285    "peekc",286    "pmf",287    "point",288    "poisson",289    "poke",290    "probbeta",291    "probbnml",292    "probchi",293    "probf",294    "probgam",295    "probhypr",296    "probit",297    "probnegb",298    "probnorm",299    "probt",300    "put",301    "putc",302    "putn",303    "qtr",304    "quote",305    "ranbin",306    "rancau",307    "ranexp",308    "rangam",309    "range",310    "rank",311    "rannor",312    "ranpoi",313    "rantbl",314    "rantri",315    "ranuni",316    "repeat",317    "resolve",318    "reverse",319    "rewind",320    "right",321    "round",322    "saving",323    "scan",324    "sdf",325    "second",326    "sign",327    "sin",328    "sinh",329    "skewness",330    "soundex",331    "spedis",332    "sqrt",333    "std",334    "stderr",335    "stfips",336    "stname",337    "stnamel",338    "substr",339    "sum",340    "symget",341    "sysget",342    "sysmsg",343    "sysprod",344    "sysrc",345    "system",346    "tan",347    "tanh",348    "time",349    "timepart",350    "tinv",351    "tnonct",352    "today",353    "translate",354    "tranwrd",355    "trigamma",356    "trim",357    "trimn",358    "trunc",359    "uniform",360    "upcase",361    "uss",362    "var",363    "varfmt",364    "varinfmt",365    "varlabel",366    "varlen",367    "varname",368    "varnum",369    "varray",370    "varrayx",371    "vartype",372    "verify",373    "vformat",374    "vformatd",375    "vformatdx",376    "vformatn",377    "vformatnx",378    "vformatw",379    "vformatwx",380    "vformatx",381    "vinarray",382    "vinarrayx",383    "vinformat",384    "vinformatd",385    "vinformatdx",386    "vinformatn",387    "vinformatnx",388    "vinformatw",389    "vinformatwx",390    "vinformatx",391    "vlabel",392    "vlabelx",393    "vlength",394    "vlengthx",395    "vname",396    "vnamex",397    "vtype",398    "vtypex",399    "weekday",400    "year",401    "yyq",402    "zipfips",403    "zipname",404    "zipnamel",405    "zipstate"406  ];407 408  // Built-in macro functions409  const MACRO_FUNCTIONS = [410    "bquote",411    "nrbquote",412    "cmpres",413    "qcmpres",414    "compstor",415    "datatyp",416    "display",417    "do",418    "else",419    "end",420    "eval",421    "global",422    "goto",423    "if",424    "index",425    "input",426    "keydef",427    "label",428    "left",429    "length",430    "let",431    "local",432    "lowcase",433    "macro",434    "mend",435    "nrbquote",436    "nrquote",437    "nrstr",438    "put",439    "qcmpres",440    "qleft",441    "qlowcase",442    "qscan",443    "qsubstr",444    "qsysfunc",445    "qtrim",446    "quote",447    "qupcase",448    "scan",449    "str",450    "substr",451    "superq",452    "syscall",453    "sysevalf",454    "sysexec",455    "sysfunc",456    "sysget",457    "syslput",458    "sysprod",459    "sysrc",460    "sysrput",461    "then",462    "to",463    "trim",464    "unquote",465    "until",466    "upcase",467    "verify",468    "while",469    "window"470  ];471 472  const LITERALS = [473    "null",474    "missing",475    "_all_",476    "_automatic_",477    "_character_",478    "_infile_",479    "_n_",480    "_name_",481    "_null_",482    "_numeric_",483    "_user_",484    "_webout_"485  ];486 487  return {488    name: 'SAS',489    case_insensitive: true,490    keywords: {491      literal: LITERALS,492      keyword: SAS_KEYWORDS493    },494    contains: [495      {496        // Distinct highlight for proc <proc>, data, run, quit497        className: 'keyword',498        begin: /^\s*(proc [\w\d_]+|data|run|quit)[\s;]/499      },500      {501        // Macro variables502        className: 'variable',503        begin: /&[a-zA-Z_&][a-zA-Z0-9_]*\.?/504      },505      {506        begin: [507          /^\s*/,508          /datalines;|cards;/,509          /(?:.*\n)+/,510          /^\s*;\s*$/511        ],512        className: {513          2: "keyword",514          3: "string"515        }516      },517      {518        begin: [519          /%mend|%macro/,520          /\s+/,521          /[a-zA-Z_&][a-zA-Z0-9_]*/522        ],523        className: {524          1: "built_in",525          3: "title.function"526        }527      },528      { // Built-in macro variables529        className: 'built_in',530        begin: '%' + regex.either(...MACRO_FUNCTIONS)531      },532      {533        // User-defined macro functions534        className: 'title.function',535        begin: /%[a-zA-Z_][a-zA-Z_0-9]*/536      },537      {538        // TODO: this is most likely an incorrect classification539        // built_in may need more nuance540        // https://github.com/highlightjs/highlight.js/issues/2521541        className: 'meta',542        begin: regex.either(...FUNCTIONS) + '(?=\\()'543      },544      {545        className: 'string',546        variants: [547          hljs.APOS_STRING_MODE,548          hljs.QUOTE_STRING_MODE549        ]550      },551      hljs.COMMENT('\\*', ';'),552      hljs.C_BLOCK_COMMENT_MODE553    ]554  };555}556 557export { sas as default };558 
basant307/AI_Governance_Project · CoolFace