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