-
Notifications
You must be signed in to change notification settings - Fork 1
/
z80_rgbds.sublime-syntax
77 lines (72 loc) · 2.58 KB
/
z80_rgbds.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
%YAML 1.2
---
name: Z80 Assembly (RGBDS)
file_extensions: [asm, s, inc]
scope: source.rgbds
variables:
# macros, labels, constants etc: can't start w/ number, alphanum + underscore
namingrule: '[a-zA-Z_][a-zA-Z_0-9\\@]*'
contexts:
main:
# stuff for the CPU
- match: ^\s*(ld|ldi|ldd|ldh|push|pop|add|adc|sub|sbc|and|or|xor|cp|inc|dec|daa|cpl|rlca|rla|rrca|rra|rlc|rl|rrc|rr|sla|swap|sra|srl|bit|res|set|ccf|scf|nop|halt|stop|di|ei|jp|jr|call|ret|reti|rst)
scope: keyword.rgbds
- match: (af|bc|de|hl|sp|a|b|c|d|e|h)[\s,]
scope: source.rgbds
captures:
1: variable.language.registers.rgbds
# stuff for the assembler
- match: (MACRO|ENDM|IF|ENDC|REPT|ENDR|DB|DW|DS|INCLUDE|INCBIN|SECTION|EQU|FAIL|PUSHO|OPT|WARN|SET|POPO)
scope: support.function.rgbds
- match: ^\s*(\.?{{namingrule}})\s*(\:)\s*$
scope: meta.label.rgbds
captures: # FIXME: using class and operator for colours, not semantically correct
1: support.class.label.name.rgbds
2: keyword.operator.label.colon.rgbds
- match: ^\s*{{namingrule}}
scope: entity.name.tag.rgbds # function
- match: \b{{namingrule}}
scope: entity.name.function.rgbds # FIXME: this is actualyl an identifier, using function to get the colour I want :D
# misc stuff, some of these might be unnecessary
- match: '"'
scope: punctuation.definition.string.begin.rgbds
push: double_quoted_string
- match: ''''
scope: punctuation.definition.string.begin.rgbds
push: quoted_string
- match: ;
scope: punctuation.definition.comment.rgbds
push: line_comment
- match: '!|&|\*|\-|\+|~|/|\^'
scope: keyword.operator.rgbds
- match: \{|\}
scope: meta.brace.curly.rgbds
- match: \(|\)
scope: meta.brace.round.rgbds
- match: \[|\]
scope: meta.brace.square.rgbds
# numbers
- match: '[0-9]'
scope: constant.numeric.integer.decimal.rgbds
- match: \$[0-9a-fA-F]+
scope: constant.numeric.integer.hexadecimal.rgbds
- match: '\%[01]+'
scope: constant.numeric.integer.binary.rgbds
double_quoted_string:
- meta_scope: string.quoted.double.rgbds
- match: \\.
scope: constant.character.escape.rgbds
- match: '"'
scope: punctuation.definition.string.end.rgbds
pop: true
quoted_string:
- meta_scope: string.quoted.double.rgbds
- match: \\.
scope: constant.character.escape.rgbds
- match: ''''
scope: punctuation.definition.string.end.rgbds
pop: true
line_comment:
- meta_scope: comment.line.rgbds
- match: $
pop: true