-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.zap.js
148 lines (146 loc) · 5.93 KB
/
source.zap.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed permissive.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.zap', '.xzap'],
names: ['zap'],
patterns: [
{include: '#whitespace'},
{include: '#comment'},
{include: '#number'},
{include: '#string'},
{include: '#labels'},
{include: '#instruction'},
{include: '#debug_directive'},
{include: '#directive'}
],
repository: {
branch: {
captures: {
1: {name: 'keyword.control.branch.positive.zap'},
2: {name: 'keyword.control.branch.negative.zap'},
3: {name: 'keyword.control.branch.${3:/downcase}.zap'},
4: {name: 'keyword.control.branch.label.name.zap'}
},
match:
'(?x)\n(?: (/) | (\\\\) )\n\\s*\n(?:\n (TRUE | FALSE)\n| ( [A-Za-z?$#&] [A-Za-z0-9\\-?$#&.]* )\n)',
name: 'meta.branch.zap'
},
comment: {
captures: {1: {name: 'punctuation.definition.comment.line.zap'}},
match: '(;).*$',
name: 'comment.line.zap'
},
debug_directive: {
begin: '(?x)\n(?<=\\s|:|^)\n(\\.)(DEBUG-[-A-Z]+)\n(?= \\s | ; | $)',
beginCaptures: {
0: {name: 'keyword.directive.debug.${2:/downcase}.zap'},
1: {name: 'punctuation.directive.debug.zap'}
},
end: '(?=;|$)',
name: 'meta.directive.debug.zap',
patterns: [{include: '#operands'}]
},
directive: {
begin:
'(?x)\n(?<=\\s|:|^)\n(?!\\.DEBUG-)\n(?:\n ((\\.)(FUNCT))\n \\s+\n ([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)\n (?= \\s | [,;] | $)\n|\n ((\\.)([A-Z]+))\n (?= \\s | ; | $)\n)',
beginCaptures: {
1: {name: 'keyword.directive.${3:/downcase}.zap'},
2: {name: 'punctuation.directive.zap'},
4: {name: 'entity.name.function.zap'},
5: {name: 'keyword.directive.${7:/downcase}.zap'},
6: {name: 'punctuation.directive.zap'}
},
end: '(?=;|$)',
name: 'meta.directive.zap',
patterns: [{include: '#operands'}]
},
global_label: {
captures: {
1: {name: 'keyword.control.definition.label.global.name.zap'},
2: {name: 'punctuation.definition.label.global.zap'}
},
match: '([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)(::)',
name: 'meta.label.global.zap'
},
identifier: {
captures: {
1: {name: 'variable.language.stack.zap'},
2: {name: 'variable.zap'}
},
match: '(STACK\\b)|([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)',
name: 'meta.variable.zap'
},
instruction: {
begin:
'(?x)\n\\b\n(?:\n (JUMP)\n \\s+\n ([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)\n (?= \\s* (?: ; | $ ) )\n|\n (\n ADD | ASHIFT | ASSIGNED\\? | BAND | BCOM | BOR | BTST | BUFOUT | CALL | CALL1 | CALL2 |\n CATCH | CHECKU | CLEAR | COLOR | COPYT | CRLF | CURGET | CURSET | DCLEAR | DEC |\n DIRIN | DIROUT | DISPLAY | DIV | DLESS\\? | EQUAL\\? | ERASE | FCLEAR | FIRST\\? | FONT |\n FSET\\?? | FSTACK | GET | GETB | GETP | GETPT | GRTR\\? | HLIGHT | ICALL | ICALL1 |\n ICALL2 | IGRTR\\? | IN\\? | INC | INPUT | INTBL\\? | IRESTORE | ISAVE | IXCALL | JUMP |\n LESS\\? | LEX | LOC | MARGIN | MENU | MOD | MOUSE-INFO | MOUSE-LIMIT | MOVE | MUL |\n NEXT\\? | NEXTP | NOOP | ORIGINAL\\? | PICINF | PICSET | POP | PRINT | PRINTB | PRINTC |\n PRINTD | PRINTF | PRINTI | PRINTN | PRINTR | PRINTT | PRINTU | PTSIZE | PUSH | PUT |\n PUTB | PUTP | QUIT | RANDOM | READ | REMOVE | RESTART | RESTORE | RETURN | RFALSE |\n RSTACK | RTRUE | SAVE | SCREEN | SCROLL | SET | SHIFT | SOUND | SPLIT | SUB | THROW |\n USL | VALUE | VERIFY | WINATTR | WINGET | WINPOS | WINPUT | WINSIZE | XCALL | XPUSH |\n ZERO\\? | XWSTR\n )\n (?= \\s | ; | $)\n)',
beginCaptures: {
1: {name: 'keyword.opcode.zap'},
2: {name: 'keyword.control.branch.label.name.zap'},
3: {name: 'keyword.opcode.zap'}
},
end: '(?=;|$)',
name: 'meta.instruction.zap',
patterns: [
{include: '#opcode'},
{include: '#operands'},
{include: '#store'},
{include: '#branch'}
]
},
labels: {patterns: [{include: '#global_label'}, {include: '#local_label'}]},
local_label: {
captures: {
1: {name: 'keyword.control.definition.label.local.name.zap'},
2: {name: 'punctuation.definition.label.local.zap'}
},
match: '([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)(:)(?!:)',
name: 'meta.label.local.zap'
},
number: {match: '[0-9]+', name: 'constant.numeric.decimal.zap'},
operands: {
patterns: [
{include: '#summation'},
{include: '#number'},
{include: '#identifier'},
{include: '#string'}
]
},
store: {
captures: {
1: {name: 'punctuation.definition.storage.zap'},
2: {name: 'storage.stack.zap'},
3: {name: 'entity.name.variable.zap'}
},
match: '(>)\\s*(?:(STACK)|([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*))',
name: 'meta.store.zap'
},
string: {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.zap'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.zap'}},
name: 'string.quoted.double.zap',
patterns: [{match: '\\\\.', name: 'constant.character.escape.zap'}]
},
summation: {
captures: {
1: {name: 'constant.numeric.decimal.zap'},
2: {name: 'entity.name.variable.zap'},
3: {name: 'keyword.operator.plus.zap'},
4: {name: 'constant.numeric.decimal.zap'},
5: {name: 'entity.name.variable.zap'}
},
match:
'(?:([0-9]+)|([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*))(?:\\s*(\\+)\\s*(?:([0-9]+)|([A-Za-z?$#&][A-Za-z0-9\\-?$#&.]*)))+',
name: 'meta.operand.summation.zap'
},
whitespace: {match: '\\s+'}
},
scopeName: 'source.zap'
}
export default grammar