livecodeserver.js 10 KB

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