-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mercury.YAML-tmLanguage
172 lines (155 loc) · 6.01 KB
/
Mercury.YAML-tmLanguage
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
# [PackageDev] target_format: plist, ext: tmLanguage
# c.f.: http://manual.macromates.com/en/language_grammars
# c.f.: http://www.apeth.com/nonblog/stories/textmatebundle.html
# developed with: https://github.com/SublimeText/AAAPackageDev
---
fileTypes: [m,moo]
name: Mercury
scopeName: source.mercury
uuid: A3E186F8-CF20-4983-B132-209EDF43E3DE
repository:
block_comment:
name: comment.block.source.mercury
begin: /\*
captures:
'0': {name: punctuation.definition.comment.source.mercury}
end: \*/
line_comment:
name: comment.comment.source.mercury
begin: (^[ \t]+)?(%([-]+%)?)
beginCaptures:
'1': {name: punctuation.whitespace.comment.leading.source.mercury}
'2': {name: comment.line.percentage.source.mercury}
end: (?!\G)
patterns:
- match: '(([ \t]+(XXX|TODO|FIXME|WARNING|IMPORTANT|NOTE(_TO_IMPLEMENTORS)?)\b)*)(.*)'
captures:
'0': {name: comment.comment.source.mercury}
'1': {name: constant.language.warn.source.mercury}
string_quoted_double:
name: string.quoted.double.source.mercury
begin: '"'
beginCaptures:
'0': {name: punctuation.literal.string.begin.source.mercury}
end: '"(?!")'
endCaptures:
'0': {name: punctuation.literal.string.end.source.mercury}
patterns:
- match: \\.
name: constant.character.escapesource.mercury
- match: '""'
name: constant.character.escape.quote.source.mercury
- match: '%[I]?[-+# *\.0-9]*[dioxXucsfeEgGp]'
name: constant.character.escape.format.source.mercury
atom:
name: string.quoted.single.source.mercury
begin: ''''
beginCaptures:
'0': {name: punctuation.definition.string.begin.source.mercury}
end: '''(?![''])'
endCaptures:
'0': {name: punctuation.definition.string.end.source.mercury}
patterns:
- match: \\.
name: constant.character.escape.source.mercury
- match: \'\'
name: constant.character.escape.quote.source.mercury
inline_bin_op:
match: '`[^`]+`'
name: keyword.operator.other.source.mercury
decl_keywords:
match: \b(is|where)\b
name: keyword.control.declaration.source.mercury
determ_keywords:
match: (?x)\b(require_(_switch_arms)?)?(multi|cc_(multi|nondet)
|det|semidet|nondet
|errorneous|failure
)\b
name: constant.language.determ.source.mercury
logic_keywords:
match: (?x)\b(yes|no|true|false|(semidet_)?succeed|(semidet_)?fail
|some|all|require_complete_switch
)\b
name: constant.language.logic.source.mercury
purity_level:
match: \b((promise_)(semi)?pure|(im|semi)?pure)\b
name: storage.type.source.mercury
foreign_mods:
match: (?x)\b(affects_liveness|(does_not|doesnt)_affect_liveness
|attach_to_io_state
|can_pass_as_mercury_type|stable
|(may_call|will_not)(_call_mercury|_modify)
|(may_)(not_)?_duplicate
|(no_|unknown_)?sharing|tabled_for_io|local
|(un)?trailed
|(not_|maybe_)?thread_safe
|will_not_throw_exception
)\b
name: storage.type.source.mercury
impl_defined_variable:
match: '[$][a-zA-Z0-9_]*\b'
name: variable.language.source.mercury
singleton_variable:
match: \b_[A-Z]?[a-zA-Z0-9_]*\b
name: support.variable
variable:
match: \b[A-Z][a-zA-Z0-9_]*\b
name: variable.other
variables:
patterns:
- include: '#impl_defined_variable'
- include: '#singleton_variable'
- include: '#variable'
declarations:
patterns:
- match: (?x)(^[ \t]*:-)[ ]((use|include|end|import|)_module|module
|func|pred|type(class)?|inst(ance)?
|mode|interface|implementation
)\b
captures:
'1': {name: keyword.operator.logic.source.mercury}
name: keyword.control.declaration.source.mercury
- match: (?x)(^[ \t]*:-)[ ](pragma)[ ](check_termination|does_not_terminate|fact_table
|inline|loop_check|memo|minimal_model|no_inline
|obsolete|promise_equivalent_clauses|source_file
|terminates|type_spec
|foreign_(proc|type|decl|code|export(_enum)?
|enum|import_module)
)\b
captures:
'1': {name: keyword.operator.logic.source.mercury}
'2': {name: keyword.control.pragma.source.mercury}
name: constant.language.pragma.source.mercury
common_ops:
patterns:
- match: (-(?![>-])|[+](?![+])|[*][*]?|/(?![\\/])|//|\\(?![/=]))
name: keyword.operator.arithmetic.source.mercury
- match: (=<|>=|<(?![=])|(?![-])>)
name: keyword.operator.comparison.source.mercury
- match: (<=>|<=|=>|\\=|==|:-|=(?![=<>])|,|;|->|/\\(?![=])|\\/|@)
name: keyword.operator.logic.source.mercury
- match: (-->|--->|[+][+](?![+])|::|:=|![\.:]?|\||\^)
name: keyword.operator.other.source.mercury
- match: (\(|\)|\[|\]|\{|\})
name: keyword.operator.list.source.mercury
- match: \.(?=[ \t]*($|%))
name: keyword.operator.terminator.source.mercury
number:
match: \b(0(?!['])[0-7]*|0['].|[1-9][0-9]*|\.[0-9]+([eE][0-9]+)?|0[xX][0-9a-fA-F]+|0[bB][01]+)\b
name: constant.numeric.source.mercury
patterns:
- include: '#number' # number must come before single quoted chars, to allow 0'a
- include: '#string_quoted_double'
- include: '#inline_bin_op'
- include: '#atom'
- include: '#block_comment'
- include: '#line_comment'
- include: '#decl_keywords'
- include: '#purity_level'
- include: '#declarations'
# declarations come before common_ops, since declarations relies on :-
- include: '#common_ops'
- include: '#determ_keywords'
- include: '#logic_keywords'
- include: '#foreign_mods'
- include: '#variables'