cos.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. module.exports = function cos (hljs) {
  2. var STRINGS = {
  3. className: 'string',
  4. variants: [
  5. {
  6. begin: '"',
  7. end: '"',
  8. contains: [{ // escaped
  9. begin: "\"\"",
  10. relevance: 0
  11. }]
  12. }
  13. ]
  14. };
  15. var NUMBERS = {
  16. className: "number",
  17. begin: "\\b(\\d+(\\.\\d*)?|\\.\\d+)",
  18. relevance: 0
  19. };
  20. var COS_KEYWORDS =
  21. 'property parameter class classmethod clientmethod extends as break ' +
  22. 'catch close continue do d|0 else elseif for goto halt hang h|0 if job ' +
  23. 'j|0 kill k|0 lock l|0 merge new open quit q|0 read r|0 return set s|0 ' +
  24. 'tcommit throw trollback try tstart use view while write w|0 xecute x|0 ' +
  25. 'zkill znspace zn ztrap zwrite zw zzdump zzwrite print zbreak zinsert ' +
  26. 'zload zprint zremove zsave zzprint mv mvcall mvcrt mvdim mvprint zquit ' +
  27. 'zsync ascii';
  28. // registered function - no need in them due to all functions are highlighted,
  29. // but I'll just leave this here.
  30. //"$bit", "$bitcount",
  31. //"$bitfind", "$bitlogic", "$case", "$char", "$classmethod", "$classname",
  32. //"$compile", "$data", "$decimal", "$double", "$extract", "$factor",
  33. //"$find", "$fnumber", "$get", "$increment", "$inumber", "$isobject",
  34. //"$isvaliddouble", "$isvalidnum", "$justify", "$length", "$list",
  35. //"$listbuild", "$listdata", "$listfind", "$listfromstring", "$listget",
  36. //"$listlength", "$listnext", "$listsame", "$listtostring", "$listvalid",
  37. //"$locate", "$match", "$method", "$name", "$nconvert", "$next",
  38. //"$normalize", "$now", "$number", "$order", "$parameter", "$piece",
  39. //"$prefetchoff", "$prefetchon", "$property", "$qlength", "$qsubscript",
  40. //"$query", "$random", "$replace", "$reverse", "$sconvert", "$select",
  41. //"$sortbegin", "$sortend", "$stack", "$text", "$translate", "$view",
  42. //"$wascii", "$wchar", "$wextract", "$wfind", "$wiswide", "$wlength",
  43. //"$wreverse", "$xecute", "$zabs", "$zarccos", "$zarcsin", "$zarctan",
  44. //"$zcos", "$zcot", "$zcsc", "$zdate", "$zdateh", "$zdatetime",
  45. //"$zdatetimeh", "$zexp", "$zhex", "$zln", "$zlog", "$zpower", "$zsec",
  46. //"$zsin", "$zsqr", "$ztan", "$ztime", "$ztimeh", "$zboolean",
  47. //"$zconvert", "$zcrc", "$zcyc", "$zdascii", "$zdchar", "$zf",
  48. //"$ziswide", "$zlascii", "$zlchar", "$zname", "$zposition", "$zqascii",
  49. //"$zqchar", "$zsearch", "$zseek", "$zstrip", "$zwascii", "$zwchar",
  50. //"$zwidth", "$zwpack", "$zwbpack", "$zwunpack", "$zwbunpack", "$zzenkaku",
  51. //"$change", "$mv", "$mvat", "$mvfmt", "$mvfmts", "$mviconv",
  52. //"$mviconvs", "$mvinmat", "$mvlover", "$mvoconv", "$mvoconvs", "$mvraise",
  53. //"$mvtrans", "$mvv", "$mvname", "$zbitand", "$zbitcount", "$zbitfind",
  54. //"$zbitget", "$zbitlen", "$zbitnot", "$zbitor", "$zbitset", "$zbitstr",
  55. //"$zbitxor", "$zincrement", "$znext", "$zorder", "$zprevious", "$zsort",
  56. //"device", "$ecode", "$estack", "$etrap", "$halt", "$horolog",
  57. //"$io", "$job", "$key", "$namespace", "$principal", "$quit", "$roles",
  58. //"$storage", "$system", "$test", "$this", "$tlevel", "$username",
  59. //"$x", "$y", "$za", "$zb", "$zchild", "$zeof", "$zeos", "$zerror",
  60. //"$zhorolog", "$zio", "$zjob", "$zmode", "$znspace", "$zparent", "$zpi",
  61. //"$zpos", "$zreference", "$zstorage", "$ztimestamp", "$ztimezone",
  62. //"$ztrap", "$zversion"
  63. return {
  64. case_insensitive: true,
  65. aliases: ["cos", "cls"],
  66. keywords: COS_KEYWORDS,
  67. contains: [
  68. NUMBERS,
  69. STRINGS,
  70. hljs.C_LINE_COMMENT_MODE,
  71. hljs.C_BLOCK_COMMENT_MODE,
  72. {
  73. className: "comment",
  74. begin: /;/, end: "$",
  75. relevance: 0
  76. },
  77. { // Functions and user-defined functions: write $ztime(60*60*3), $$myFunc(10), $$^Val(1)
  78. className: "built_in",
  79. begin: /(?:\$\$?|\.\.)\^?[a-zA-Z]+/
  80. },
  81. { // Macro command: quit $$$OK
  82. className: "built_in",
  83. begin: /\$\$\$[a-zA-Z]+/
  84. },
  85. { // Special (global) variables: write %request.Content; Built-in classes: %Library.Integer
  86. className: "built_in",
  87. begin: /%[a-z]+(?:\.[a-z]+)*/
  88. },
  89. { // Global variable: set ^globalName = 12 write ^globalName
  90. className: "symbol",
  91. begin: /\^%?[a-zA-Z][\w]*/
  92. },
  93. { // Some control constructions: do ##class(Package.ClassName).Method(), ##super()
  94. className: "keyword",
  95. begin: /##class|##super|#define|#dim/
  96. },
  97. // sub-languages: are not fully supported by hljs by 11/15/2015
  98. // left for the future implementation.
  99. {
  100. begin: /&sql\(/, end: /\)/,
  101. excludeBegin: true, excludeEnd: true,
  102. subLanguage: "sql"
  103. },
  104. {
  105. begin: /&(js|jscript|javascript)</, end: />/,
  106. excludeBegin: true, excludeEnd: true,
  107. subLanguage: "javascript"
  108. },
  109. {
  110. // this brakes first and last tag, but this is the only way to embed a valid html
  111. begin: /&html<\s*</, end: />\s*>/,
  112. subLanguage: "xml"
  113. }
  114. ]
  115. };
  116. };