Last active
May 7, 2026 08:43
-
-
Save damieng/55d0d80ae4b169d53a36f1bfa05f9834 to your computer and use it in GitHub Desktop.
Generic BASIC syntax support for Shiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default { | |
| name: "basic", | |
| scopeName: "source.basic", | |
| aliases: ["sinclair-basic", "bbc-basic", "zx-basic"], | |
| extensions: [".bas", ".bbc"], | |
| patterns: [ | |
| { include: "#line-number" }, | |
| { include: "#comment" }, | |
| { include: "#string" }, | |
| { include: "#sigil-builtin" }, | |
| { include: "#keyword" }, | |
| { include: "#operator" }, | |
| { include: "#hex-number" }, | |
| { include: "#number" }, | |
| { include: "#builtin" }, | |
| ], | |
| repository: { | |
| "line-number": { | |
| name: "constant.numeric.line-number.basic", | |
| match: "^(?:\\s*)(?:\\d+)(?=\\s|$)", | |
| }, | |
| comment: { | |
| patterns: [ | |
| { | |
| name: "comment.line.rem.basic", | |
| match: "(?:^|:)\\s*(?i:REM)\\b.*$", | |
| }, | |
| { | |
| name: "comment.line.apostrophe.basic", | |
| match: "'[^\\n]*$", | |
| }, | |
| ], | |
| }, | |
| string: { | |
| name: "string.quoted.double.basic", | |
| begin: '"', | |
| end: '"|$', | |
| patterns: [ | |
| { | |
| name: "constant.character.escape.basic", | |
| match: '""', | |
| }, | |
| ], | |
| }, | |
| "sigil-builtin": { | |
| name: "keyword.control.basic", | |
| match: | |
| "(?<![A-Za-z0-9_])(?i:CHR|GET|INKEY|INPUT|KEY|LEFT|MID|RIGHT|SCREEN|STR|TIME|VAL)\\$(?![A-Za-z0-9_])", | |
| }, | |
| keyword: { | |
| name: "keyword.control.basic", | |
| match: | |
| "(?<![A-Za-z0-9_])(?i:AND|AS|AUTO|BEEP|BIN|BGET#|BLOAD|BPUT#|BORDER|BRIGHT|BY|CALL|CASE|CHAIN|CIRCLE|CLEAR|CLOSE#|CLS|COLOUR|COLOR|CONT|CONTINUE|COPY|DATA|DEF|DEF\\s+FN|DEFPROC|DEFFN|DELETE|DIM|DRAW|ELSE|END|ENDCASE|ENDIF|ENDPROC|ENDWHILE|ENVELOPE|ERASE|ERROR|EVERY|FALSE|FLASH|FN|FOR|FORMAT|GCOL|GOSUB|GO\\s+SUB|GOTO|GO\\s+TO|IF|INK|INKEY|INKEY\\$|INPUT|INPUT\\$|INVERSE|LET|LINE|LIST|LLIST|LOAD|LOCAL|LOMEM|HIMEM|MERGE|MODE|MOVE|NEW|NEXT|NOT|OF|OFF|ON|OPEN#|OPENIN|OPENOUT|OPENUP|OR|OSCLI|OTHERWISE|OUT|OVER|PAPER|PAUSE|PLOT|POKE|PRINT|PROC|PTR#|RANDOMIZE|READ|REM|RENUMBER|REPEAT|REPORT|RESTORE|RETURN|RUN|SAVE|SOUND|STEP|STOP|TAB|THEN|TO|TRACE|TRUE|UNTIL|USR|VAL|VAL\\$|VDU|VERIFY|WAIT|WHEN|WHILE|WIDTH)(?![A-Za-z0-9_])", | |
| }, | |
| operator: { | |
| name: "keyword.operator.basic", | |
| match: "[+\\-*/^=<>\\\\]+|\\b(?i:MOD|DIV|AND|OR|NOT)\\b", | |
| }, | |
| "hex-number": { | |
| name: "constant.numeric.hex.basic", | |
| match: "&[0-9A-Fa-f]+|\\b0[xX][0-9A-Fa-f]+\\b", | |
| }, | |
| number: { | |
| name: "constant.numeric.decimal.basic", | |
| match: "\\b\\d+(?:\\.\\d+)?(?:[eE][+\\-]?\\d+)?\\b", | |
| }, | |
| builtin: { | |
| name: "support.function.basic", | |
| match: | |
| "(?<![A-Za-z0-9_])(?i:ABS|ACS|ADVAL|ASC|ASN|AT|ATN|BGET#|CHR|CODE|COLOUR|COLOR|COS|COUNT|DEG|EOF#|ERL|ERR|EVAL|EXP|EXT#|GET|IN|INSTR|INT|LEFT|LEN|LN|LOG|NOT|OPENIN|OPENOUT|OPENUP|PI|POINT|POS|PTR#|RAD|REPORT|RIGHT|RND|SCREEN\\$|SGN|SIN|SPC|SQR|STR|TAB|TAN|TIME|TIME\\$|TOP|USR|VAL|VPOS|PEEK)(?![A-Za-z0-9_])", | |
| }, | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment