-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRQL.sublime-syntax
173 lines (138 loc) · 4.29 KB
/
PRQL.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
%YAML 1.2
---
# See http://www.sublimetext.com/docs/syntax.html
file_extensions:
- prql
scope: source.prql
variables:
identifier: '[A-Za-z]\w*'
contexts:
main:
- include: functions
- include: numbers
# Strings
- match: '[frs]?"'
scope: punctuation.definition.string.begin.prql
push: double_quoted_string
- match: "[frs]?'"
scope: punctuation.definition.string.begin.prql
push: single_quoted_string
# Docblocks
- match: '#!'
scope: punctuation.definition.documentation.prql
push: docblock_comment
# Comments
- match: '#'
scope: punctuation.definition.comment.prql
push: line_comment
# Keywords
- match: '\b(case)\b'
scope: keyword.control.prql
# Numbers
- match: '\b(-)?[0-9._e]+\b'
scope: constant.numeric.prql
# Transforms
- match: '\b(aggregate|derive|filter|from|group|join|select|sort|take|window)\b'
scope: keyword.other.prql
# constants
- match: true|false|null
scope: constant.language.prql
# assignment-expressions:
- match: =
scope: keyword.operator.assignment.inline.prql
# operators:
- match: ==|~=|\\+|-|\\*|!=|->|=>|<=|>=|&&|<|>
scope: keyword.operator.comparison.prql
- match: '[-+%/*]'
scope: keyword.operator.arithmetic.prql
# logical
- match: '&&|\|\|'
scope: keyword.operator.logical.prql
# sequence-separators:
- match: ','
scope: punctuation.separator.sequence.prql
# data types
- match: '\b(bool|int8|int16|int32|int64|int128|int|float|text|set)\b'
scope: storage.type.prql
# time units
- match: years|months|weeks|days|hours|minutes|seconds|milliseconds|microseconds
scope: keyword.other.prql
# module
- match: '\b(module)\s+({{identifier}})\b'
captures:
1: storage.type.module.prql
2: entity.name.module.prql
# variable-declaration:
- match: let
scope: keyword.declaration.prql
# Reserved variable names
- match: this|that
scope: variable.language.prql
# pipe
- match: \||\&
scope: keyword.operator.assignment.pipe.prql
functions:
# Aggregate functions
- match: '\b(any|average|concat_array|count|every|max|min|stddev|sum)\b'
scope: support.function.aggregate.prql
# Date functions
- match: '\b(to_text)\b'
scope: support.function.date.prql
# File reading functions
- match: '\b(read_csv|read_parquet)\b'
scope: support.function.file.prql
# List functions
- match: '\b(all|map|zip|_eq|_is_null)\b'
scope: support.function.list.prql
# Text functions
- match: '\b(contains|ends_with|extract|length|lower|ltrim|replace|rtrim|starts_with|trim|upper)\b'
scope: support.function.text.prql
# Math functions
- match: '\b(abs|acos|asin|atan|ceil|cos|degrees|exp|floor|ln|log|log10|pi|pow|radians|round|sin|sqrt|tan)\b'
scope: support.function.math.prql
# Window functions
- match: '\b(lag|lead|first|last|rank|rank_dense|row_number)\b'
scope: support.function.window.prql
numbers:
# hex
- match: (0x)((?:_?\h)+)
scope: meta.number.integer.hexadecimal.prql
captures:
1: constant.numeric.base.prql
2: constant.numeric.value.prql
# octal
- match: (0o)((?:_?[0-7])+)(\d*)
scope: meta.number.integer.octal.prql
captures:
1: constant.numeric.base.prql
2: constant.numeric.value.prql
3: invalid.illegal.digit.prql
# binary
- match: (0b)((?:_?[01])*)(\d*)
scope: meta.number.integer.binary.prql
captures:
1: constant.numeric.base.prql
2: constant.numeric.value.prql
3: invalid.illegal.digit.prql
double_quoted_string:
- meta_scope: string.quoted.double.prql
- match: '\\.'
scope: constant.character.escape.prql
- match: '"'
scope: punctuation.definition.string.end.prql
pop: true
single_quoted_string:
- meta_scope: string.quoted.single.prql
- match: '\\.'
scope: constant.character.escape.prql
- match: "'"
scope: punctuation.definition.string.end.prql
pop: true
line_comment:
- meta_scope: comment.line.prql
- match: $
pop: true
docblock_comment:
- meta_scope: comment.block.documentation.prql
- match: $
pop: true