In SmileBASIC, this code:
X = 20
IF Y == 4 THEN X = 40
is equivalent to this:
X = 20IF Y == 4 THEN X = 40
No space is required after a numeric literal. As soon as a non-decimal character appears, it is assumed to be the start of a new statement.
I cannot figure out how to get the syntax highlighting to detect that IF correctly.
Here’s my stripped down .sublime-syntax file:
%YAML 1.2
---
name: SmileBASIC
file_extensions: [prg, sb]
scope: source.smilebasic
contexts:
main:
# Conditional
- match: '(?i)\b(IF|THEN|ELSEIF|ELSE|ENDIF|ON)\b'
scope: keyword.control.conditional.smilebasic
# Numbers
- match: '\b[0-9]+'
scope: constant.numeric.smilebasic
And what I’m testing it against:
X = 20IF Y == 4 THEN X = 40
VARTHATENDSWITHIF = 7
X = 20
IF Y == 4 THEN X = 40
VARTHATENDSWITHIF = 7
If I include the preceding \b in the keywords, then the IF in the first line is not highlighted. If I remove it, then the IF is correctly highlighted, but the final two letters of VARTHATENDSWITHIF are also highlighted - bad!
On the other hand… As I am typing this, I realize that when I get around to scoping variable names, the latter issue will disappear. Should I just remove the preceding \b?