Repository navigation
Expand file tree
/
Copy pathMSX Basic.sublime-syntax
More file actions
executable file
·156 lines (133 loc) · 5.29 KB
/
Copy pathMSX Basic.sublime-syntax
File metadata and controls
executable file
·156 lines (133 loc) · 5.29 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
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
#
# See https://github.com/farique1/MSX-Sublime-Tools
# for updates and other MSX Sublime tools
#
# v1.3.1
# Fixed " inside DATA.
author: Fred Rique (farique)
url: https://github.com/farique1/MSX-Sublime-Tools
comment: v1.3.1
name: MSX Basic
file_extensions: [bas, asc, mlt]
scope: source.msxbasic
# All case insensitive
contexts:
main:
# Token List specific
- match: '((^[0-9a-fA-F]{4})(:)([0-9a-fA-F ]+ {8})|^)(start|end|lines|size|)'
captures:
2: support.function.msxbasic
3: constant.global.msxbasic
4: constant.numeric.msxbasic
5: variable.parameter.msxbasic
# Double quotes
- match: '"'
push: double_quoted_string
# Comment line ' ## REM
- match: (?i:'|rem)
push: comment_line
# DATA line highlights elements and comma only
- match: '(?i:data)'
push: data_line
scope: keyword.control.msxbasic
# Round brackets balancing warning (only highlights missing closed)
- match: \(
push: brackets
- match: \)
scope: invalid.msxbasic
# Special cases for on xxx goto/gosub (there are more?)
- match: '(?i:error|interval|key|sprite|stop|strig)\s*(?=(?i:goto|gosub))'
scope: support.function.msxbasic
# Functions with precedence over Instructions
- match: (?i:asc)
scope: support.function.msxbasic
#def fn
- match: (?i:(fn)\s*(\w+)(\$|\%|\!|\#)?(?=\())
captures:
1: support.function.msxbasic
2: support.function.msxbasic
3: keyword.operator.msxbasic
# Instructions (several are position and context sensitive)
# review: base key play strig stick pdl pad time date set...
# catching 'key' if after ^ or : unless folowed by (
- match: (?i:\?|as(?=\s*#|\s*\w+\$)|auto|as|beep|bload|bsave|circle|clear|cload|close|cls|cmd|color|cont|copy|copy|csave|csrlin|data|(def)(dbl|(?=\s?fn)|int|sng|str|\s?usr)|delete|dim|draw|dsko\$|else|end|erase|error|field|files|for|get|gosub|goto|if|input|interval|ipl|kanji|(?<=:|^|\d)\s*key(?!\()|kill|let|line|list|llist|load|locate|lprint|lset|maxfiles|merge|motor|name|new|next|off|on|open|out|output|paint|play(?!(\()| +\()|point|poke|preset|print|pset|put|read|renum|restore|resume|return|rset|run|run|save|screen|(set)(\sadjust|\sbeep|\spage|\spassword|\sprompt|\sscreen|\sscroll|\stitle|\svideo|\b)|sound|sprite\$|sprite|step|stop|swap|then|to|troff|tron|using|vpoke|wait|width)
scope: keyword.msxbasic
# Functions (several are position and context sensitive)
# review: base key play strig stick pdl pad time date set...
- match: (?i:abs|asc|atn|attr\$|base|bin\$|cdbl|cdbl|chr\$|cint|cint|cos|csng|csng|cvd|cvi|cvs|date|dskf|eof|erl|err|exp|fix|fn|fpos|fre|hex\$|inkey\$|inp|input\$|instr|int|key|left\$|len|loc|lof|log|lpos|mid\$|mkd\$|mki\$|mks\$|oct\$|pad|pdl|peek|play(?=(\(|\s+\())|pos|right\$|rnd|sgn|sin|space\$|spc|sqr|stick|str\$|strig|string\$|tab|tan|time|usr|val|varptr|varptr|vdp|vpeek)
scope: support.function.msxbasic
# Call and _ get any 15 char string.
- match: (call\s+|_\s*)(\w{,15})
captures:
1: keyword.msxbasic
2: support.function.msxbasic
# colon - instruction separator
- match: ':'
scope: comment.msxbasic
# Separators
- match: '[.,;]'
scope: keyword.operator.msxbasic
# Operators
- match: (?i:\+|-|\*|/|\^|\\|=|<|>|and|or|not|xor|eqv|imp|mod)
scope: keyword.operator.msxbasic
# Numbers
- match: '(#?)([1-9]+[0-9]*|0)(\.?)([ed][+-])?([%!#]?)'
captures:
1: keyword.operator.msxbasic
2: constant.numeric.msxbasic
3: keyword.operator.msxbasic
4: keyword.operator.msxbasic
5: keyword.operator.msxbasic
# Variables
- match: '(#?)([A-Za-z]\d*)([%!#\$]?)'
captures:
1: keyword.operator.msxbasic
2: constant.global.msxbasic
3: keyword.operator.msxbasic
# Hex and binary numbers (bug if word after hex touching and beggining with a-f)
- match: '(&[hH])([0-9a-fA-F]+|)|(&[bB])([01]+|)|(&[oO])([1-7]+|)'
captures:
1: keyword.operator.msxbasic
2: constant.numeric.msxbasic
3: keyword.operator.msxbasic
4: constant.numeric.msxbasic
5: keyword.operator.msxbasic
6: constant.numeric.msxbasic
# Quotes: show join line character _
double_quoted_string:
- meta_scope: string.msxbasic
- match: '"|$'
pop: true
# Comments: include labels and continues next line if ending wit : or _
# (does not continue if next line begins with numbers)
comment_line:
- meta_scope: comment.msxbasic
- match: '{\d+?}'
scope: comment.msxbasic
- match: '{(\w+?|@)}'
scope: entity.name.class.msxbasic
- match: '$\n'
pop: true
# DATA: show join lines character _ and continue next line with _ (stops if :)
# Bug > ## comment stops the highlight. can be avoided adding _ at the end
data_line:
- meta_scope: constant.global.msxbasic
- match: ','
scope: variable.parameter.msxbasic
- match: '"'
push:
- match: ':'
scope: constant.global.msxbasic
- match: '("|(?=\n))'
pop: true
- match: '($\n|:)'
scope: comment.msxbasic
pop: true
# Round brackets
brackets:
- match: \)
pop: true
- include: main