-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhare.sublime-syntax
More file actions
123 lines (110 loc) · 3.89 KB
/
Copy pathhare.sublime-syntax
File metadata and controls
123 lines (110 loc) · 3.89 KB
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
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: Hare
file_extensions: [ha]
scope: source.hare
contexts:
main:
- include: keywords
- include: strings
- include: strings_2
- include: char_lit
- include: line_comment
- include: misc_ops
- include: core_types
- include: boolean
- include: float_lit
- include: int_dec_lit
- include: int_bin_lit
- include: int_oct_lit
- include: int_hex_lit
# Comparison operator:
- match: (&&|\|\||==|!=)
scope: keyword.operator.comparison.hare
# Assignment operator:
- match: (\+=|-=|/=|\*=|%=|\^=|&=|\|=|<<=|>>=|=)
scope: keyword.operator.assignment.hare
# Arithmetic operator:
- match: (!|\+|-|/|\*|%|\^|&|\||<<|>>)
scope: keyword.operator.arithmetic.hare
# Comparison operator (second group because of regex precedence):
- match: (<=|>=|<|>)
scope: keyword.operator.comparison.hare
# Preprocessor Directive:
- match: '(@[a-z]+)'
scope: keyword.attribute.hare
# Conversion Operators:
- match: \b(is|as)\b
scope: keyword.operator.conversion.hare
# Boolean constant
boolean:
- match: \b(true|false)\b
scope: constant.language.boolean.hare
# Single-quote string literal (character)
char_lit:
- match: '''([^''\\]|\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))'''
scope: string.quoted.single.hare
# Built-in/core type
core_types:
- match: \b(str|rune|char|bool|int|uint|uintptr|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64|opaque|null|void|nullable|valist)\b
scope: support.type.primitive.hare
# Integer literal (decimal)
int_dec_lit:
- match: '\b[0-9]+((e|E)[0-9]+)?(z|(u|i)(8|16|32|64)?)?\b'
scope: constant.numeric.integer.decimal.hare
# Integer literal (binary)
int_bin_lit:
- match: '\b0b[0-1]+(z|(u|i)(8|16|32|64)?)?\b'
scope: constant.numeric.integer.binary.hare
# Integer literal (octal)
int_oct_lit:
- match: '\b0o[0-7]+(z|(u|i)(8|16|32|64)?)?\b'
scope: constant.numeric.integer.octal.hare
# Integer literal (hex)
int_hex_lit:
- match: '\b0x[0-9A-Fa-f]+(z|(u|i)(8|16|32|64)?)?\b'
scope: constant.numeric.integer.hex.hare
# Floating point literal
float_lit:
- match: '\b[0-9]+\.[0-9]+((e|E)(\+|-)?[0-9]+)?(f(32|64))?\b'
scope: constant.numeric.floating.hare
- match: '\b[0-9]+((e|E)(\+|-)?[0-9]+)?f(32|64)\b'
scope: constant.numeric.floating.hare
keywords:
- match: \b(abort|align|alloc|append|assert|break|case|const|continue|def|defer|delete|done|else|enum|export|fn|for|free|if|insert|len|let|match|offset|return|size|static|struct|switch|type|union|vaarg|vaend|vastart|yield|use)\b
scope: keyword.control.hare
line_comment:
- match: //
push:
- meta_scope: comment.line.double-slash.hare
- match: $
pop: true
# Miscellaneous operators
misc_ops:
- match: (=>|::|:|\?|!|\||\.\.\.|\.\.|&\.\.)
scope: keyword.operator.misc.hare
# Strings
# see: haredoc fmt, fmt/iter.ha
strings:
- match: '"'
push:
- meta_scope: string.quoted.double.hare
- match: '"'
pop: true
- match: \\(0|a|b|f|n|r|t|v|\\|\'|\"|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})
scope: constant.character.escape.hare
- match: '\{\{|\}\}'
scope: constant.character.format.hare
- match: '{([0-9]*(:([0\-\+\=\_\ ]*(\.)?[0-9]*(x|X|o|b)?(\.[0-9]*)?(e|f|g)?(F(s|\.|U|E|S|2))*))?|[0-9]*%[0-9]*)}'
scope: constant.character.format.hare
strings_2:
- match: '`'
push:
- meta_scope: string.quoted.double.hare
- match: '`'
pop: true
- match: '\{\{|\}\}'
scope: constant.character.format.hare
- match: '{([0-9]*(:([0\-\+\=\_\ ]*(\.)?[0-9]*(x|X|o|b)?(\.[0-9]*)?(e|f|g)?(F(s|\.|U|E|S|2))*))?|[0-9]*%[0-9]*)}'
scope: constant.character.format.hare