gauss.js 17 KB

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