monaco-yql-languages 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +17 -0
- package/.eslintignore +1 -0
- package/.eslintrc +7 -0
- package/.github/workflows/ci.yml +44 -0
- package/.github/workflows/publication.yml +21 -0
- package/.github/workflows/release.yml +21 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierignore +4 -0
- package/.prettierignore copy +2 -0
- package/.prettierrc.js +1 -0
- package/.stylelintrc +3 -0
- package/AUTHORS +5 -0
- package/CHANGELOG.md +31 -0
- package/CODEOWNERS +1 -0
- package/CONTRIBUTING.md +36 -0
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/commitlint.config.js +1 -0
- package/package.json +51 -0
- package/src/_.contribution.ts +246 -0
- package/src/clickhouse/clickhouse.contribution.ts +31 -0
- package/src/clickhouse/clickhouse.keywords.ts +1306 -0
- package/src/clickhouse/clickhouse.ts +228 -0
- package/src/completion.ts +124 -0
- package/src/fillers/monaco-editor-core.ts +1 -0
- package/src/monaco.contribution.ts +5 -0
- package/src/s-expressions/s-expressions.contribution.ts +9 -0
- package/src/s-expressions/s-expressions.keywords.ts +14 -0
- package/src/s-expressions/s-expressions.ts +91 -0
- package/src/themes/themes.contribution.ts +49 -0
- package/src/yql/yql.contribution.ts +15 -0
- package/src/yql/yql.keywords.ts +13 -0
- package/src/yql/yql.ts +198 -0
- package/src/yql/yql_ansi.contribution.ts +15 -0
- package/tsconfig.json +19 -0
package/src/yql/yql.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type {languages} from '../fillers/monaco-editor-core';
|
|
2
|
+
|
|
3
|
+
import {builtinFunctions, keywords, typeKeywords} from './yql.keywords';
|
|
4
|
+
|
|
5
|
+
export const conf: languages.LanguageConfiguration = {
|
|
6
|
+
comments: {
|
|
7
|
+
lineComment: '--',
|
|
8
|
+
blockComment: ['/*', '*/'],
|
|
9
|
+
},
|
|
10
|
+
brackets: [
|
|
11
|
+
['{', '}'],
|
|
12
|
+
['[', ']'],
|
|
13
|
+
['(', ')'],
|
|
14
|
+
],
|
|
15
|
+
autoClosingPairs: [
|
|
16
|
+
{open: '{', close: '}'},
|
|
17
|
+
{open: '[', close: ']'},
|
|
18
|
+
{open: '(', close: ')'},
|
|
19
|
+
{open: '"', close: '"'},
|
|
20
|
+
{open: "'", close: "'"},
|
|
21
|
+
{open: '`', close: '`'},
|
|
22
|
+
],
|
|
23
|
+
surroundingPairs: [
|
|
24
|
+
{open: '{', close: '}'},
|
|
25
|
+
{open: '[', close: ']'},
|
|
26
|
+
{open: '(', close: ')'},
|
|
27
|
+
{open: '"', close: '"'},
|
|
28
|
+
{open: "'", close: "'"},
|
|
29
|
+
{open: '`', close: '`'},
|
|
30
|
+
],
|
|
31
|
+
wordPattern: /(-?\d*\.\d\w*)|([^`~!@#%^&*()\-=+[{\]}\\|;:'",./?\s]+)/g,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface LanguageOptions {
|
|
35
|
+
ansi?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export function getLanguage({ansi = false}: LanguageOptions = {}): languages.IMonarchLanguage &
|
|
38
|
+
Record<string, unknown> {
|
|
39
|
+
return {
|
|
40
|
+
defaultToken: 'text',
|
|
41
|
+
ignoreCase: true,
|
|
42
|
+
|
|
43
|
+
brackets: [
|
|
44
|
+
{open: '[', close: ']', token: 'delimiter.square'},
|
|
45
|
+
{open: '(', close: ')', token: 'delimiter.parenthesis'},
|
|
46
|
+
{open: '{', close: '}', token: 'delimiter.curly'},
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
keywords,
|
|
50
|
+
|
|
51
|
+
typeKeywords,
|
|
52
|
+
|
|
53
|
+
constants: ['true', 'false', 'enabled', 'disabled'],
|
|
54
|
+
|
|
55
|
+
builtinFunctions,
|
|
56
|
+
|
|
57
|
+
operators: [
|
|
58
|
+
'+',
|
|
59
|
+
'-',
|
|
60
|
+
'/',
|
|
61
|
+
'//',
|
|
62
|
+
'%',
|
|
63
|
+
'<@>',
|
|
64
|
+
'@>',
|
|
65
|
+
'<@',
|
|
66
|
+
'&',
|
|
67
|
+
'^',
|
|
68
|
+
'~',
|
|
69
|
+
'<',
|
|
70
|
+
'>',
|
|
71
|
+
'<=',
|
|
72
|
+
'>=',
|
|
73
|
+
'=>',
|
|
74
|
+
'==',
|
|
75
|
+
'!=',
|
|
76
|
+
'<>',
|
|
77
|
+
'=',
|
|
78
|
+
],
|
|
79
|
+
|
|
80
|
+
symbols: /[=><!~?:&|+\-*/^%]+/,
|
|
81
|
+
escapes: /\\(?:[abfnrtv\\"'`]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
82
|
+
variables: /[a-zA-Z_]\w*/,
|
|
83
|
+
|
|
84
|
+
tokenizer: {
|
|
85
|
+
root: [
|
|
86
|
+
{include: '@whitespace'},
|
|
87
|
+
{include: '@comments'},
|
|
88
|
+
{include: '@numbers'},
|
|
89
|
+
{include: '@tablePath'},
|
|
90
|
+
{include: '@strings'},
|
|
91
|
+
{include: '@primaryKey'},
|
|
92
|
+
// support function
|
|
93
|
+
[/(@variables)::(@variables)/, 'support.function'],
|
|
94
|
+
[/[;,.]/, 'delimiter'],
|
|
95
|
+
[/[(){}[\]]/, '@brackets'],
|
|
96
|
+
// identifiers and keywords
|
|
97
|
+
[
|
|
98
|
+
/@?[a-zA-Z_$]\w*/,
|
|
99
|
+
{
|
|
100
|
+
cases: {
|
|
101
|
+
'@keywords': 'keyword',
|
|
102
|
+
'@typeKeywords': 'keyword.type',
|
|
103
|
+
'@constants': 'constant.yql',
|
|
104
|
+
'@builtinFunctions': 'constant.other.color',
|
|
105
|
+
'[$@][a-zA-Z_]\\w*': 'variable',
|
|
106
|
+
'@default': 'identifier',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
/@symbols/,
|
|
112
|
+
{
|
|
113
|
+
cases: {
|
|
114
|
+
'@operators': 'operator.sql',
|
|
115
|
+
'@default': '',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
],
|
|
120
|
+
whitespace: [[/\s+/, 'white']],
|
|
121
|
+
comments: [
|
|
122
|
+
[/--.*/, 'comment'],
|
|
123
|
+
[/\/\*/, {token: 'comment.quote', next: ansi ? '@commentAnsi' : '@comment'}],
|
|
124
|
+
],
|
|
125
|
+
comment: [
|
|
126
|
+
[/[^*/]+/, 'comment'],
|
|
127
|
+
[/\*\//, {token: 'comment.quote', next: '@pop'}],
|
|
128
|
+
[/./, 'comment'],
|
|
129
|
+
],
|
|
130
|
+
commentAnsi: [
|
|
131
|
+
[/\/\*/, {token: 'comment.quote', next: '@comment'}],
|
|
132
|
+
[/[^*/]+/, 'comment'],
|
|
133
|
+
[/\*\//, {token: 'comment.quote', next: '@pop'}],
|
|
134
|
+
[/./, 'comment'],
|
|
135
|
+
],
|
|
136
|
+
numbers: [
|
|
137
|
+
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?f?\b/, 'number.float'],
|
|
138
|
+
[/[+-]?(?:\d+|0b[01]+|0o[0-8]+|0x[\da-f]+)(?:u?[lst]?)?\b/, 'number'],
|
|
139
|
+
],
|
|
140
|
+
strings: [
|
|
141
|
+
[/'/, {token: 'string', next: ansi ? '@stringAnsiSingle' : '@stringSingle'}],
|
|
142
|
+
[/"/, {token: 'string', next: ansi ? '@stringAnsiDouble' : '@stringDouble'}],
|
|
143
|
+
[/[@]{2}/, {token: 'string', next: '@multilineString'}],
|
|
144
|
+
],
|
|
145
|
+
stringSingle: [
|
|
146
|
+
[/[^\\']+/, 'string'],
|
|
147
|
+
[/@escapes/, 'string.escape'],
|
|
148
|
+
[/\\./, 'string.escape.invalid'],
|
|
149
|
+
[/'[uyj]?/, {token: 'string', next: '@pop'}],
|
|
150
|
+
],
|
|
151
|
+
stringAnsiSingle: [
|
|
152
|
+
[/[^']+/, 'string'],
|
|
153
|
+
[/''/, 'string'],
|
|
154
|
+
[/'[uyj]?/, {token: 'string', next: '@pop'}],
|
|
155
|
+
],
|
|
156
|
+
stringDouble: [
|
|
157
|
+
[/[^\\"]+/, 'string'],
|
|
158
|
+
[/@escapes/, 'string.escape'],
|
|
159
|
+
[/\\./, 'string.escape.invalid'],
|
|
160
|
+
[/"[uyj]?/, {token: 'string', next: '@pop'}],
|
|
161
|
+
],
|
|
162
|
+
stringAnsiDouble: [
|
|
163
|
+
[/[^"]+/, 'string'],
|
|
164
|
+
[/""/, 'string'],
|
|
165
|
+
[/"[uyj]?/, {token: 'string', next: '@pop'}],
|
|
166
|
+
],
|
|
167
|
+
multilineString: [
|
|
168
|
+
[
|
|
169
|
+
/#py/,
|
|
170
|
+
{token: 'string.python', nextEmbedded: 'python', next: '@embedded', goBack: 3},
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
/\/\/js/,
|
|
174
|
+
{token: 'string.js', nextEmbedded: 'javascript', next: '@embedded', goBack: 4},
|
|
175
|
+
],
|
|
176
|
+
[/[^@]+/, 'string'],
|
|
177
|
+
[/[@]{4}/, 'string'],
|
|
178
|
+
[/[@]{2}[uyj]?/, {token: 'string', next: '@pop'}],
|
|
179
|
+
[/./, 'string'],
|
|
180
|
+
],
|
|
181
|
+
embedded: [
|
|
182
|
+
[
|
|
183
|
+
/([^@]|^)([@]{4})*[@]{2}([@]([^@]|$)|[^@]|$)/,
|
|
184
|
+
{token: '@rematch', next: '@pop', nextEmbedded: '@pop'},
|
|
185
|
+
],
|
|
186
|
+
],
|
|
187
|
+
tablePath: [[/((`)?[\w/]+\2\s*\.\s*)?`/, {token: 'string.tablepath', next: '@table'}]],
|
|
188
|
+
table: [
|
|
189
|
+
[/[^\\`]+/, 'string.tablepath'],
|
|
190
|
+
[/``/, 'string.tablepath'],
|
|
191
|
+
[/@escapes/, 'string.escape.tablepath'],
|
|
192
|
+
[/\\./, 'string.escape.invalid.tablepath'],
|
|
193
|
+
[/`/, {token: 'string.tablepath', next: '@pop'}],
|
|
194
|
+
],
|
|
195
|
+
primaryKey: [[/primary key/i, 'keyword']],
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {registerLanguage} from '../_.contribution';
|
|
2
|
+
|
|
3
|
+
export const LANGUAGE_ID = 'yql_ansi';
|
|
4
|
+
|
|
5
|
+
registerLanguage({
|
|
6
|
+
id: LANGUAGE_ID,
|
|
7
|
+
extensions: [],
|
|
8
|
+
loader: () =>
|
|
9
|
+
import('./yql').then((module) => {
|
|
10
|
+
return {
|
|
11
|
+
conf: module.conf,
|
|
12
|
+
language: module.getLanguage({ansi: true}),
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@gravity-ui/tsconfig/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"resolveJsonModule": true,
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"module": "esnext",
|
|
8
|
+
"jsx": "react"
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"src/**/*.ts",
|
|
12
|
+
"src/**/*.tsx"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"**/__tests__",
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"**/*.test.tsx",
|
|
18
|
+
]
|
|
19
|
+
}
|