This repository was archived by the owner on Nov 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExapunks.sublime-syntax
More file actions
170 lines (160 loc) · 5.38 KB
/
Exapunks.sublime-syntax
File metadata and controls
170 lines (160 loc) · 5.38 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
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
%YAML 1.2
---
name: EXAPUNKS
file_extensions:
- exa
- exapunks
scope: source.exapunks
first_line_match: '^(?i:NOTE\sEXAPUNKS)\b'
contexts:
prototype:
- match: ';'
scope: punctuation.definition.comment.exapunks
push:
- meta_scope: comment.line.semicolon.exapunks
- match: $\n?
pop: true
main:
- include: instructions
- include: macro
# invalid @END or substitution macro outside of repeat block
- match: '@END|@{|{|,|}'
scope: invalid.illegal.exapunks
instructions:
# comment
- match: \b(?i:NOTE)\b
push:
- meta_scope: comment.line.note.exapunks
- match: $\n?
pop: true
# manipulating values
- match: '\b(?i:COPY|ADDI|SUBI|MULI|DIVI|MODI|SWIZ|RAND)\b'
scope: meta.function-call.exapunks support.function.arithmetic.exapunks
push: function-arguments
# lifecycle
- match: '\b(?i:REPL)'
scope: meta.function-call.exapunks support.function.lifecycle.exapunks
push:
- meta_content_scope: meta.label-name.exapunks
# label names when referenced
- match: \w+
scope: variable.label.exapunks
- include: number-substitution
- match: $\n?
scope: meta.label-name.exapunks
pop: true
- match: '\b(?i:HALT|KILL)\b'
scope: meta.function-call.exapunks support.function.lifecycle.exapunks
# movement
- match: '\b(?i:LINK|HOST)\b'
scope: meta.function-call.exapunks support.function.movement.exapunks
push: function-arguments
# communication
- match: '\b(?i:MODE|VOID(?=\sM))\b'
scope: meta.function-call.exapunks support.function.communication.exapunks
push: function-arguments
# file manipulation
- match: '\b(?i:MAKE|GRAB|FILE|SEEK|DROP|WIPE|VOID(?=\sF))\b'
scope: meta.function-call.exapunks support.function.file-manipulation.exapunks
push: function-arguments
# testing values
- match: '\b(?i:TEST)\b'
scope: meta.function-call.exapunks support.function.test.exapunks
push: test-arguments
# label definition
- match: '\b(?i:MARK)\b'
scope: keyword.declaration.label.exapunks
push:
- meta_content_scope: meta.label-name.exapunks
# label names when defined
- match: \w+
scope: entity.name.label.exapunks
- include: number-substitution
- match: $\n?
scope: meta.label-name.exapunks
pop: true
# branching
- match: '\b(?i:JUMP|TJMP|FJMP)\b'
scope: keyword.control.flow.goto.exapunks
push:
- meta_content_scope: meta.label-name.exapunks
# label names when referenced
- match: \w+
scope: variable.label.exapunks
- include: number-substitution
- match: $\n?
scope: meta.label-name.exapunks
pop: true
# miscellaneous
- match: '\b(?i:NOOP|VOID)\b'
scope: meta.function-call.exapunks support.function.exapunks
push: function-arguments
macro:
# macro instruction: repeat block
- match: '(?i:@REP)\b'
scope: keyword.control.directive.exapunks
push:
- meta_scope: meta.macro.repeat.exapunks
- include: numbers
- match: $\n?
set:
- meta_content_scope: meta.macro.repeat.exapunks
- include: instructions
- match: '(?i:@END)\b'
scope: meta.macro.repeat.exapunks keyword.control.directive.exapunks
pop: true
function-arguments:
- meta_content_scope: meta.function-call.arguments.exapunks
- include: variables
- include: numbers
- match: $\n?
scope: meta.function-call.arguments.exapunks
pop: true
test-arguments:
- meta_content_scope: meta.function-call.arguments.exapunks
- include: variables
- include: numbers
- include: operators
# special parameters for the test instruction
- match: '\b(?i:MRD|EOF)\b'
scope: support.constant.exapunks
- match: $\n?
scope: meta.function-call.arguments.exapunks
pop: true
variables:
# registers
- match: '\b(?i:[XTFM])\b'
scope: variable.language.register.exapunks
# predefined hardware registers
- match: '#(?i:ADDR|AUTH|AZIM|CASH|CLRS|CONT|COOL|COPY|CTRL|DATA|DATE|DIAL|DISP|ELEV|EN3D|FILE|FIRE|FREQ|HEAT|INVS|LOCK|MOTR|NERV|NEXT|NSE0|NUKE|PADX|PADY|PADB|PAGE|PASS|POWR|RATE|SAFE|SQR0|SQR1|TEMP|TIME|TRAK|TRI0|ZGC0|ZGC1|ZGC2|ZGC3|ZGC4)\b'
scope: variable.language.hardware-register.exapunks
# user defined hardware registers
- match: '#\w{4}\b'
scope: variable.other.hardware-register.exapunks
- include: number-substitution
numbers:
# numbers
- match: '-?\b\d{1,4}\b'
scope: constant.numeric.integer.exapunks
# invalid numbers
- match: '-?\b\d{5,}\b'
scope: invalid.illegal.outsized-number.exapunks
number-substitution:
# macro instruction: number substitution @{N,M}
- match: '(@)({)'
captures:
1: keyword.control.directive.exapunks
2: punctuation.section.braces.begin.exapunks
push:
- meta_scope: meta.macro.substitution.exapunks
- match: ','
scope: punctuation.separator.exapunks
- match: '}'
scope: punctuation.section.braces.end.exapunks
pop: true
- include: numbers
- match: $\n?
pop: true
operators:
- match: '=|<|>'
scope: keyword.operator.comparison.exapunks