livecodeserver.js 10 KB

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