livecodeserver.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. module.exports = function(hljs) {
  2. var VARIABLE = {
  3. className: 'variable',
  4. variants: [
  5. {begin: '\\b([gtps][A-Z]{1}[a-zA-Z0-9]*)(\\[.+\\])?(?:\\s*?)'},
  6. {begin: '\\$_[A-Z]+'}
  7. ],
  8. relevance: 0
  9. };
  10. var COMMENT_MODES = [
  11. hljs.C_BLOCK_COMMENT_MODE,
  12. hljs.HASH_COMMENT_MODE,
  13. hljs.COMMENT('--', '$'),
  14. hljs.COMMENT('[^:]//', '$')
  15. ];
  16. var TITLE1 = hljs.inherit(hljs.TITLE_MODE, {
  17. variants: [
  18. {begin: '\\b_*rig[A-Z]+[A-Za-z0-9_\\-]*'},
  19. {begin: '\\b_[a-z0-9\\-]+'}
  20. ]
  21. });
  22. var TITLE2 = hljs.inherit(hljs.TITLE_MODE, {begin: '\\b([A-Za-z0-9_\\-]+)\\b'});
  23. return {
  24. case_insensitive: false,
  25. keywords: {
  26. keyword:
  27. '$_COOKIE $_FILES $_GET $_GET_BINARY $_GET_RAW $_POST $_POST_BINARY $_POST_RAW $_SESSION $_SERVER ' +
  28. 'codepoint codepoints segment segments codeunit codeunits sentence sentences trueWord trueWords paragraph ' +
  29. 'after byte bytes english the until http forever descending using line real8 with seventh ' +
  30. 'for stdout finally element word words fourth before black ninth sixth characters chars stderr ' +
  31. 'uInt1 uInt1s uInt2 uInt2s stdin string lines relative rel any fifth items from middle mid ' +
  32. 'at else of catch then third it file milliseconds seconds second secs sec int1 int1s int4 ' +
  33. 'int4s internet int2 int2s normal text item last long detailed effective uInt4 uInt4s repeat ' +
  34. 'end repeat URL in try into switch to words https token binfile each tenth as ticks tick ' +
  35. 'system real4 by dateItems without char character ascending eighth whole dateTime numeric short ' +
  36. 'first ftp integer abbreviated abbr abbrev private case while if ' +
  37. 'div mod wrap and or bitAnd bitNot bitOr bitXor among not in a an within ' +
  38. 'contains ends with begins the keys of keys',
  39. literal:
  40. 'SIX TEN FORMFEED NINE ZERO NONE SPACE FOUR FALSE COLON CRLF PI COMMA ENDOFFILE EOF EIGHT FIVE ' +
  41. 'QUOTE EMPTY ONE TRUE RETURN CR LINEFEED RIGHT BACKSLASH NULL SEVEN TAB THREE TWO ' +
  42. 'six ten formfeed nine zero none space four false colon crlf pi comma endoffile eof eight five ' +
  43. 'quote empty one true return cr linefeed right backslash null seven tab three two ' +
  44. 'RIVERSION RISTATE FILE_READ_MODE FILE_WRITE_MODE FILE_WRITE_MODE DIR_WRITE_MODE FILE_READ_UMASK ' +
  45. 'FILE_WRITE_UMASK DIR_READ_UMASK DIR_WRITE_UMASK',
  46. built_in:
  47. 'put abs acos aliasReference annuity arrayDecode arrayEncode asin atan atan2 average avg avgDev base64Decode ' +
  48. 'base64Encode baseConvert binaryDecode binaryEncode byteOffset byteToNum cachedURL cachedURLs charToNum ' +
  49. 'cipherNames codepointOffset codepointProperty codepointToNum codeunitOffset commandNames compound compress ' +
  50. 'constantNames cos date dateFormat decompress difference directories ' +
  51. 'diskSpace DNSServers exp exp1 exp2 exp10 extents files flushEvents folders format functionNames geometricMean global ' +
  52. 'globals hasMemory harmonicMean hostAddress hostAddressToName hostName hostNameToAddress isNumber ISOToMac itemOffset ' +
  53. 'keys len length libURLErrorData libUrlFormData libURLftpCommand libURLLastHTTPHeaders libURLLastRHHeaders ' +
  54. 'libUrlMultipartFormAddPart libUrlMultipartFormData libURLVersion lineOffset ln ln1 localNames log log2 log10 ' +
  55. 'longFilePath lower macToISO matchChunk matchText matrixMultiply max md5Digest median merge messageAuthenticationCode messageDigest millisec ' +
  56. 'millisecs millisecond milliseconds min monthNames nativeCharToNum normalizeText num number numToByte numToChar ' +
  57. 'numToCodepoint numToNativeChar offset open openfiles openProcesses openProcessIDs openSockets ' +
  58. 'paragraphOffset paramCount param params peerAddress pendingMessages platform popStdDev populationStandardDeviation ' +
  59. 'populationVariance popVariance processID random randomBytes replaceText result revCreateXMLTree revCreateXMLTreeFromFile ' +
  60. 'revCurrentRecord revCurrentRecordIsFirst revCurrentRecordIsLast revDatabaseColumnCount revDatabaseColumnIsNull ' +
  61. 'revDatabaseColumnLengths revDatabaseColumnNames revDatabaseColumnNamed revDatabaseColumnNumbered ' +
  62. 'revDatabaseColumnTypes revDatabaseConnectResult revDatabaseCursors revDatabaseID revDatabaseTableNames ' +
  63. 'revDatabaseType revDataFromQuery revdb_closeCursor revdb_columnbynumber revdb_columncount revdb_columnisnull ' +
  64. 'revdb_columnlengths revdb_columnnames revdb_columntypes revdb_commit revdb_connect revdb_connections ' +
  65. 'revdb_connectionerr revdb_currentrecord revdb_cursorconnection revdb_cursorerr revdb_cursors revdb_dbtype ' +
  66. 'revdb_disconnect revdb_execute revdb_iseof revdb_isbof revdb_movefirst revdb_movelast revdb_movenext ' +
  67. 'revdb_moveprev revdb_query revdb_querylist revdb_recordcount revdb_rollback revdb_tablenames ' +
  68. 'revGetDatabaseDriverPath revNumberOfRecords revOpenDatabase revOpenDatabases revQueryDatabase ' +
  69. 'revQueryDatabaseBlob revQueryResult revQueryIsAtStart revQueryIsAtEnd revUnixFromMacPath revXMLAttribute ' +
  70. 'revXMLAttributes revXMLAttributeValues revXMLChildContents revXMLChildNames revXMLCreateTreeFromFileWithNamespaces ' +
  71. 'revXMLCreateTreeWithNamespaces revXMLDataFromXPathQuery revXMLEvaluateXPath revXMLFirstChild revXMLMatchingNode ' +
  72. 'revXMLNextSibling revXMLNodeContents revXMLNumberOfChildren revXMLParent revXMLPreviousSibling ' +
  73. 'revXMLRootNode revXMLRPC_CreateRequest revXMLRPC_Documents revXMLRPC_Error ' +
  74. 'revXMLRPC_GetHost revXMLRPC_GetMethod revXMLRPC_GetParam revXMLText revXMLRPC_Execute ' +
  75. 'revXMLRPC_GetParamCount revXMLRPC_GetParamNode revXMLRPC_GetParamType revXMLRPC_GetPath revXMLRPC_GetPort ' +
  76. 'revXMLRPC_GetProtocol revXMLRPC_GetRequest revXMLRPC_GetResponse revXMLRPC_GetSocket revXMLTree ' +
  77. 'revXMLTrees revXMLValidateDTD revZipDescribeItem revZipEnumerateItems revZipOpenArchives round sampVariance ' +
  78. 'sec secs seconds sentenceOffset sha1Digest shell shortFilePath sin specialFolderPath sqrt standardDeviation statRound ' +
  79. 'stdDev sum sysError systemVersion tan tempName textDecode textEncode tick ticks time to tokenOffset toLower toUpper ' +
  80. 'transpose truewordOffset trunc uniDecode uniEncode upper URLDecode URLEncode URLStatus uuid value variableNames ' +
  81. 'variance version waitDepth weekdayNames wordOffset xsltApplyStylesheet xsltApplyStylesheetFromFile xsltLoadStylesheet ' +
  82. 'xsltLoadStylesheetFromFile add breakpoint cancel clear local variable file word line folder directory URL close socket process ' +
  83. 'combine constant convert create new alias folder directory decrypt delete variable word line folder ' +
  84. 'directory URL dispatch divide do encrypt filter get include intersect kill libURLDownloadToFile ' +
  85. 'libURLFollowHttpRedirects libURLftpUpload libURLftpUploadFile libURLresetAll libUrlSetAuthCallback libURLSetDriver ' +
  86. 'libURLSetCustomHTTPHeaders libUrlSetExpect100 libURLSetFTPListCommand libURLSetFTPMode libURLSetFTPStopTime ' +
  87. 'libURLSetStatusCallback load extension loadedExtensions multiply socket prepare process post seek rel relative read from process rename ' +
  88. 'replace require resetAll resolve revAddXMLNode revAppendXML revCloseCursor revCloseDatabase revCommitDatabase ' +
  89. 'revCopyFile revCopyFolder revCopyXMLNode revDeleteFolder revDeleteXMLNode revDeleteAllXMLTrees ' +
  90. 'revDeleteXMLTree revExecuteSQL revGoURL revInsertXMLNode revMoveFolder revMoveToFirstRecord revMoveToLastRecord ' +
  91. 'revMoveToNextRecord revMoveToPreviousRecord revMoveToRecord revMoveXMLNode revPutIntoXMLNode revRollBackDatabase ' +
  92. 'revSetDatabaseDriverPath revSetXMLAttribute revXMLRPC_AddParam revXMLRPC_DeleteAllDocuments revXMLAddDTD ' +
  93. 'revXMLRPC_Free revXMLRPC_FreeAll revXMLRPC_DeleteDocument revXMLRPC_DeleteParam revXMLRPC_SetHost ' +
  94. 'revXMLRPC_SetMethod revXMLRPC_SetPort revXMLRPC_SetProtocol revXMLRPC_SetSocket revZipAddItemWithData ' +
  95. 'revZipAddItemWithFile revZipAddUncompressedItemWithData revZipAddUncompressedItemWithFile revZipCancel ' +
  96. 'revZipCloseArchive revZipDeleteItem revZipExtractItemToFile revZipExtractItemToVariable revZipSetProgressCallback ' +
  97. 'revZipRenameItem revZipReplaceItemWithData revZipReplaceItemWithFile revZipOpenArchive send set sort split start stop ' +
  98. 'subtract symmetric union unload vectorDotProduct wait write'
  99. },
  100. contains: [
  101. VARIABLE,
  102. {
  103. className: 'keyword',
  104. begin: '\\bend\\sif\\b'
  105. },
  106. {
  107. className: 'function',
  108. beginKeywords: 'function', end: '$',
  109. contains: [
  110. VARIABLE,
  111. TITLE2,
  112. hljs.APOS_STRING_MODE,
  113. hljs.QUOTE_STRING_MODE,
  114. hljs.BINARY_NUMBER_MODE,
  115. hljs.C_NUMBER_MODE,
  116. TITLE1
  117. ]
  118. },
  119. {
  120. className: 'function',
  121. begin: '\\bend\\s+', end: '$',
  122. keywords: 'end',
  123. contains: [
  124. TITLE2,
  125. TITLE1
  126. ],
  127. relevance: 0
  128. },
  129. {
  130. beginKeywords: 'command on', end: '$',
  131. contains: [
  132. VARIABLE,
  133. TITLE2,
  134. hljs.APOS_STRING_MODE,
  135. hljs.QUOTE_STRING_MODE,
  136. hljs.BINARY_NUMBER_MODE,
  137. hljs.C_NUMBER_MODE,
  138. TITLE1
  139. ]
  140. },
  141. {
  142. className: 'meta',
  143. variants: [
  144. {
  145. begin: '<\\?(rev|lc|livecode)',
  146. relevance: 10
  147. },
  148. { begin: '<\\?' },
  149. { begin: '\\?>' }
  150. ]
  151. },
  152. hljs.APOS_STRING_MODE,
  153. hljs.QUOTE_STRING_MODE,
  154. hljs.BINARY_NUMBER_MODE,
  155. hljs.C_NUMBER_MODE,
  156. TITLE1
  157. ].concat(COMMENT_MODES),
  158. illegal: ';$|^\\[|^=|&|{'
  159. };
  160. };