-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBBCBASIC.sublime-syntax
138 lines (116 loc) · 4.19 KB
/
BBCBASIC.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
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
%YAML 1.2
---
# BBC BASIC syntax colouring mode.
#
# Intended for use with BBC BASIC V/VI files in text format, for RISC OS. Should work
# acceptably well with earlier versions of BBC BASIC and variants from other platforms.
#
# See http://www.sublimetext.com/docs/3/syntax.html
name: BBC BASIC
file_extensions: ['bbc']
scope: source.bbcbasic
contexts:
main:
# The main context is the initial starting point of our syntax.
# Include other contexts from here (or specify them directly).
- include: linenumber
- include: comments
- include: keywords
- include: cli
- include: numbers
- include: variables
- include: strings
linenumber:
- match: "^ *[0-9]+ *"
scope: entity.line-number.bbcbasic
keywords:
- match: "(DEF *(?:PROC|FN)) *([@`A-Za-z_][@`A-Za-z_0-9]*)"
captures:
'1': storage.type.function.bbcbasic
'2': entity.name.function.bbcbasic
- match: "(END *PROC)$"
scope: storage.type.function.bbcbasic
- match: "^="
# Try to identify the '=' termination of the function
scope: storage.type.function.bbcbasic
# Conditional statements
- match: "(IF|THEN|ELSE|ENDIF)"
scope: keyword.control.flow.bbcbasic
# Switch statements
- match: "(CASE|OTHERWISE|WHEN|ENDCASE)"
scope: keyword.control.flow.bbcbasic
# Loop statements
- match: "(FOR|NEXT|REPEAT|UNTIL|WHILE|ENDWHILE)"
scope: keyword.control.flow.bbcbasic
# Legacy control flow
- match: "(RETURN|GOTO|GOSUB)"
scope: keyword.control.flow.bbcbasic
# Exceptional operations
- match: "(ON|END|STOP|QUIT)"
scope: keyword.control.flow.bbcbasic
- match: "(PROC|FN)([`@A-Za-z_][`@A-Za-z_0-9]*)"
captures:
'1': keyword.control.bbcbasic
'2': meta.function-call.bbcbasic
- match: "\
CHR\\$|GET\\$|INKEY\\$|LEFT\\$|MID\\$|RIGHT\\$|STR\\$|STRING\\$|TIME\\$|REPORT\\$|\
ERROR|\
LINE|OFF|STEP|SPC|TAB|\
OPENIN|PAGE|TIME|LOMEM|HIMEM|ABS|\
ACS|ADVAL|ASC|ASN|ATN|BGET#|COS|COUNT|\
DEG|ERL|ERR|EVAL|EXP|EXT#|FALSE|\
GET|INKEY|INSTR|INT|LEN|LN|LOG|NOT|\
OPENUP|OPENOUT|PI|POINT|POS|RAD|RND|\
SGN|SIN|SQR|TAN|TO|TRUE|USR|VAL|VPOS|\
EOF#|PTR#|PAGE|TIME|\
SOUND|BPUT#|CALL|CHAIN|CLEAR|\
CLOSE#|CLG|CLS|DATA|DIM|DRAW|\
ENVELOPE|GCOL|\
INPUT|LET|LOCAL|MODE|MOVE|\
VDU|PLOT|PRINT|PROC|READ|\
REPORT|RESTORE|RUN|COLOUR|\
TRACE|WIDTH|OSCLI|\
OF|\
CIRCLE|FILL|ORIGIN|POINT|RECTANGLE|SWAP|\
WAIT|MOUSE|SYS|INSTALL|\
LIBRARY|TINT|ELLIPSE|BEATS|TEMPO|VOICES|\
VOICE|STEREO|OVERLAY|APPEND|AUTO|CRUNCH|\
DELETE|EDIT|HELP|LIST|LOAD|LVAR|NEW|\
OLD|RENUMBER|SAVE|TEXTLOAD|TEXTSAVE|\
TWINO|TWIN|INSTALL|SUM|BEAT|\
AND|DIV|EOR|MOD|OR"
scope: keyword.control.bbcbasic
numbers:
- match: '[+-]?[0-9]+(\.[0-9]+)?(E[\-+]?[0-9]+)'
scope: constant.numeric.bbcbasic
- match: '(-)?[0-9.]+|(&[0-9a-fA-F]{1,8})|%([01]+)'
scope: constant.numeric.bbcbasic
variables:
- match: '[`A-Za-z_][`A-Za-z0-9_]*%'
scope: variable.integer.bbcbasic
- match: '[`A-Za-z_][`A-Za-z0-9_]*\$'
scope: variable.string.bbcbasic
- match: '[`A-Za-z_][`A-Za-z0-9_]*'
scope: variable.float.bbcbasic
strings:
# Strings begin and end with quotes.
- match: '(".*?")'
scope: string.quoted.double.bbcbasic
comments:
# Comments begin with a 'REM' and finish at the end of the line.
- match: 'REM'
scope: punctuation.definition.comment.bbcbasic
push:
# This is an anonymous context push for brevity.
- meta_scope: comment.line.rem.bbcbasic
- match: $\n?
pop: true
# CLI commands that start with a | are effectively a comment
# (Note: This does not cope with comments following a line number prefix)
- match: '^ *\*\|.*'
scope: comment.line.rem.bbcbasic
cli:
# CLI commands are harder to recognise without a stateful process here, but we try
# to recognise what we can with the 'preprocessor' type of statement
- match: '^( *|.*: *|.*THEN *|.*ELSE *)\*.*'
scope: meta.directive.bbcbasic keyword.other.preprocessor.include.c