-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchip8.sublime-syntax
More file actions
69 lines (60 loc) · 2.09 KB
/
chip8.sublime-syntax
File metadata and controls
69 lines (60 loc) · 2.09 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
%YAML 1.2
---
# Sublime Text Syntax for Chip8 Assembly
# See http://www.sublimetext.com/docs/syntax.html
name: Chip8
file_extensions:
- asm
- chip8
scope: source.chip8
contexts:
main:
# Strings begin and end with quotes, and use backslashes as an escape
# character
- match: '"'
scope: punctuation.definition.string.begin.chip8
push: double_quoted_string
# Comments begin with a ';' and finish at the end of the line
- match: ';'
scope: punctuation.definition.comment.chip8
push: line_comment
# 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(ADD|AND|CALL|CLS|DRW|DRAW|LD|JP|OR|SHL|SHR|SE|SNE|SKP|SKNP|SUB|SUBN|SYS|RAND|RET|XOR)\b'
scope: keyword.chip8
- match: '\b(add|and|call|cls|drw|draw|ld|jp|or|shl|shr|se|sne|skp|sknp|sub|subn|sys|rand|ret|xor)\b'
scope: keyword.chip8
# Registers
- match: '\b(F|BCD|DT|I|K|ST)\b'
scope: entity.name.chip8
- match: '\b[vV][0-9a-fA-F]{1,2}\b' # V0-VF
scope: variable.language.chip8
# Numbers
- match: '\b(-)?[0-9.]+\b' # decimal
scope: constant.numeric.chip8
- match: '\b(-)?0x[a-fA-F0-9.]+\b' # hexadecimal
scope: constant.numeric.chip8
- match: '\b(-)?0b[0-1.]+\b' # binary
scope: constant.numeric.chip8
# Label Def
# Must be the first thing on the line.
# Can have an arbitrary number of spaces before and after the period.
- match: '^\s*\.\s*[\w_]+\b'
scope: entity.name.function
# Label Access
- match: '\.\s*[\w_]+\b'
scope: variable.function.chip8
double_quoted_string:
- meta_scope: string.quoted.double.chip8
- match: '\\.'
scope: constant.character.escape.chip8
- match: '"'
scope: punctuation.definition.string.end.chip8
pop: true
line_comment:
- meta_scope: comment.line.chip8
- match: $
pop: true