gauss.js (17205B)
1 /* 2 Language: GAUSS 3 Author: Matt Evans <matt@aptech.com> 4 Description: GAUSS Mathematical and Statistical language 5 Website: https://www.aptech.com 6 Category: scientific 7 */ 8 function gauss(hljs) { 9 var KEYWORDS = { 10 keyword: 'bool break call callexe checkinterrupt clear clearg closeall cls comlog compile ' + 11 'continue create debug declare delete disable dlibrary dllcall do dos ed edit else ' + 12 'elseif enable end endfor endif endp endo errorlog errorlogat expr external fn ' + 13 'for format goto gosub graph if keyword let lib library line load loadarray loadexe ' + 14 'loadf loadk loadm loadp loads loadx local locate loopnextindex lprint lpwidth lshow ' + 15 'matrix msym ndpclex new open output outwidth plot plotsym pop prcsn print ' + 16 'printdos proc push retp return rndcon rndmod rndmult rndseed run save saveall screen ' + 17 'scroll setarray show sparse stop string struct system trace trap threadfor ' + 18 'threadendfor threadbegin threadjoin threadstat threadend until use while winprint ' + 19 'ne ge le gt lt and xor or not eq eqv', 20 built_in: 'abs acf aconcat aeye amax amean AmericanBinomCall AmericanBinomCall_Greeks AmericanBinomCall_ImpVol ' + 21 'AmericanBinomPut AmericanBinomPut_Greeks AmericanBinomPut_ImpVol AmericanBSCall AmericanBSCall_Greeks ' + 22 'AmericanBSCall_ImpVol AmericanBSPut AmericanBSPut_Greeks AmericanBSPut_ImpVol amin amult annotationGetDefaults ' + 23 'annotationSetBkd annotationSetFont annotationSetLineColor annotationSetLineStyle annotationSetLineThickness ' + 24 'annualTradingDays arccos arcsin areshape arrayalloc arrayindex arrayinit arraytomat asciiload asclabel astd ' + 25 'astds asum atan atan2 atranspose axmargin balance band bandchol bandcholsol bandltsol bandrv bandsolpd bar ' + 26 'base10 begwind besselj bessely beta box boxcox cdfBeta cdfBetaInv cdfBinomial cdfBinomialInv cdfBvn cdfBvn2 ' + 27 'cdfBvn2e cdfCauchy cdfCauchyInv cdfChic cdfChii cdfChinc cdfChincInv cdfExp cdfExpInv cdfFc cdfFnc cdfFncInv ' + 28 'cdfGam cdfGenPareto cdfHyperGeo cdfLaplace cdfLaplaceInv cdfLogistic cdfLogisticInv cdfmControlCreate cdfMvn ' + 29 'cdfMvn2e cdfMvnce cdfMvne cdfMvt2e cdfMvtce cdfMvte cdfN cdfN2 cdfNc cdfNegBinomial cdfNegBinomialInv cdfNi ' + 30 'cdfPoisson cdfPoissonInv cdfRayleigh cdfRayleighInv cdfTc cdfTci cdfTnc cdfTvn cdfWeibull cdfWeibullInv cdir ' + 31 'ceil ChangeDir chdir chiBarSquare chol choldn cholsol cholup chrs close code cols colsf combinate combinated ' + 32 'complex con cond conj cons ConScore contour conv convertsatostr convertstrtosa corrm corrms corrvc corrx corrxs ' + 33 'cos cosh counts countwts crossprd crout croutp csrcol csrlin csvReadM csvReadSA cumprodc cumsumc curve cvtos ' + 34 'datacreate datacreatecomplex datalist dataload dataloop dataopen datasave date datestr datestring datestrymd ' + 35 'dayinyr dayofweek dbAddDatabase dbClose dbCommit dbCreateQuery dbExecQuery dbGetConnectOptions dbGetDatabaseName ' + 36 'dbGetDriverName dbGetDrivers dbGetHostName dbGetLastErrorNum dbGetLastErrorText dbGetNumericalPrecPolicy ' + 37 'dbGetPassword dbGetPort dbGetTableHeaders dbGetTables dbGetUserName dbHasFeature dbIsDriverAvailable dbIsOpen ' + 38 'dbIsOpenError dbOpen dbQueryBindValue dbQueryClear dbQueryCols dbQueryExecPrepared dbQueryFetchAllM dbQueryFetchAllSA ' + 39 'dbQueryFetchOneM dbQueryFetchOneSA dbQueryFinish dbQueryGetBoundValue dbQueryGetBoundValues dbQueryGetField ' + 40 'dbQueryGetLastErrorNum dbQueryGetLastErrorText dbQueryGetLastInsertID dbQueryGetLastQuery dbQueryGetPosition ' + 41 'dbQueryIsActive dbQueryIsForwardOnly dbQueryIsNull dbQueryIsSelect dbQueryIsValid dbQueryPrepare dbQueryRows ' + 42 'dbQuerySeek dbQuerySeekFirst dbQuerySeekLast dbQuerySeekNext dbQuerySeekPrevious dbQuerySetForwardOnly ' + 43 'dbRemoveDatabase dbRollback dbSetConnectOptions dbSetDatabaseName dbSetHostName dbSetNumericalPrecPolicy ' + 44 'dbSetPort dbSetUserName dbTransaction DeleteFile delif delrows denseToSp denseToSpRE denToZero design det detl ' + 45 'dfft dffti diag diagrv digamma doswin DOSWinCloseall DOSWinOpen dotfeq dotfeqmt dotfge dotfgemt dotfgt dotfgtmt ' + 46 'dotfle dotflemt dotflt dotfltmt dotfne dotfnemt draw drop dsCreate dstat dstatmt dstatmtControlCreate dtdate dtday ' + 47 'dttime dttodtv dttostr dttoutc dtvnormal dtvtodt dtvtoutc dummy dummybr dummydn eig eigh eighv eigv elapsedTradingDays ' + 48 'endwind envget eof eqSolve eqSolvemt eqSolvemtControlCreate eqSolvemtOutCreate eqSolveset erf erfc erfccplx erfcplx error ' + 49 'etdays ethsec etstr EuropeanBinomCall EuropeanBinomCall_Greeks EuropeanBinomCall_ImpVol EuropeanBinomPut ' + 50 'EuropeanBinomPut_Greeks EuropeanBinomPut_ImpVol EuropeanBSCall EuropeanBSCall_Greeks EuropeanBSCall_ImpVol ' + 51 'EuropeanBSPut EuropeanBSPut_Greeks EuropeanBSPut_ImpVol exctsmpl exec execbg exp extern eye fcheckerr fclearerr feq ' + 52 'feqmt fflush fft ffti fftm fftmi fftn fge fgemt fgets fgetsa fgetsat fgetst fgt fgtmt fileinfo filesa fle flemt ' + 53 'floor flt fltmt fmod fne fnemt fonts fopen formatcv formatnv fputs fputst fseek fstrerror ftell ftocv ftos ftostrC ' + 54 'gamma gammacplx gammaii gausset gdaAppend gdaCreate gdaDStat gdaDStatMat gdaGetIndex gdaGetName gdaGetNames gdaGetOrders ' + 55 'gdaGetType gdaGetTypes gdaGetVarInfo gdaIsCplx gdaLoad gdaPack gdaRead gdaReadByIndex gdaReadSome gdaReadSparse ' + 56 'gdaReadStruct gdaReportVarInfo gdaSave gdaUpdate gdaUpdateAndPack gdaVars gdaWrite gdaWrite32 gdaWriteSome getarray ' + 57 'getdims getf getGAUSShome getmatrix getmatrix4D getname getnamef getNextTradingDay getNextWeekDay getnr getorders ' + 58 'getpath getPreviousTradingDay getPreviousWeekDay getRow getscalar3D getscalar4D getTrRow getwind glm gradcplx gradMT ' + 59 'gradMTm gradMTT gradMTTm gradp graphprt graphset hasimag header headermt hess hessMT hessMTg hessMTgw hessMTm ' + 60 'hessMTmw hessMTT hessMTTg hessMTTgw hessMTTm hessMTw hessp hist histf histp hsec imag indcv indexcat indices indices2 ' + 61 'indicesf indicesfn indnv indsav integrate1d integrateControlCreate intgrat2 intgrat3 inthp1 inthp2 inthp3 inthp4 ' + 62 'inthpControlCreate intquad1 intquad2 intquad3 intrleav intrleavsa intrsect intsimp inv invpd invswp iscplx iscplxf ' + 63 'isden isinfnanmiss ismiss key keyav keyw lag lag1 lagn lapEighb lapEighi lapEighvb lapEighvi lapgEig lapgEigh lapgEighv ' + 64 'lapgEigv lapgSchur lapgSvdcst lapgSvds lapgSvdst lapSvdcusv lapSvds lapSvdusv ldlp ldlsol linSolve listwise ln lncdfbvn ' + 65 'lncdfbvn2 lncdfmvn lncdfn lncdfn2 lncdfnc lnfact lngammacplx lnpdfmvn lnpdfmvt lnpdfn lnpdft loadd loadstruct loadwind ' + 66 'loess loessmt loessmtControlCreate log loglog logx logy lower lowmat lowmat1 ltrisol lu lusol machEpsilon make makevars ' + 67 'makewind margin matalloc matinit mattoarray maxbytes maxc maxindc maxv maxvec mbesselei mbesselei0 mbesselei1 mbesseli ' + 68 'mbesseli0 mbesseli1 meanc median mergeby mergevar minc minindc minv miss missex missrv moment momentd movingave ' + 69 'movingaveExpwgt movingaveWgt nextindex nextn nextnevn nextwind ntos null null1 numCombinations ols olsmt olsmtControlCreate ' + 70 'olsqr olsqr2 olsqrmt ones optn optnevn orth outtyp pacf packedToSp packr parse pause pdfCauchy pdfChi pdfExp pdfGenPareto ' + 71 'pdfHyperGeo pdfLaplace pdfLogistic pdfn pdfPoisson pdfRayleigh pdfWeibull pi pinv pinvmt plotAddArrow plotAddBar plotAddBox ' + 72 'plotAddHist plotAddHistF plotAddHistP plotAddPolar plotAddScatter plotAddShape plotAddTextbox plotAddTS plotAddXY plotArea ' + 73 'plotBar plotBox plotClearLayout plotContour plotCustomLayout plotGetDefaults plotHist plotHistF plotHistP plotLayout ' + 74 'plotLogLog plotLogX plotLogY plotOpenWindow plotPolar plotSave plotScatter plotSetAxesPen plotSetBar plotSetBarFill ' + 75 'plotSetBarStacked plotSetBkdColor plotSetFill plotSetGrid plotSetLegend plotSetLineColor plotSetLineStyle plotSetLineSymbol ' + 76 'plotSetLineThickness plotSetNewWindow plotSetTitle plotSetWhichYAxis plotSetXAxisShow plotSetXLabel plotSetXRange ' + 77 'plotSetXTicInterval plotSetXTicLabel plotSetYAxisShow plotSetYLabel plotSetYRange plotSetZAxisShow plotSetZLabel ' + 78 'plotSurface plotTS plotXY polar polychar polyeval polygamma polyint polymake polymat polymroot polymult polyroot ' + 79 'pqgwin previousindex princomp printfm printfmt prodc psi putarray putf putvals pvCreate pvGetIndex pvGetParNames ' + 80 'pvGetParVector pvLength pvList pvPack pvPacki pvPackm pvPackmi pvPacks pvPacksi pvPacksm pvPacksmi pvPutParVector ' + 81 'pvTest pvUnpack QNewton QNewtonmt QNewtonmtControlCreate QNewtonmtOutCreate QNewtonSet QProg QProgmt QProgmtInCreate ' + 82 'qqr qqre qqrep qr qre qrep qrsol qrtsol qtyr qtyre qtyrep quantile quantiled qyr qyre qyrep qz rank rankindx readr ' + 83 'real reclassify reclassifyCuts recode recserar recsercp recserrc rerun rescale reshape rets rev rfft rffti rfftip rfftn ' + 84 'rfftnp rfftp rndBernoulli rndBeta rndBinomial rndCauchy rndChiSquare rndCon rndCreateState rndExp rndGamma rndGeo rndGumbel ' + 85 'rndHyperGeo rndi rndKMbeta rndKMgam rndKMi rndKMn rndKMnb rndKMp rndKMu rndKMvm rndLaplace rndLCbeta rndLCgam rndLCi rndLCn ' + 86 'rndLCnb rndLCp rndLCu rndLCvm rndLogNorm rndMTu rndMVn rndMVt rndn rndnb rndNegBinomial rndp rndPoisson rndRayleigh ' + 87 'rndStateSkip rndu rndvm rndWeibull rndWishart rotater round rows rowsf rref sampleData satostrC saved saveStruct savewind ' + 88 'scale scale3d scalerr scalinfnanmiss scalmiss schtoc schur searchsourcepath seekr select selif seqa seqm setdif setdifsa ' + 89 'setvars setvwrmode setwind shell shiftr sin singleindex sinh sleep solpd sortc sortcc sortd sorthc sorthcc sortind ' + 90 'sortindc sortmc sortr sortrc spBiconjGradSol spChol spConjGradSol spCreate spDenseSubmat spDiagRvMat spEigv spEye spLDL ' + 91 'spline spLU spNumNZE spOnes spreadSheetReadM spreadSheetReadSA spreadSheetWrite spScale spSubmat spToDense spTrTDense ' + 92 'spTScalar spZeros sqpSolve sqpSolveMT sqpSolveMTControlCreate sqpSolveMTlagrangeCreate sqpSolveMToutCreate sqpSolveSet ' + 93 'sqrt statements stdc stdsc stocv stof strcombine strindx strlen strput strrindx strsect strsplit strsplitPad strtodt ' + 94 'strtof strtofcplx strtriml strtrimr strtrunc strtruncl strtruncpad strtruncr submat subscat substute subvec sumc sumr ' + 95 'surface svd svd1 svd2 svdcusv svds svdusv sysstate tab tan tanh tempname ' + 96 'time timedt timestr timeutc title tkf2eps tkf2ps tocart todaydt toeplitz token topolar trapchk ' + 97 'trigamma trimr trunc type typecv typef union unionsa uniqindx uniqindxsa unique uniquesa upmat upmat1 upper utctodt ' + 98 'utctodtv utrisol vals varCovMS varCovXS varget vargetl varmall varmares varput varputl vartypef vcm vcms vcx vcxs ' + 99 'vec vech vecr vector vget view viewxyz vlist vnamecv volume vput vread vtypecv wait waitc walkindex where window ' + 100 'writer xlabel xlsGetSheetCount xlsGetSheetSize xlsGetSheetTypes xlsMakeRange xlsReadM xlsReadSA xlsWrite xlsWriteM ' + 101 'xlsWriteSA xpnd xtics xy xyz ylabel ytics zeros zeta zlabel ztics cdfEmpirical dot h5create h5open h5read h5readAttribute ' + 102 'h5write h5writeAttribute ldl plotAddErrorBar plotAddSurface plotCDFEmpirical plotSetColormap plotSetContourLabels ' + 103 'plotSetLegendFont plotSetTextInterpreter plotSetXTicCount plotSetYTicCount plotSetZLevels powerm strjoin sylvester ' + 104 'strtrim', 105 literal: 'DB_AFTER_LAST_ROW DB_ALL_TABLES DB_BATCH_OPERATIONS DB_BEFORE_FIRST_ROW DB_BLOB DB_EVENT_NOTIFICATIONS ' + 106 'DB_FINISH_QUERY DB_HIGH_PRECISION DB_LAST_INSERT_ID DB_LOW_PRECISION_DOUBLE DB_LOW_PRECISION_INT32 ' + 107 'DB_LOW_PRECISION_INT64 DB_LOW_PRECISION_NUMBERS DB_MULTIPLE_RESULT_SETS DB_NAMED_PLACEHOLDERS ' + 108 'DB_POSITIONAL_PLACEHOLDERS DB_PREPARED_QUERIES DB_QUERY_SIZE DB_SIMPLE_LOCKING DB_SYSTEM_TABLES DB_TABLES ' + 109 'DB_TRANSACTIONS DB_UNICODE DB_VIEWS __STDIN __STDOUT __STDERR __FILE_DIR' 110 }; 111 112 113 var AT_COMMENT_MODE = hljs.COMMENT('@', '@'); 114 115 var PREPROCESSOR = 116 { 117 className: 'meta', 118 begin: '#', end: '$', 119 keywords: {'meta-keyword': 'define definecs|10 undef ifdef ifndef iflight ifdllcall ifmac ifos2win ifunix else endif lineson linesoff srcfile srcline'}, 120 contains: [ 121 { 122 begin: /\\\n/, relevance: 0 123 }, 124 { 125 beginKeywords: 'include', end: '$', 126 keywords: {'meta-keyword': 'include'}, 127 contains: [ 128 { 129 className: 'meta-string', 130 begin: '"', end: '"', 131 illegal: '\\n' 132 } 133 ] 134 }, 135 hljs.C_LINE_COMMENT_MODE, 136 hljs.C_BLOCK_COMMENT_MODE, 137 AT_COMMENT_MODE, 138 ] 139 }; 140 141 var STRUCT_TYPE = 142 { 143 begin: /\bstruct\s+/, 144 end: /\s/, 145 keywords: "struct", 146 contains: [ 147 { 148 className: "type", 149 begin: hljs.UNDERSCORE_IDENT_RE, 150 relevance: 0, 151 }, 152 ], 153 }; 154 155 // only for definitions 156 var PARSE_PARAMS = [ 157 { 158 className: 'params', 159 begin: /\(/, end: /\)/, 160 excludeBegin: true, 161 excludeEnd: true, 162 endsWithParent: true, 163 relevance: 0, 164 contains: [ 165 { // dots 166 className: 'literal', 167 begin: /\.\.\./, 168 }, 169 hljs.C_NUMBER_MODE, 170 hljs.C_BLOCK_COMMENT_MODE, 171 AT_COMMENT_MODE, 172 STRUCT_TYPE, 173 ] 174 } 175 ]; 176 177 var FUNCTION_DEF = 178 { 179 className: "title", 180 begin: hljs.UNDERSCORE_IDENT_RE, 181 relevance: 0, 182 }; 183 184 var DEFINITION = function (beginKeywords, end, inherits) { 185 var mode = hljs.inherit( 186 { 187 className: "function", 188 beginKeywords: beginKeywords, 189 end: end, 190 excludeEnd: true, 191 contains: [].concat(PARSE_PARAMS), 192 }, 193 inherits || {} 194 ); 195 mode.contains.push(FUNCTION_DEF); 196 mode.contains.push(hljs.C_NUMBER_MODE); 197 mode.contains.push(hljs.C_BLOCK_COMMENT_MODE); 198 mode.contains.push(AT_COMMENT_MODE); 199 return mode; 200 }; 201 202 var BUILT_IN_REF = 203 { // these are explicitly named internal function calls 204 className: 'built_in', 205 begin: '\\b(' + KEYWORDS.built_in.split(' ').join('|') + ')\\b', 206 }; 207 208 var STRING_REF = 209 { 210 className: 'string', 211 begin: '"', end: '"', 212 contains: [hljs.BACKSLASH_ESCAPE], 213 relevance: 0, 214 }; 215 216 var FUNCTION_REF = 217 { 218 //className: "fn_ref", 219 begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', 220 returnBegin: true, 221 keywords: KEYWORDS, 222 relevance: 0, 223 contains: [ 224 { 225 beginKeywords: KEYWORDS.keyword, 226 }, 227 BUILT_IN_REF, 228 { // ambiguously named function calls get a relevance of 0 229 className: 'built_in', 230 begin: hljs.UNDERSCORE_IDENT_RE, 231 relevance: 0, 232 }, 233 ], 234 }; 235 236 var FUNCTION_REF_PARAMS = 237 { 238 //className: "fn_ref_params", 239 begin: /\(/, 240 end: /\)/, 241 relevance: 0, 242 keywords: { built_in: KEYWORDS.built_in, literal: KEYWORDS.literal }, 243 contains: [ 244 hljs.C_NUMBER_MODE, 245 hljs.C_BLOCK_COMMENT_MODE, 246 AT_COMMENT_MODE, 247 BUILT_IN_REF, 248 FUNCTION_REF, 249 STRING_REF, 250 'self', 251 ], 252 }; 253 254 FUNCTION_REF.contains.push(FUNCTION_REF_PARAMS); 255 256 return { 257 name: 'GAUSS', 258 aliases: ['gss'], 259 case_insensitive: true, // language is case-insensitive 260 keywords: KEYWORDS, 261 illegal: /(\{[%#]|[%#]\}| <- )/, 262 contains: [ 263 hljs.C_NUMBER_MODE, 264 hljs.C_LINE_COMMENT_MODE, 265 hljs.C_BLOCK_COMMENT_MODE, 266 AT_COMMENT_MODE, 267 STRING_REF, 268 PREPROCESSOR, 269 { 270 className: 'keyword', 271 begin: /\bexternal (matrix|string|array|sparse matrix|struct|proc|keyword|fn)/, 272 }, 273 DEFINITION('proc keyword', ';'), 274 DEFINITION('fn', '='), 275 { 276 beginKeywords: 'for threadfor', 277 end: /;/, 278 //end: /\(/, 279 relevance: 0, 280 contains: [ 281 hljs.C_BLOCK_COMMENT_MODE, 282 AT_COMMENT_MODE, 283 FUNCTION_REF_PARAMS, 284 ], 285 }, 286 { // custom method guard 287 // excludes method names from keyword processing 288 variants: [ 289 { begin: hljs.UNDERSCORE_IDENT_RE + '\\.' + hljs.UNDERSCORE_IDENT_RE, }, 290 { begin: hljs.UNDERSCORE_IDENT_RE + '\\s*=', }, 291 ], 292 relevance: 0, 293 }, 294 FUNCTION_REF, 295 STRUCT_TYPE, 296 ] 297 }; 298 } 299 300 module.exports = gauss;