Telehack BASIC (TeleBASIC) — VS Code Syntax Highlighting
Made by GunpointG
Updated August 22, 2025
Syntax highlighting for Telehack’s BASIC dialect (aka TeleBASIC).
Covers line-numbered BASIC, REM / ' comments, strings, numbers, TeleBASIC keywords, predefined constants and functions, $/%-suffixed variables, file-descriptor numbers after #, and operators.
Features
- Line numbers at BOL (e.g.,
10, 200)
- Comments:
REM ... and ' ...
- Strings: double-quoted, with
"" escape
- Keywords:
IF/THEN, FOR/NEXT, GOTO/GOSUB/RETURN, OPEN $s, AS #n, PRINT, PUT, READ, LET, END, SYSTEM, TH_EXEC, etc.
- Predefined constants (e.g.,
ARGC%, ARGV$, TIME$, TIMER, TH_*)
- Predefined functions (e.g.,
ASC, CHR$, INT, LEN, MID$, LEFT$, RIGHT$, RND, TAB$, TH_SPRINTF$, …)
- Variables:
- String vars:
name$
- Integer vars:
count%, count
- File descriptor numbers (e.g.,
PRINT #1, ..., INPUT# 2, ...)
- Operators:
+ - * / = <> <= >= < >
- DEF FN definition highlighting**:**
DEF FNname (no-space) → function name tokenized
DEF FN name (spaced) → DEF FN as keywords, name as function
The grammar is case-insensitive where appropriate.
Example
10 REM Demo of TeleBASIC syntax
20 ' A comment style
30 A% = 42 : A$ = "hello ""world"""
40 IF A% > 10 THEN PRINT "A is greater than 10"
50 PRINT "User: " + USER$ + " Time: " + TIME$
60 OPEN "DATA.DAT" AS #1
70 PRINT #1, "Record", A$
80 CLOSE #1
90 DEF FN concat$(X$, Y$) = X$ + Y$
100 PRINT concat$("foo", "bar")
110 PRINT "Arg count=" + STR$(ARGC%)
120 END
File Types
Associated by default with:
Scopes & Theming Notes
The grammar uses canonical TextMate scopes so themes can colorize predictably:
- Keywords:
keyword.control.telebasic
- Operators:
keyword.operator.telebasic
- Strings:
string.quoted.double.telebasic (+ constant.character.escape.telebasic)
- Numbers:
constant.numeric.telebasic
- Comments:
REM ... → comment.line.rem.telebasic
' ... → comment.line.apostrophe.telebasic
- Variables:
name$ → variable.other.string.telebasic
count% → variable.other.integer.telebasic
count → variable.other.telebasic
#1 (after #) → variable.other.file-descriptor.telebasic
- Predefined constants:
constant.language.telebasic
- Predefined functions:
support.function.telebasic
Language Configuration
- Line comments:
', REM
- Auto-closing pairs:
"...", (...), [...]
TeleBASIC Dialect Notes
- Single-line
IF THEN (classic BASIC style). Use : to chain, or GOTO/GOSUB for multi-line logic.
- Strings are single-line; use concatenation or
DATA/READ for longer text.
DEF FN supports both DEF FNname (no space) and DEF FN name (spaced) patterns in this grammar.
Known Limitations
- No multi-line comment syntax (TeleBASIC doesn’t define one).
Please reach out to auteur_wand.2u@icloud.com regarding any bugs, issues, or additions needed.
| |