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