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