Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/sas
File: sas.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
// SAS mode copyright (c) 2016 Jared Dean, SAS Institute
[4] Fix | Delete
// Created by Jared Dean
[5] Fix | Delete
[6] Fix | Delete
// TODO
[7] Fix | Delete
// indent and de-indent
[8] Fix | Delete
// identify macro variables
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
//Definitions
[12] Fix | Delete
// comment -- text withing * ; or /* */
[13] Fix | Delete
// keyword -- SAS language variable
[14] Fix | Delete
// variable -- macro variables starts with '&' or variable formats
[15] Fix | Delete
// variable-2 -- DATA Step, proc, or macro names
[16] Fix | Delete
// string -- text within ' ' or " "
[17] Fix | Delete
// operator -- numeric operator + / - * ** le eq ge ... and so on
[18] Fix | Delete
// builtin -- proc %macro data run mend
[19] Fix | Delete
// atom
[20] Fix | Delete
// def
[21] Fix | Delete
[22] Fix | Delete
(function(mod) {
[23] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[24] Fix | Delete
mod(require("../../lib/codemirror"));
[25] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[26] Fix | Delete
define(["../../lib/codemirror"], mod);
[27] Fix | Delete
else // Plain browser env
[28] Fix | Delete
mod(CodeMirror);
[29] Fix | Delete
})(function(CodeMirror) {
[30] Fix | Delete
"use strict";
[31] Fix | Delete
[32] Fix | Delete
CodeMirror.defineMode("sas", function () {
[33] Fix | Delete
var words = {};
[34] Fix | Delete
var isDoubleOperatorSym = {
[35] Fix | Delete
eq: 'operator',
[36] Fix | Delete
lt: 'operator',
[37] Fix | Delete
le: 'operator',
[38] Fix | Delete
gt: 'operator',
[39] Fix | Delete
ge: 'operator',
[40] Fix | Delete
"in": 'operator',
[41] Fix | Delete
ne: 'operator',
[42] Fix | Delete
or: 'operator'
[43] Fix | Delete
};
[44] Fix | Delete
var isDoubleOperatorChar = /(<=|>=|!=|<>)/;
[45] Fix | Delete
var isSingleOperatorChar = /[=\(:\),{}.*<>+\-\/^\[\]]/;
[46] Fix | Delete
[47] Fix | Delete
// Takes a string of words separated by spaces and adds them as
[48] Fix | Delete
// keys with the value of the first argument 'style'
[49] Fix | Delete
function define(style, string, context) {
[50] Fix | Delete
if (context) {
[51] Fix | Delete
var split = string.split(' ');
[52] Fix | Delete
for (var i = 0; i < split.length; i++) {
[53] Fix | Delete
words[split[i]] = {style: style, state: context};
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
//datastep
[58] Fix | Delete
define('def', 'stack pgm view source debug nesting nolist', ['inDataStep']);
[59] Fix | Delete
define('def', 'if while until for do do; end end; then else cancel', ['inDataStep']);
[60] Fix | Delete
define('def', 'label format _n_ _error_', ['inDataStep']);
[61] Fix | Delete
define('def', 'ALTER BUFNO BUFSIZE CNTLLEV COMPRESS DLDMGACTION ENCRYPT ENCRYPTKEY EXTENDOBSCOUNTER GENMAX GENNUM INDEX LABEL OBSBUF OUTREP PW PWREQ READ REPEMPTY REPLACE REUSE ROLE SORTEDBY SPILL TOBSNO TYPE WRITE FILECLOSE FIRSTOBS IN OBS POINTOBS WHERE WHEREUP IDXNAME IDXWHERE DROP KEEP RENAME', ['inDataStep']);
[62] Fix | Delete
define('def', 'filevar finfo finv fipname fipnamel fipstate first firstobs floor', ['inDataStep']);
[63] Fix | Delete
define('def', 'varfmt varinfmt varlabel varlen varname varnum varray varrayx vartype verify vformat vformatd vformatdx vformatn vformatnx vformatw vformatwx vformatx vinarray vinarrayx vinformat vinformatd vinformatdx vinformatn vinformatnx vinformatw vinformatwx vinformatx vlabel vlabelx vlength vlengthx vname vnamex vnferr vtype vtypex weekday', ['inDataStep']);
[64] Fix | Delete
define('def', 'zipfips zipname zipnamel zipstate', ['inDataStep']);
[65] Fix | Delete
define('def', 'put putc putn', ['inDataStep']);
[66] Fix | Delete
define('builtin', 'data run', ['inDataStep']);
[67] Fix | Delete
[68] Fix | Delete
[69] Fix | Delete
//proc
[70] Fix | Delete
define('def', 'data', ['inProc']);
[71] Fix | Delete
[72] Fix | Delete
// flow control for macros
[73] Fix | Delete
define('def', '%if %end %end; %else %else; %do %do; %then', ['inMacro']);
[74] Fix | Delete
[75] Fix | Delete
//everywhere
[76] Fix | Delete
define('builtin', 'proc run; quit; libname filename %macro %mend option options', ['ALL']);
[77] Fix | Delete
[78] Fix | Delete
define('def', 'footnote title libname ods', ['ALL']);
[79] Fix | Delete
define('def', '%let %put %global %sysfunc %eval ', ['ALL']);
[80] Fix | Delete
// automatic macro variables http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003167023.htm
[81] Fix | Delete
define('variable', '&sysbuffr &syscc &syscharwidth &syscmd &sysdate &sysdate9 &sysday &sysdevic &sysdmg &sysdsn &sysencoding &sysenv &syserr &syserrortext &sysfilrc &syshostname &sysindex &sysinfo &sysjobid &syslast &syslckrc &syslibrc &syslogapplname &sysmacroname &sysmenv &sysmsg &sysncpu &sysodspath &sysparm &syspbuff &sysprocessid &sysprocessname &sysprocname &sysrc &sysscp &sysscpl &sysscpl &syssite &sysstartid &sysstartname &systcpiphostname &systime &sysuserid &sysver &sysvlong &sysvlong4 &syswarningtext', ['ALL']);
[82] Fix | Delete
[83] Fix | Delete
//footnote[1-9]? title[1-9]?
[84] Fix | Delete
[85] Fix | Delete
//options statement
[86] Fix | Delete
define('def', 'source2 nosource2 page pageno pagesize', ['ALL']);
[87] Fix | Delete
[88] Fix | Delete
//proc and datastep
[89] Fix | Delete
define('def', '_all_ _character_ _cmd_ _freq_ _i_ _infile_ _last_ _msg_ _null_ _numeric_ _temporary_ _type_ abort abs addr adjrsq airy alpha alter altlog altprint and arcos array arsin as atan attrc attrib attrn authserver autoexec awscontrol awsdef awsmenu awsmenumerge awstitle backward band base betainv between blocksize blshift bnot bor brshift bufno bufsize bxor by byerr byline byte calculated call cards cards4 catcache cbufno cdf ceil center cexist change chisq cinv class cleanup close cnonct cntllev coalesce codegen col collate collin column comamid comaux1 comaux2 comdef compbl compound compress config continue convert cos cosh cpuid create cross crosstab css curobs cv daccdb daccdbsl daccsl daccsyd dacctab dairy datalines datalines4 datejul datepart datetime day dbcslang dbcstype dclose ddm delete delimiter depdb depdbsl depsl depsyd deptab dequote descending descript design= device dflang dhms dif digamma dim dinfo display distinct dkricond dkrocond dlm dnum do dopen doptname doptnum dread drop dropnote dsname dsnferr echo else emaildlg emailid emailpw emailserver emailsys encrypt end endsas engine eof eov erf erfc error errorcheck errors exist exp fappend fclose fcol fdelete feedback fetch fetchobs fexist fget file fileclose fileexist filefmt filename fileref fmterr fmtsearch fnonct fnote font fontalias fopen foptname foptnum force formatted formchar formdelim formdlim forward fpoint fpos fput fread frewind frlen from fsep fuzz fwrite gaminv gamma getoption getvarc getvarn go goto group gwindow hbar hbound helpenv helploc hms honorappearance hosthelp hostprint hour hpct html hvar ibessel ibr id if index indexc indexw initcmd initstmt inner input inputc inputn inr insert int intck intnx into intrr invaliddata irr is jbessel join juldate keep kentb kurtosis label lag last lbound leave left length levels lgamma lib library libref line linesize link list log log10 log2 logpdf logpmf logsdf lostcard lowcase lrecl ls macro macrogen maps mautosource max maxdec maxr mdy mean measures median memtype merge merror min minute missing missover mlogic mod mode model modify month mopen mort mprint mrecall msglevel msymtabmax mvarsize myy n nest netpv new news nmiss no nobatch nobs nocaps nocardimage nocenter nocharcode nocmdmac nocol nocum nodate nodbcs nodetails nodmr nodms nodmsbatch nodup nodupkey noduplicates noechoauto noequals noerrorabend noexitwindows nofullstimer noicon noimplmac noint nolist noloadlist nomiss nomlogic nomprint nomrecall nomsgcase nomstored nomultenvappl nonotes nonumber noobs noovp nopad nopercent noprint noprintinit normal norow norsasuser nosetinit nosplash nosymbolgen note notes notitle notitles notsorted noverbose noxsync noxwait npv null number numkeys nummousekeys nway obs on open order ordinal otherwise out outer outp= output over ovp p(1 5 10 25 50 75 90 95 99) pad pad2 paired parm parmcards path pathdll pathname pdf peek peekc pfkey pmf point poisson poke position printer probbeta probbnml probchi probf probgam probhypr probit probnegb probnorm probsig probt procleave prt ps pw pwreq qtr quote r ranbin rancau ranexp rangam range ranks rannor ranpoi rantbl rantri ranuni read recfm register regr remote remove rename repeat replace resolve retain return reuse reverse rewind right round rsquare rtf rtrace rtraceloc s s2 samploc sasautos sascontrol sasfrscr sasmsg sasmstore sasscript sasuser saving scan sdf second select selection separated seq serror set setcomm setot sign simple sin sinh siteinfo skewness skip sle sls sortedby sortpgm sortseq sortsize soundex spedis splashlocation split spool sqrt start std stderr stdin stfips stimer stname stnamel stop stopover subgroup subpopn substr sum sumwgt symbol symbolgen symget symput sysget sysin sysleave sysmsg sysparm sysprint sysprintfont sysprod sysrc system t table tables tan tanh tapeclose tbufsize terminal test then timepart tinv tnonct to today tol tooldef totper transformout translate trantab tranwrd trigamma trim trimn trunc truncover type unformatted uniform union until upcase update user usericon uss validate value var weight when where while wincharset window work workinit workterm write wsum xsync xwait yearcutoff yes yyq min max', ['inDataStep', 'inProc']);
[90] Fix | Delete
define('operator', 'and not ', ['inDataStep', 'inProc']);
[91] Fix | Delete
[92] Fix | Delete
// Main function
[93] Fix | Delete
function tokenize(stream, state) {
[94] Fix | Delete
// Finally advance the stream
[95] Fix | Delete
var ch = stream.next();
[96] Fix | Delete
[97] Fix | Delete
// BLOCKCOMMENT
[98] Fix | Delete
if (ch === '/' && stream.eat('*')) {
[99] Fix | Delete
state.continueComment = true;
[100] Fix | Delete
return "comment";
[101] Fix | Delete
} else if (state.continueComment === true) { // in comment block
[102] Fix | Delete
//comment ends at the beginning of the line
[103] Fix | Delete
if (ch === '*' && stream.peek() === '/') {
[104] Fix | Delete
stream.next();
[105] Fix | Delete
state.continueComment = false;
[106] Fix | Delete
} else if (stream.skipTo('*')) { //comment is potentially later in line
[107] Fix | Delete
stream.skipTo('*');
[108] Fix | Delete
stream.next();
[109] Fix | Delete
if (stream.eat('/'))
[110] Fix | Delete
state.continueComment = false;
[111] Fix | Delete
} else {
[112] Fix | Delete
stream.skipToEnd();
[113] Fix | Delete
}
[114] Fix | Delete
return "comment";
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
// DoubleOperator match
[118] Fix | Delete
var doubleOperator = ch + stream.peek();
[119] Fix | Delete
[120] Fix | Delete
// Match all line comments.
[121] Fix | Delete
var myString = stream.string;
[122] Fix | Delete
var myRegexp = /(?:^\s*|[;]\s*)(\*.*?);/ig;
[123] Fix | Delete
var match = myRegexp.exec(myString);
[124] Fix | Delete
if (match !== null) {
[125] Fix | Delete
if (match.index === 0 && (stream.column() !== (match.index + match[0].length - 1))) {
[126] Fix | Delete
stream.backUp(stream.column());
[127] Fix | Delete
stream.skipTo(';');
[128] Fix | Delete
stream.next();
[129] Fix | Delete
return 'comment';
[130] Fix | Delete
} else if (match.index + 1 < stream.column() && stream.column() < match.index + match[0].length - 1) {
[131] Fix | Delete
// the ';' triggers the match so move one past it to start
[132] Fix | Delete
// the comment block that is why match.index+1
[133] Fix | Delete
stream.backUp(stream.column() - match.index - 1);
[134] Fix | Delete
stream.skipTo(';');
[135] Fix | Delete
stream.next();
[136] Fix | Delete
return 'comment';
[137] Fix | Delete
}
[138] Fix | Delete
} else if ((ch === '"' || ch === "'") && !state.continueString) {
[139] Fix | Delete
state.continueString = ch
[140] Fix | Delete
return "string"
[141] Fix | Delete
} else if (state.continueString) {
[142] Fix | Delete
if (state.continueString == ch) {
[143] Fix | Delete
state.continueString = null;
[144] Fix | Delete
} else if (stream.skipTo(state.continueString)) {
[145] Fix | Delete
// quote found on this line
[146] Fix | Delete
stream.next();
[147] Fix | Delete
state.continueString = null;
[148] Fix | Delete
} else {
[149] Fix | Delete
stream.skipToEnd();
[150] Fix | Delete
}
[151] Fix | Delete
return "string";
[152] Fix | Delete
} else if (state.continueString !== null && stream.eol()) {
[153] Fix | Delete
stream.skipTo(state.continueString) || stream.skipToEnd();
[154] Fix | Delete
return "string";
[155] Fix | Delete
} else if (/[\d\.]/.test(ch)) { //find numbers
[156] Fix | Delete
if (ch === ".")
[157] Fix | Delete
stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
[158] Fix | Delete
else if (ch === "0")
[159] Fix | Delete
stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
[160] Fix | Delete
else
[161] Fix | Delete
stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
[162] Fix | Delete
return "number";
[163] Fix | Delete
} else if (isDoubleOperatorChar.test(ch + stream.peek())) { // TWO SYMBOL TOKENS
[164] Fix | Delete
stream.next();
[165] Fix | Delete
return "operator";
[166] Fix | Delete
} else if (isDoubleOperatorSym.hasOwnProperty(doubleOperator)) {
[167] Fix | Delete
stream.next();
[168] Fix | Delete
if (stream.peek() === ' ')
[169] Fix | Delete
return isDoubleOperatorSym[doubleOperator.toLowerCase()];
[170] Fix | Delete
} else if (isSingleOperatorChar.test(ch)) { // SINGLE SYMBOL TOKENS
[171] Fix | Delete
return "operator";
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
// Matches one whole word -- even if the word is a character
[175] Fix | Delete
var word;
[176] Fix | Delete
if (stream.match(/[%&;\w]+/, false) != null) {
[177] Fix | Delete
word = ch + stream.match(/[%&;\w]+/, true);
[178] Fix | Delete
if (/&/.test(word)) return 'variable'
[179] Fix | Delete
} else {
[180] Fix | Delete
word = ch;
[181] Fix | Delete
}
[182] Fix | Delete
// the word after DATA PROC or MACRO
[183] Fix | Delete
if (state.nextword) {
[184] Fix | Delete
stream.match(/[\w]+/);
[185] Fix | Delete
// match memname.libname
[186] Fix | Delete
if (stream.peek() === '.') stream.skipTo(' ');
[187] Fix | Delete
state.nextword = false;
[188] Fix | Delete
return 'variable-2';
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
word = word.toLowerCase()
[192] Fix | Delete
// Are we in a DATA Step?
[193] Fix | Delete
if (state.inDataStep) {
[194] Fix | Delete
if (word === 'run;' || stream.match(/run\s;/)) {
[195] Fix | Delete
state.inDataStep = false;
[196] Fix | Delete
return 'builtin';
[197] Fix | Delete
}
[198] Fix | Delete
// variable formats
[199] Fix | Delete
if ((word) && stream.next() === '.') {
[200] Fix | Delete
//either a format or libname.memname
[201] Fix | Delete
if (/\w/.test(stream.peek())) return 'variable-2';
[202] Fix | Delete
else return 'variable';
[203] Fix | Delete
}
[204] Fix | Delete
// do we have a DATA Step keyword
[205] Fix | Delete
if (word && words.hasOwnProperty(word) &&
[206] Fix | Delete
(words[word].state.indexOf("inDataStep") !== -1 ||
[207] Fix | Delete
words[word].state.indexOf("ALL") !== -1)) {
[208] Fix | Delete
//backup to the start of the word
[209] Fix | Delete
if (stream.start < stream.pos)
[210] Fix | Delete
stream.backUp(stream.pos - stream.start);
[211] Fix | Delete
//advance the length of the word and return
[212] Fix | Delete
for (var i = 0; i < word.length; ++i) stream.next();
[213] Fix | Delete
return words[word].style;
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
// Are we in an Proc statement?
[217] Fix | Delete
if (state.inProc) {
[218] Fix | Delete
if (word === 'run;' || word === 'quit;') {
[219] Fix | Delete
state.inProc = false;
[220] Fix | Delete
return 'builtin';
[221] Fix | Delete
}
[222] Fix | Delete
// do we have a proc keyword
[223] Fix | Delete
if (word && words.hasOwnProperty(word) &&
[224] Fix | Delete
(words[word].state.indexOf("inProc") !== -1 ||
[225] Fix | Delete
words[word].state.indexOf("ALL") !== -1)) {
[226] Fix | Delete
stream.match(/[\w]+/);
[227] Fix | Delete
return words[word].style;
[228] Fix | Delete
}
[229] Fix | Delete
}
[230] Fix | Delete
// Are we in a Macro statement?
[231] Fix | Delete
if (state.inMacro) {
[232] Fix | Delete
if (word === '%mend') {
[233] Fix | Delete
if (stream.peek() === ';') stream.next();
[234] Fix | Delete
state.inMacro = false;
[235] Fix | Delete
return 'builtin';
[236] Fix | Delete
}
[237] Fix | Delete
if (word && words.hasOwnProperty(word) &&
[238] Fix | Delete
(words[word].state.indexOf("inMacro") !== -1 ||
[239] Fix | Delete
words[word].state.indexOf("ALL") !== -1)) {
[240] Fix | Delete
stream.match(/[\w]+/);
[241] Fix | Delete
return words[word].style;
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
return 'atom';
[245] Fix | Delete
}
[246] Fix | Delete
// Do we have Keywords specific words?
[247] Fix | Delete
if (word && words.hasOwnProperty(word)) {
[248] Fix | Delete
// Negates the initial next()
[249] Fix | Delete
stream.backUp(1);
[250] Fix | Delete
// Actually move the stream
[251] Fix | Delete
stream.match(/[\w]+/);
[252] Fix | Delete
if (word === 'data' && /=/.test(stream.peek()) === false) {
[253] Fix | Delete
state.inDataStep = true;
[254] Fix | Delete
state.nextword = true;
[255] Fix | Delete
return 'builtin';
[256] Fix | Delete
}
[257] Fix | Delete
if (word === 'proc') {
[258] Fix | Delete
state.inProc = true;
[259] Fix | Delete
state.nextword = true;
[260] Fix | Delete
return 'builtin';
[261] Fix | Delete
}
[262] Fix | Delete
if (word === '%macro') {
[263] Fix | Delete
state.inMacro = true;
[264] Fix | Delete
state.nextword = true;
[265] Fix | Delete
return 'builtin';
[266] Fix | Delete
}
[267] Fix | Delete
if (/title[1-9]/.test(word)) return 'def';
[268] Fix | Delete
[269] Fix | Delete
if (word === 'footnote') {
[270] Fix | Delete
stream.eat(/[1-9]/);
[271] Fix | Delete
return 'def';
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
// Returns their value as state in the prior define methods
[275] Fix | Delete
if (state.inDataStep === true && words[word].state.indexOf("inDataStep") !== -1)
[276] Fix | Delete
return words[word].style;
[277] Fix | Delete
if (state.inProc === true && words[word].state.indexOf("inProc") !== -1)
[278] Fix | Delete
return words[word].style;
[279] Fix | Delete
if (state.inMacro === true && words[word].state.indexOf("inMacro") !== -1)
[280] Fix | Delete
return words[word].style;
[281] Fix | Delete
if (words[word].state.indexOf("ALL") !== -1)
[282] Fix | Delete
return words[word].style;
[283] Fix | Delete
return null;
[284] Fix | Delete
}
[285] Fix | Delete
// Unrecognized syntax
[286] Fix | Delete
return null;
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
return {
[290] Fix | Delete
startState: function () {
[291] Fix | Delete
return {
[292] Fix | Delete
inDataStep: false,
[293] Fix | Delete
inProc: false,
[294] Fix | Delete
inMacro: false,
[295] Fix | Delete
nextword: false,
[296] Fix | Delete
continueString: null,
[297] Fix | Delete
continueComment: false
[298] Fix | Delete
};
[299] Fix | Delete
},
[300] Fix | Delete
token: function (stream, state) {
[301] Fix | Delete
// Strip the spaces, but regex will account for them either way
[302] Fix | Delete
if (stream.eatSpace()) return null;
[303] Fix | Delete
// Go through the main process
[304] Fix | Delete
return tokenize(stream, state);
[305] Fix | Delete
},
[306] Fix | Delete
[307] Fix | Delete
blockCommentStart: "/*",
[308] Fix | Delete
blockCommentEnd: "*/"
[309] Fix | Delete
};
[310] Fix | Delete
[311] Fix | Delete
});
[312] Fix | Delete
[313] Fix | Delete
CodeMirror.defineMIME("text/x-sas", "sas");
[314] Fix | Delete
});
[315] Fix | Delete
[316] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function