-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPerl6.sublime-syntax
216 lines (195 loc) · 6.96 KB
/
Perl6.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions: [p6, pm6, pod6]
scope: source.perl6
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
prototype:
- include: in_line_comments
- include: line_comments
- include: doc_comments
main:
# The main context is the initial starting point of our syntax.
# Include other contexts from here (or specify them directly).
- include: regex
- include: keywords
- include: numbers
- include: double_quote_strings
- include: single_qoute_strings
- include: built_in_consts
- include: vars
- include: storage_types
- include: built_in_subs
keywords:
# Keywords are if, else for and while.
# Note that blackslashes don't need to be escaped within single quoted
# strings in YAML. When using single quoted strings, only single quotes
# need to be escaped: this is done by using two single quotes next to each
# other.
- match: '\b(if|elsif|else|unless|with|for|given|when|default|loop|my|while|return|returns|repeat|until|orwith|without|use|is|has|try|gather|start|react|supply|tap|emit|does|self|fail)\b'
scope: keyword.control.perl6
built_in_subs:
# 5/18/18: needs to be expanded upon quite a bit...
- match: '\b(say|print|uc|chars|flip|numerator|denominator|nude|is-prime|WHAT|slurp|warn|IO|lines|mkdir|rmdir|e|map|reverse|exit|sort|unique|kv|keys|values|open|get|push|prompt|run|shell|spurt|dir|die|defined|last|do)\b'
scope: support.function.perl6
vars:
- match: '(\$|@|%)\S+?.\b'
captures:
1: punctuation.definition.variable
scope: variable.other.perl6
regex:
- match: '(m|rx|)\/'
scope: string.regexp.begin.perl6
push:
- meta_scope: string.regexp.perl6
- match: '/'
scope: string.regexp.end.perl6
pop: true
numbers:
- match: '\b(\-)?[0-9]*\.?[0-9]+\b'
scope: constant.numeric.perl6
- match: '\b0x[0-9a-fA-F_]+\b'
scope: constant.numeric.perl6
- match: '\b0b[0-1_]+\b'
scope: constant.numeric.perl6
- match: '\b0o[0-7_]+\b'
scope: constant.numeric.perl6
built_in_consts:
- match: '\b(True|False|Nil)\b'
scope: constant.language.perl6
storage_types:
- match: '\b(Mu|Any|Cool|Str|Int|Rat|Bool|Sub|u?int8|u?int16|u?int32|u?int64|byte|num32|num64|token|regex|rule)\b'
scope: storage.type.perl6
- match: '\b(sub|multi|submethod|method)\b ([A-Za-z0-9_-]+)'
scope: storage.type.perl6
captures:
1: meta.function.perl6
2: entity.name.function.perl6
- match: '\b(class)\b ([A-Za-z0-9-_:]+)'
scope: storage.type.perl6
captures:
1: meta.class.perl6
2: entity.name.class.perl6
- match: '\b(grammar)\b ([A-Za-z0-9_-]+)'
scope: storage.type.perl6
captures:
1: meta.grammar.perl6
2: entity.name.grammar.perl6
char_escapes:
- match: '\\.'
scope: constant.character.escape.perl6
double_quote_strings:
# interpolated strings begin and end with double quotes, and use backslashes as an escape
# character.
- match: '"'
scope: punctuation.definition.string.begin.perl6
push: inside_double_quote_string
inside_double_quote_string:
- meta_include_prototype: false
- meta_scope: string.quoted.double.perl6
- include: char_escapes
- match: '"'
scope: punctuation.definition.string.end.perl6
pop: true
single_qoute_strings:
# literal strings begin and end with single quotes, no escapes
- match: ''''
scope: punctuation.definition.string.begin.perl6
push:
- meta_include_prototype: false
- meta_scope: string.quoted.single.perl6
- match: ''''
scope: punctuation.definition.string.end.perl6
pop: true
line_comments:
# line_comments begin with a '#' and finish at the end of the line.
- match: '#'
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_scope: comment.line.number-sign.perl6
- match: $\n?
pop: true
doc_comments:
# doc_comments begin with a '=begin <tagname>\n' and end with a
# '=end <tagname>\n' string
- match: '^=begin \S+\n'
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- meta_scope: comment.block.documentation.perl6
- match: '^=end \S+\n'
pop: true
in_line_comments:
- match: '#`\('
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- meta_scope: comment.block.perl6
- include: matching_parentheses
- match: '\)'
pop: true
- match: '#`\['
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- meta_scope: comment.block.perl6
- include: matching_square_brackets
- match: '\]'
pop: true
- match: '#`\{'
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- meta_scope: comment.block.perl6
- include: matching_curly_brackets
- match: '\}'
pop: true
- match: '#`\<'
scope: punctuation.definition.comment.perl6
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- meta_scope: comment.block.perl6
- include: matching_angle_brackets
- match: '\>'
pop: true
#These contexts are pretty much exclusively for nested brackets in comments
matching_parentheses:
- match: '\('
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- include: matching_parentheses
- match: '\)'
pop: true
matching_square_brackets:
- match: '\['
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- include: matching_square_brackets
- match: '\]'
pop: true
matching_curly_brackets:
- match: '\{'
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- include: matching_curly_brackets
- match: '\}'
pop: true
matching_angle_brackets:
- match: '\<'
push:
# This is an anonymous context push for brevity.
- meta_include_prototype: false
- include: matching_angle_brackets
- match: '\>'
pop: true