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
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type {languages} from '../fillers/monaco-editor-core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
constants,
|
|
5
|
+
dataTypeFamiliesCaseInsensitive,
|
|
6
|
+
dataTypeFamiliesCaseSensitive,
|
|
7
|
+
functionsCaseInsensitive,
|
|
8
|
+
functionsCaseSensitive,
|
|
9
|
+
keywords,
|
|
10
|
+
tableEngines,
|
|
11
|
+
tableFunctions,
|
|
12
|
+
} from './clickhouse.keywords';
|
|
13
|
+
|
|
14
|
+
export {completionLists} from './clickhouse.keywords';
|
|
15
|
+
|
|
16
|
+
export const conf: languages.LanguageConfiguration = {
|
|
17
|
+
comments: {
|
|
18
|
+
lineComment: '--',
|
|
19
|
+
blockComment: ['```', '```'],
|
|
20
|
+
},
|
|
21
|
+
brackets: [
|
|
22
|
+
['{', '}'],
|
|
23
|
+
['[', ']'],
|
|
24
|
+
['(', ')'],
|
|
25
|
+
],
|
|
26
|
+
autoClosingPairs: [
|
|
27
|
+
{open: '{', close: '}'},
|
|
28
|
+
{open: '[', close: ']'},
|
|
29
|
+
{open: '(', close: ')'},
|
|
30
|
+
{open: '"', close: '"'},
|
|
31
|
+
{open: "'", close: "'"},
|
|
32
|
+
{open: '`', close: '`'},
|
|
33
|
+
],
|
|
34
|
+
surroundingPairs: [
|
|
35
|
+
{open: '{', close: '}'},
|
|
36
|
+
{open: '[', close: ']'},
|
|
37
|
+
{open: '(', close: ')'},
|
|
38
|
+
{open: '"', close: '"'},
|
|
39
|
+
{open: "'", close: "'"},
|
|
40
|
+
{open: '`', close: '`'},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const keywordsCaseInsensitive = getCaseInsensitiveRegExp(keywords);
|
|
45
|
+
const typeKeywordsCaseInsensitive = getCaseInsensitiveRegExp(
|
|
46
|
+
oneWordPatterns(dataTypeFamiliesCaseInsensitive),
|
|
47
|
+
);
|
|
48
|
+
const builtinFunctionsCaseInsensitive = getCaseInsensitiveRegExp(functionsCaseInsensitive);
|
|
49
|
+
|
|
50
|
+
export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
51
|
+
defaultToken: 'text',
|
|
52
|
+
|
|
53
|
+
brackets: [
|
|
54
|
+
{open: '[', close: ']', token: 'delimiter.square'},
|
|
55
|
+
{open: '(', close: ')', token: 'delimiter.parenthesis'},
|
|
56
|
+
{open: '{', close: '}', token: 'delimiter.curly'},
|
|
57
|
+
],
|
|
58
|
+
|
|
59
|
+
keywords,
|
|
60
|
+
|
|
61
|
+
keywordsDouble: [
|
|
62
|
+
`${caseInsensitiveRegExp('GROUP')}\\W+${caseInsensitiveRegExp('BY')}`,
|
|
63
|
+
`${caseInsensitiveRegExp('ON')}\\W+${caseInsensitiveRegExp('CLUSTER')}`,
|
|
64
|
+
`${caseInsensitiveRegExp('ORDER')}\\W+${caseInsensitiveRegExp('BY')}`,
|
|
65
|
+
`${caseInsensitiveRegExp('LIMIT')}\\W+\\d+\\W*,\\W*\\d+`,
|
|
66
|
+
`${caseInsensitiveRegExp('LIMIT')}\\W+\\d+\\W+${caseInsensitiveRegExp('BY')}\\W+`,
|
|
67
|
+
`${caseInsensitiveRegExp('LIMIT')}\\W+\\d+`,
|
|
68
|
+
`${caseInsensitiveRegExp('RENAME')}\\W+${caseInsensitiveRegExp('TABLE')}`,
|
|
69
|
+
`${caseInsensitiveRegExp('IF')}\\W+${caseInsensitiveRegExp('NOT')}\\W+${caseInsensitiveRegExp('EXISTS')}`,
|
|
70
|
+
`${caseInsensitiveRegExp('IF')}\\W+${caseInsensitiveRegExp('EXISTS')}`,
|
|
71
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+Vertical`,
|
|
72
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+JSONCompact`,
|
|
73
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+JSONEachRow`,
|
|
74
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+TSKV`,
|
|
75
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+TabSeparatedWithNames`,
|
|
76
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+TabSeparatedWithNamesAndTypes`,
|
|
77
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+TabSeparatedRaw`,
|
|
78
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+BlockTabSeparated`,
|
|
79
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+CSVWithNames`,
|
|
80
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+CSV`,
|
|
81
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+JSON`,
|
|
82
|
+
`${caseInsensitiveRegExp('FORMAT')}\\W+TabSeparated`,
|
|
83
|
+
].join('|'),
|
|
84
|
+
|
|
85
|
+
typeKeywords: dataTypeFamiliesCaseSensitive,
|
|
86
|
+
typeKeywordsDouble: getCaseInsensitiveRegExp(
|
|
87
|
+
manyWordsPatterns(dataTypeFamiliesCaseInsensitive),
|
|
88
|
+
),
|
|
89
|
+
constants,
|
|
90
|
+
|
|
91
|
+
builtinFunctions: functionsCaseSensitive,
|
|
92
|
+
|
|
93
|
+
tableFunctions,
|
|
94
|
+
tableEngines,
|
|
95
|
+
|
|
96
|
+
operators: [
|
|
97
|
+
'+',
|
|
98
|
+
'-',
|
|
99
|
+
'/',
|
|
100
|
+
'//',
|
|
101
|
+
'%',
|
|
102
|
+
'<@>',
|
|
103
|
+
'@>',
|
|
104
|
+
'<@',
|
|
105
|
+
'&',
|
|
106
|
+
'^',
|
|
107
|
+
'~',
|
|
108
|
+
'<',
|
|
109
|
+
'>',
|
|
110
|
+
'<=',
|
|
111
|
+
'=>',
|
|
112
|
+
'==',
|
|
113
|
+
'!=',
|
|
114
|
+
'<>',
|
|
115
|
+
'=',
|
|
116
|
+
],
|
|
117
|
+
|
|
118
|
+
symbols: /[=><!~?:&|+\-*/^%]+/,
|
|
119
|
+
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
120
|
+
// TODO: FIX ME
|
|
121
|
+
variables: /[\w]+(?:\[[\w\]+]|[=-]>\w+)?/,
|
|
122
|
+
|
|
123
|
+
tokenizer: {
|
|
124
|
+
root: [
|
|
125
|
+
{include: '@whitespace'},
|
|
126
|
+
{include: '@comments'},
|
|
127
|
+
{include: '@numbers'},
|
|
128
|
+
{include: '@strings'},
|
|
129
|
+
// variables
|
|
130
|
+
[/[$@:](@variables)/, 'variable'],
|
|
131
|
+
[/{(@variables)}/, 'variable'],
|
|
132
|
+
[/[?;,.]/, 'delimiter'],
|
|
133
|
+
[/[(){}[\]]/, '@brackets'],
|
|
134
|
+
// identifiers and keywords
|
|
135
|
+
[/@keywordsDouble/, 'keyword'],
|
|
136
|
+
[/@typeKeywordsDouble/, 'keyword.type'],
|
|
137
|
+
[
|
|
138
|
+
/[a-zA-Z_$][\w$]*/,
|
|
139
|
+
{
|
|
140
|
+
cases: {
|
|
141
|
+
[keywordsCaseInsensitive]: {token: 'keyword'},
|
|
142
|
+
'@constants': {token: 'constant'},
|
|
143
|
+
'@builtinFunctions': {token: 'constant.other.color'},
|
|
144
|
+
[builtinFunctionsCaseInsensitive]: {token: 'constant.other.color'},
|
|
145
|
+
'@tableFunctions': {token: 'constant.other.color'},
|
|
146
|
+
'@tableEngines': {token: 'constant.other.color'},
|
|
147
|
+
'@typeKeywords': {token: 'keyword.type'},
|
|
148
|
+
[typeKeywordsCaseInsensitive]: {token: 'keyword.type'},
|
|
149
|
+
'@default': 'identifier',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
/@symbols/,
|
|
155
|
+
{
|
|
156
|
+
cases: {
|
|
157
|
+
'@operators': 'operator.sql',
|
|
158
|
+
'@default': '',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
],
|
|
163
|
+
whitespace: [[/\s+/, 'white']],
|
|
164
|
+
comments: [
|
|
165
|
+
[/--+.*/, 'comment'],
|
|
166
|
+
[/```/, {token: 'comment.quote', next: '@comment'}],
|
|
167
|
+
[/\/\*/, {token: 'comment.quote', next: '@cppComment'}],
|
|
168
|
+
],
|
|
169
|
+
comment: [
|
|
170
|
+
[/[^`]+/, 'comment'],
|
|
171
|
+
[/```/, {token: 'comment.quote', next: '@pop'}],
|
|
172
|
+
[/./, 'comment'],
|
|
173
|
+
],
|
|
174
|
+
cppComment: [
|
|
175
|
+
[/[^*/]+/, 'comment'],
|
|
176
|
+
[/\*\//, {token: 'comment.quote', next: '@pop'}],
|
|
177
|
+
[/./, 'comment'],
|
|
178
|
+
],
|
|
179
|
+
numbers: [[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, 'number']],
|
|
180
|
+
strings: [
|
|
181
|
+
[/'/, {token: 'string', next: '@stringSingle'}],
|
|
182
|
+
[/"/, {token: 'string.tablepath', next: '@stringDouble'}],
|
|
183
|
+
[/`/, {token: 'string.tablepath', next: '@stringBacktick'}],
|
|
184
|
+
],
|
|
185
|
+
stringSingle: [
|
|
186
|
+
[/[^\\']/, 'string'],
|
|
187
|
+
[/@escapes/, 'string.escape'],
|
|
188
|
+
[/\\./, 'string.escape.invalid'],
|
|
189
|
+
[/'/, {token: 'string', next: '@pop'}],
|
|
190
|
+
],
|
|
191
|
+
stringDouble: [
|
|
192
|
+
[/[^\\"]/, 'string.tablepath'],
|
|
193
|
+
[/@escapes/, 'string.tablepath'],
|
|
194
|
+
[/\\./, 'string.tablepath'],
|
|
195
|
+
[/"/, {token: 'string.tablepath', next: '@pop'}],
|
|
196
|
+
],
|
|
197
|
+
stringBacktick: [
|
|
198
|
+
[/[^\\`]/, 'string.tablepath'],
|
|
199
|
+
[/@escapes/, 'string.tablepath'],
|
|
200
|
+
[/\\./, 'string.tablepath'],
|
|
201
|
+
[/`/, {token: 'string.tablepath', next: '@pop'}],
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
function caseInsensitiveRegExp(pattern: string) {
|
|
207
|
+
return pattern
|
|
208
|
+
.split('')
|
|
209
|
+
.map((char) => {
|
|
210
|
+
if (/[a-zA-Z]/.test(char)) {
|
|
211
|
+
return `[${char.toLowerCase()}${char.toUpperCase()}]`;
|
|
212
|
+
}
|
|
213
|
+
return char;
|
|
214
|
+
})
|
|
215
|
+
.join('');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getCaseInsensitiveRegExp(patterns: string[]) {
|
|
219
|
+
return `(${patterns.map((pattern) => caseInsensitiveRegExp(pattern).replace(/\s+/g, '\\s')).join('|')})`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function oneWordPatterns(patterns: string[]) {
|
|
223
|
+
return patterns.filter((pattern) => /^\S*$/.test(pattern));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function manyWordsPatterns(patterns: string[]) {
|
|
227
|
+
return patterns.filter((pattern) => /\s/.test(pattern)).sort((a, b) => b.localeCompare(a));
|
|
228
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CancellationToken,
|
|
3
|
+
IRange,
|
|
4
|
+
Position,
|
|
5
|
+
editor,
|
|
6
|
+
languages,
|
|
7
|
+
} from './fillers/monaco-editor-core';
|
|
8
|
+
|
|
9
|
+
export type CompletionListProvider = {
|
|
10
|
+
(content: string, offset: number, signal?: AbortSignal | null): Promise<string[]>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const allUpperCaseRe = new RegExp('^[$A-Z_\\s]+$');
|
|
14
|
+
|
|
15
|
+
export function provideCompletionItems(getCompletionList: CompletionListProvider) {
|
|
16
|
+
return (
|
|
17
|
+
model: editor.ITextModel,
|
|
18
|
+
position: Position,
|
|
19
|
+
context: languages.CompletionContext,
|
|
20
|
+
token: CancellationToken,
|
|
21
|
+
): languages.ProviderResult<languages.CompletionList> => {
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const signal = controller.signal;
|
|
24
|
+
token.onCancellationRequested(() => {
|
|
25
|
+
controller.abort();
|
|
26
|
+
});
|
|
27
|
+
const prevText = model
|
|
28
|
+
.getLineContent(position.lineNumber)
|
|
29
|
+
.slice(0, position.column - 1)
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
if (context.triggerCharacter === ':' && prevText.slice(-2) !== '::') {
|
|
32
|
+
return {suggestions: []};
|
|
33
|
+
} else if (context.triggerCharacter === '`' && /[^\s.]`$/.test(prevText)) {
|
|
34
|
+
return {suggestions: []};
|
|
35
|
+
}
|
|
36
|
+
return getCompletionList(model.getValue(), model.getOffsetAt(position), signal).then(
|
|
37
|
+
async (data: string[]) => {
|
|
38
|
+
const suggestions: languages.CompletionItem[] = [];
|
|
39
|
+
for (const label of data) {
|
|
40
|
+
const suggest =
|
|
41
|
+
label.length > 1
|
|
42
|
+
? label.slice(0, -1).replace(/[/[]/g, '\\\\$&') + label.slice(-1)
|
|
43
|
+
: label;
|
|
44
|
+
let range: IRange | undefined;
|
|
45
|
+
if (/[`~!@#%^&*()-=+[{\]}|;:'",.<>/?]/.test(suggest)) {
|
|
46
|
+
for (let i = 0; i < label.length; i++) {
|
|
47
|
+
const prefix = (i === 0 ? suggest : suggest.slice(0, -i)).toLowerCase();
|
|
48
|
+
if (prevText.endsWith(prefix)) {
|
|
49
|
+
range = {
|
|
50
|
+
startLineNumber: position.lineNumber,
|
|
51
|
+
startColumn: position.column - prefix.length,
|
|
52
|
+
endLineNumber: position.lineNumber,
|
|
53
|
+
endColumn: position.column,
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
suggestions.push({
|
|
60
|
+
label,
|
|
61
|
+
filterText: allUpperCaseRe.test(label) ? label.toLowerCase() : label,
|
|
62
|
+
kind: 18, // languages.CompletionItemKind.Text,
|
|
63
|
+
insertText: suggest,
|
|
64
|
+
command:
|
|
65
|
+
label.endsWith('/') || label.endsWith('.`') || label.endsWith('::')
|
|
66
|
+
? {id: 'editor.action.triggerSuggest', title: ''}
|
|
67
|
+
: undefined,
|
|
68
|
+
//@ts-ignore
|
|
69
|
+
range,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {suggestions, incomplete: suggestions.length > 0};
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type CompletionLists = Partial<
|
|
79
|
+
Record<`${Uncapitalize<keyof typeof languages.CompletionItemKind>}List`, Readonly<string[]>>
|
|
80
|
+
>;
|
|
81
|
+
|
|
82
|
+
export function getCompletionItemsProvider(
|
|
83
|
+
completions: CompletionLists,
|
|
84
|
+
completionItemKind: typeof languages.CompletionItemKind,
|
|
85
|
+
) {
|
|
86
|
+
const suggestions: languages.CompletionItem[] = [];
|
|
87
|
+
|
|
88
|
+
for (const value in completionItemKind) {
|
|
89
|
+
if (!isNaN(Number(value))) {
|
|
90
|
+
const name = `${completionItemKind[value].toLowerCase()}List`;
|
|
91
|
+
if (name in completions) {
|
|
92
|
+
for (const label of completions[name as keyof CompletionLists] as string[]) {
|
|
93
|
+
suggestions.push({
|
|
94
|
+
label,
|
|
95
|
+
filterText: allUpperCaseRe.test(label) ? label.toLowerCase() : label,
|
|
96
|
+
insertText: label,
|
|
97
|
+
kind: Number(value),
|
|
98
|
+
range: {startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
suggestions.sort((a, b) => a.filterText!.localeCompare(b.filterText!));
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
provideCompletionItems(
|
|
108
|
+
model: editor.ITextModel,
|
|
109
|
+
position: Position,
|
|
110
|
+
_context: languages.CompletionContext,
|
|
111
|
+
_token: CancellationToken,
|
|
112
|
+
): languages.CompletionList | undefined {
|
|
113
|
+
const word = model.getWordUntilPosition(position);
|
|
114
|
+
const range = {
|
|
115
|
+
startLineNumber: position.lineNumber,
|
|
116
|
+
startColumn: word.startColumn,
|
|
117
|
+
endLineNumber: position.lineNumber,
|
|
118
|
+
endColumn: word.endColumn,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return {suggestions: suggestions.map((s) => ({...s, range}))};
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'monaco-editor/esm/vs/editor/editor.api';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const keywordControl =
|
|
2
|
+
'bind|block|declare|export|import|lambda|let|override_library|package|quote|return|set_package_version'.split(
|
|
3
|
+
'|',
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
export const keywordOperator =
|
|
7
|
+
'Abs|Add|AddMember|AddMemberType|AddTimezone|AggrAdd|AggrConcat|AggrCountInit|AggrCountUpdate|AggrEquals|AggrGreater|AggrGreaterOrEqual|AggrLess|AggrLessOrEqual|AggrMax|AggrMin|AggrNotEquals|Aggregate|AggregationTraits|AlterTo|And|Append|Apply|AsDict|AsDictStrict|AsEnum|AsList|AsListStrict|AsSet|AsSetStrict|AsStruct|AsTagged|AsVariant|Ascending|AssumeSorted|AssumeStrict|AssumeUnique|AtomCode|AuthTokens|BitAnd|BitCast|BitNot|BitOr|BitXor|Bool|ByteAt|CalcOverWindow|Callable|CallableArgument|CallableArgumentType|CallableResultType|CallableType|CallableTypeComponents|CallableTypeHandle|Cast|CastStruct|Chain1Map|Chopper|Coalesce|Collect|CombineByKey|CombineCore|CommonJoinCore|Concat|Condense|Condense1|ConstraintsOf|Contains|Convert|CountBits|CurrentAuthenticatedUser|CurrentOperationId|CurrentOperationSharedId|CurrentTzDate|CurrentTzDatetime|CurrentTzTimestamp|CurrentUtcDate|CurrentUtcDatetime|CurrentUtcTimestamp|Data|DataSink|DataSource|DataType|DataTypeComponents|DataTypeHandle|Date|Datetime|Dec|Decimal|Default|DependsOn|Descending|Dict|DictFromKeys|DictItems|DictKeyType|DictKeys|DictPayloadType|DictPayloads|DictType|DictTypeComponents|DictTypeHandle|Discard|Div|DivePrefixMembers|Double|EmptyDictType|EmptyDictTypeHandle|EmptyIterator|EmptyListType|EmptyListTypeHandle|EndsWith|Ensure|EnsureConvertibleTo|EnsureType|Enum|Enumerate|Equals|EquiJoin|Error|ErrorType|EvaluateCode|EvaluateType|Exists|ExpandMap|Extend|Extract|ExtractMembers|FileContent|FilePath|Files|Filter|FilterNullElements|FilterNullMembers|Find|FlatListIf|FlatMap|FlatOptionalIf|FlattenByColumns|FlattenMembers|FlattenMembersType|Float|Fold|Fold1|Fold1Map|FoldMap|ForceRemoveMember|ForceRemoveMemberType|FormatCode|FormatCodeWithPositions|FormatType|ForwardList|FromBytes|FromString|FromYsonSimpleType|FuncCode|GenericType|Greater|GreaterOrEqual|GroupByKey|GroupingCore|Guess|HasItems|Head|HoppingCore|If|IfPresent|IfStrict|IfType|Inc|Insert|InstanceOf|Int16|Int32|Int64|Int8|Interval|IsKeySwitch|Iterator|Join|Json|Just|KeepTop|Key|LMap|Lag|LambdaArgumentsCount|LambdaCode|LambdaOptionalArgumentsCount|Last|Lead|Length|Less|LessOrEqual|Likely|Limit|List|ListCode|ListFromRange|ListIf|ListItemType|ListType|ListTypeHandle|Lookup|Map|MapJoinCore|MatchType|Max|Member|Merge|Min|Minus|Mod|Mul|MultiAggregate|MultiHoppingCore|MultiMap|NamedApply|NarrowFlatMap|NarrowMap|NarrowMultiMap|NewMTRand|NextMTRand|Not|NotEquals|Nothing|Now|Nth|Null|NullType|NullTypeHandle|Nvl|Optional|OptionalIf|OptionalItemType|OptionalReduce|OptionalType|OptionalTypeHandle|Or|OrderedExtend|OrderedExtract|OrderedFilter|OrderedFlatMap|OrderedMap|OrderedMultiMap|Parameter|ParseType|ParseTypeHandle|PartitionByKey|PartitionsByKeys|Pickle|Plus|Prepend|PreserveStream|QueueCreate|QueuePeek|QueuePop|QueuePush|QuoteCode|RFind|Random|RandomNumber|RandomUuid|RemoveMember|RemoveMemberType|RemoveTimezone|ReplaceMember|Replicate|ReprCode|ResourceType|ResourceTypeHandle|ResourceTypeTag|Reverse|RotLeft|RotRight|RowNumber|SafeCast|ScriptUdf|SelectMembers|SerializeCode|ShiftLeft|ShiftRight|Size|Skip|SkipNullElements|SkipNullMembers|SkipWhile|SkipWhileInclusive|Sort|SortTraits|SourceOf|SqlAccess|SqlColumn|StablePickle|StartsWith|StaticFold|StaticFold1|StaticMap|StaticZip|StreamItemType|StreamType|StreamTypeHandle|StrictCast|StrictFromString|String|Struct|StructMemberType|StructType|StructTypeComponents|StructTypeHandle|Sub|Substring|Switch|TableName|TablePath|TableRecord|TaggedType|TaggedTypeComponents|TaggedTypeHandle|Take|TakeWhile|TakeWhileInclusive|Timestamp|ToBytes|ToDict|ToIndexDict|ToIntegral|ToList|ToOptional|ToSequence|ToStream|ToString|Top|TopSort|TryMember|TryWeakMemberFromDict|Tuple|TupleElementType|TupleType|TupleTypeComponents|TupleTypeHandle|TypeHandle|TypeKind|TypeOf|TzDate|TzDatetime|TzTimestamp|Udf|Uint16|Uint32|Uint64|Uint8|UnionAll|UnionMerge|UnitType|Unordered|Unpickle|Untag|Unwrap|Utf8|Uuid|Variant|VariantItem|VariantType|VariantTypeHandle|VariantUnderlyingType|Visit|Void|VoidType|VoidTypeHandle|Way|WideChain1Map|WideChopper|WideCombiner|WideCondense1|WideFilter|WideMap|WideSkipWhile|WideSkipWhileInclusive|WideTakeWhile|WideTakeWhileInclusive|WinOnGroups|WinOnRange|WinOnRows|WindowTraits|WithOptionalArgs|WorldCode|Xor|Yson|Zip|ZipAll'.split(
|
|
8
|
+
'|',
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const variables =
|
|
12
|
+
'Commit!|CommitAll!|ConfRead!|Configure!|Epoch|If!|Left!|MrConfigure!|MrCopy!|MrDrop!|MrEquiJoin!|MrFill!|MrIsKeySwitch|MrLMap!|MrLReduce!|MrLength|MrMap!|MrMapReduce!|MrMove!|MrOrderedReduce!|MrPublish!|MrReadTable!|MrReadTableScheme!|MrReduce!|MrSort!|MrTableContent|MrTableIndex|MrTablePath|MrTableRange!|MrTableRecord|MrTempTable|MrWrite!|Read!|ResFill!|ResIf!|ResPull!|ResWrite!|Right!|RtCreateTable!|RtDropTable!|RtInSection|RtMap!|RtMeta|RtOutSection|RtOutTable|RtOutput!|RtReadTable!|RtReadTableScheme!|RtReduce!|RtRowSpec|RtTable|RtWriteTable!|RtYdbOut!|StatFields|StatMeta|StatPublish!|StatTable|StatWriteTable!|Sync!|Write!|YqlRowSpec|YtConfigure!|YtCopy!|YtDropTable!|YtEquiJoin!|YtFill!|YtIsKeySwitch|YtKeyExact|YtKeyRange|YtLength|YtMap!|YtMapReduce!|YtMerge!|YtMeta|YtOutTable|YtOutput!|YtPath|YtPublish!|YtReadTable!|YtReadTableScheme!|YtReduce!|YtRow|YtRowRange|YtSection|YtSort!|YtStat|YtStatOut!|YtStatOutTable|YtTable|YtTableContent|YtTableIndex|YtTablePath|YtTableRecord|YtTouch!|YtWriteTable!'.split(
|
|
13
|
+
'|',
|
|
14
|
+
);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {languages} from '../fillers/monaco-editor-core';
|
|
2
|
+
|
|
3
|
+
import {keywordControl, keywordOperator, variables} from './s-expressions.keywords';
|
|
4
|
+
|
|
5
|
+
export const LANGUAGE_ID = 's-expressions';
|
|
6
|
+
|
|
7
|
+
export const conf: languages.LanguageConfiguration = {
|
|
8
|
+
comments: {
|
|
9
|
+
lineComment: '#',
|
|
10
|
+
},
|
|
11
|
+
brackets: [
|
|
12
|
+
['{', '}'],
|
|
13
|
+
['[', ']'],
|
|
14
|
+
['(', ')'],
|
|
15
|
+
],
|
|
16
|
+
autoClosingPairs: [
|
|
17
|
+
{open: '{', close: '}'},
|
|
18
|
+
{open: '[', close: ']'},
|
|
19
|
+
{open: '(', close: ')'},
|
|
20
|
+
],
|
|
21
|
+
surroundingPairs: [
|
|
22
|
+
{open: '{', close: '}'},
|
|
23
|
+
{open: '[', close: ']'},
|
|
24
|
+
{open: '(', close: ')'},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
29
|
+
defaultToken: 'text',
|
|
30
|
+
ignoreCase: true,
|
|
31
|
+
tokenPostfix: '.yql',
|
|
32
|
+
|
|
33
|
+
brackets: [
|
|
34
|
+
{open: '[', close: ']', token: 'delimiter.square'},
|
|
35
|
+
{open: '(', close: ')', token: 'delimiter.parenthesis'},
|
|
36
|
+
{open: '{', close: '}', token: 'delimiter.curly'},
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
keywordControl,
|
|
40
|
+
|
|
41
|
+
keywordOperator,
|
|
42
|
+
|
|
43
|
+
variables,
|
|
44
|
+
|
|
45
|
+
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
46
|
+
|
|
47
|
+
tokenizer: {
|
|
48
|
+
root: [
|
|
49
|
+
{include: '@whitespace'},
|
|
50
|
+
{include: '@comment'},
|
|
51
|
+
[/(#)((?:\w|[\\+-=<>'"&#])+)/, ['delimiter', 'constant']],
|
|
52
|
+
[
|
|
53
|
+
/(?:\b(?:(defun|defmethod|defmacro))\b)(\s+)((?:\w|-|\?)*)/,
|
|
54
|
+
['type.function', 'text', 'entity.name'],
|
|
55
|
+
],
|
|
56
|
+
[/(\*)(\S*)(\*)/, ['delimiter', 'variable', 'delimiter']],
|
|
57
|
+
{include: '@strings'},
|
|
58
|
+
[/'[^#\s)(]+/, 'variable.parameter'],
|
|
59
|
+
[/[(){}[\]]/, '@brackets'],
|
|
60
|
+
// identifiers and keywords
|
|
61
|
+
[
|
|
62
|
+
/(?:(?:<=?|>=?|==|!=|[-+*/%])|[a-zA-Z][a-zA-Z0-9!]*)/,
|
|
63
|
+
{
|
|
64
|
+
cases: {
|
|
65
|
+
'@keywordControl': {token: 'keyword.operator'},
|
|
66
|
+
'@keywordOperator': {token: 'keyword.control'},
|
|
67
|
+
'@variables': {token: 'variable'},
|
|
68
|
+
'@default': 'identifier',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
],
|
|
73
|
+
whitespace: [[/\s+/, 'white']],
|
|
74
|
+
comment: [[/#.*/, 'comment']],
|
|
75
|
+
strings: [
|
|
76
|
+
[/'?"(?=.)/, {token: 'string', next: '@qqstring'}],
|
|
77
|
+
[/'?[@]{2}/, {token: 'string', next: '@multiline'}],
|
|
78
|
+
[/'?x"(?:[0-9A-Fa-f]{2})*"/, 'string'],
|
|
79
|
+
],
|
|
80
|
+
qqstring: [
|
|
81
|
+
[/\\(?:[0-3][0-7][0-7]|x[0-9A-Fa-f]{2}|["tnrbfav\\])/, 'string.escape'],
|
|
82
|
+
[/[^"\\]+/, 'string'],
|
|
83
|
+
[/"|$/, {token: 'string', next: '@pop'}],
|
|
84
|
+
],
|
|
85
|
+
multiline: [
|
|
86
|
+
[/[^@]+/, 'string'],
|
|
87
|
+
[/[@]{2}/, {token: 'string', next: '@pop'}],
|
|
88
|
+
[/./, {token: 'string'}],
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as monaco from '../fillers/monaco-editor-core';
|
|
2
|
+
|
|
3
|
+
monaco.editor.defineTheme('vs', {
|
|
4
|
+
base: 'vs',
|
|
5
|
+
inherit: true,
|
|
6
|
+
rules: [
|
|
7
|
+
// Path to table
|
|
8
|
+
{token: 'string.tablepath', foreground: '338186'},
|
|
9
|
+
// Constants true
|
|
10
|
+
{token: 'constant.yql', foreground: '608b4e'},
|
|
11
|
+
// Data types JSON, Int32 etc
|
|
12
|
+
{token: 'keyword.type', foreground: '4d932d'},
|
|
13
|
+
// Strings
|
|
14
|
+
{token: 'string.sql', foreground: 'a31515'},
|
|
15
|
+
// UDF
|
|
16
|
+
{token: 'support.function', foreground: '7a3e9d'},
|
|
17
|
+
// Builtin functions COUNT(
|
|
18
|
+
{token: 'constant.other.color', foreground: '7a3e9d'},
|
|
19
|
+
// Comments
|
|
20
|
+
{token: 'comment', foreground: '969896'},
|
|
21
|
+
],
|
|
22
|
+
colors: {
|
|
23
|
+
'editor.lineHighlightBackground': '#EFEFEF',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
monaco.editor.defineTheme('vs-dark', {
|
|
28
|
+
base: 'vs-dark',
|
|
29
|
+
inherit: true,
|
|
30
|
+
rules: [
|
|
31
|
+
// Path to table
|
|
32
|
+
{token: 'string.tablepath', foreground: '338186'},
|
|
33
|
+
// Constants true
|
|
34
|
+
{token: 'constant.yql', foreground: '608b4e'},
|
|
35
|
+
// Data types JSON, Int32 etc
|
|
36
|
+
{token: 'storage.type', foreground: '6A8759'},
|
|
37
|
+
// Strings
|
|
38
|
+
{token: 'string.sql', foreground: 'ce9178'},
|
|
39
|
+
// UDF
|
|
40
|
+
{token: 'support.function', foreground: '9e7bb0'},
|
|
41
|
+
// Builtin functions COUNT(
|
|
42
|
+
{token: 'constant.other.color', foreground: '9e7bb0'},
|
|
43
|
+
// Comments
|
|
44
|
+
{token: 'comment', foreground: '969896'},
|
|
45
|
+
],
|
|
46
|
+
colors: {
|
|
47
|
+
'editor.lineHighlightBackground': '#282A2E',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {registerLanguage} from '../_.contribution';
|
|
2
|
+
|
|
3
|
+
export const LANGUAGE_ID = 'yql';
|
|
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(),
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const keywords =
|
|
2
|
+
'$row|$rows|action|add|all|alter|and|any|as|asc|assume|async|bigserial|serial|smallserial|serial8|serial4|serial2|begin|bernoulli|between|by|case|changefeed|column|columns|commit|compact|create|cross|cube|declare|define|delete|desc|dict|discard|distinct|do|drop|else|empty_action|end|erase|evaluate|exclusion|exists|export|family|flatten|for|from|full|global|group|grouping|having|if|ignore|ilike|import|in|index|inner|insert|into|is|join|key|left|like|limit|list|match|not|null|nulls|offset|on|only|optional|or|order|over|partition|pragma|presort|primary|process|reduce|regexp|repeatable|replace|respect|result|return|right|rlike|rollup|sample|schema|select|semi|set|sets|stream|subquery|sync|table|tablesample|then|truncate|union|intersect|except|update|upsert|use|using|values|view|when|where|window|with|without|xor|callable|resource|tagged|generic|unit|void|emptylist|emptydict|flow|callable|resource|tagged|generic|unit|void|emptylist|emptydict|flow'.split(
|
|
3
|
+
'|',
|
|
4
|
+
);
|
|
5
|
+
export const typeKeywords =
|
|
6
|
+
'bool|date|datetime|decimal|double|float|int16|int32|int64|int8|interval|json|jsondocument|string|timestamp|tzdate|tzdatetime|tztimestamp|uint16|uint32|uint64|uint8|utf8|uuid|yson|text|bytes'.split(
|
|
7
|
+
'|',
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const builtinFunctions =
|
|
11
|
+
'abs|aggregate_by|aggregate_list|aggregate_list_distinct|agg_list|agg_list_distinct|as_table|avg|avg_if|adaptivedistancehistogram|adaptivewardhistogram|adaptiveweighthistogram|addmember|addtimezone|aggregateflatten|aggregatetransforminput|aggregatetransformoutput|aggregationfactory|asatom|asdict|asdictstrict|asenum|aslist|asliststrict|asset|assetstrict|asstruct|astagged|astuple|asvariant|atomcode|bitcast|bit_and|bit_or|bit_xor|bool_and|bool_or|bool_xor|bottom|bottom_by|blockwardhistogram|blockweighthistogram|cast|coalesce|concat|concat_strict|correlation|count|count_if|covariance|covariance_population|covariance_sample|callableargument|callableargumenttype|callableresulttype|callabletype|callabletypecomponents|callabletypehandle|choosemembers|combinemembers|countdistinctestimate|currentauthenticateduser|currentoperationid|currentoperationsharedid|currenttzdate|currenttzdatetime|currenttztimestamp|currentutcdate|currentutcdatetime|currentutctimestamp|dense_rank|datatype|datatypecomponents|datatypehandle|dictaggregate|dictcontains|dictcreate|dicthasitems|dictitems|dictkeytype|dictkeys|dictlength|dictlookup|dictpayloadtype|dictpayloads|dicttype|dicttypecomponents|dicttypehandle|each|each_strict|emptydicttype|emptydicttypehandle|emptylisttype|emptylisttypehandle|endswith|ensure|ensureconvertibleto|ensuretype|enum|evaluateatom|evaluatecode|evaluateexpr|evaluatetype|expandstruct|filter|filter_strict|find|first_value|folder|filecontent|filepath|flattenmembers|forceremovemember|forceremovemembers|forcerenamemembers|forcespreadmembers|formatcode|formattype|frombytes|frompg|funccode|greatest|grouping|gathermembers|generictype|histogram|hll|hoppingwindowpgcast|hyperloglog|if|if_strict|instanceof|json_exists|json_query|json_value|jointablerow|just|lag|last_value|lead|least|len|length|like|likely|like_strict|lambdaargumentscount|lambdacode|lambdaoptionalargumentscount|linearhistogram|listaggregate|listall|listany|listavg|listcode|listcollect|listconcat|listcreate|listdistinct|listenumerate|listextend|listextendstrict|listextract|listfilter|listflatmap|listflatten|listfold|listfold1|listfold1map|listfoldmap|listfromrange|listfromtuple|listhas|listhasitems|listhead|listindexof|listitemtype|listlast|listlength|listmap|listmax|listmin|listnotnull|listreplicate|listreverse|listskip|listskipwhile|listskipwhileinclusive|listsort|listsortasc|listsortdesc|listsum|listtake|listtakewhile|listtakewhileinclusive|listtotuple|listtype|listtypehandle|listunionall|listuniq|listzip|listzipall|loghistogram|logarithmichistogram|max|max_by|max_of|median|min|min_by|min_of|mode|multi_aggregate_by|nanvl|nvl|nothing|nulltype|nulltypehandle|optionalitemtype|optionaltype|optionaltypehandle|percentile|parsefile|parsetype|parsetypehandle|pgand|pgarray|pgcall|pgconst|pgnot|pgop|pgor|pickle|quotecode|range|range_strict|rank|regexp|regexp_strict|rfind|row_number|random|randomnumber|randomuuid|removemember|removemembers|removetimezone|renamemembers|replacemember|reprcode|resourcetype|resourcetypehandle|resourcetypetag|some|stddev|stddev_population|stddev_sample|substring|sum|sum_if|sessionstart|sessionwindow|setcreate|setdifference|setincludes|setintersection|setisdisjoint|setsymmetricdifference|setunion|spreadmembers|stablepickle|startswith|staticmap|staticzip|streamitemtype|streamtype|streamtypehandle|structmembertype|structmembers|structtypecomponents|structtypehandle|subqueryextend|subqueryextendfor|subquerymerge|subquerymergefor|subqueryunionall|subqueryunionallfor|subqueryunionmerge|subqueryunionmergefor|top|topfreq|top_by|tablename|tablepath|tablerecordindex|tablerow|tablerows|taggedtype|taggedtypecomponents|taggedtypehandle|tobytes|todict|tomultidict|topg|toset|tosorteddict|tosortedmultidict|trymember|tupleelementtype|tupletype|tupletypecomponents|tupletypehandle|typehandle|typekind|typeof|udaf|udf|unittype|unpickle|untag|unwrap|variance|variance_population|variance_sample|variant|varianttype|varianttypehandle|variantunderlyingtype|voidtype|voidtypehandle|way|worldcode|weakfield'.split(
|
|
12
|
+
'|',
|
|
13
|
+
);
|