dykstrom / basic-mode

Emacs major mode for editing BASIC code
GNU General Public License v3.0
7 stars 10 forks source link

Optional spaces and syntax highlighting #17

Closed hackerb9 closed 1 year ago

hackerb9 commented 1 year ago

If possible, it would be nice if syntax highlighting worked in the way that most BASIC interpreters do, allowing spaces to be omitted. This cramped style is most commonly seen on small, 8-bit microcomputers. Leaving out spaces not only saves precious bytes, it can actually make the program run faster. Of course, such a situation is both hard to read and exactly when syntax highlighting would be the most helpful.

In the following three examples, I believe the first should be easy to implement and will handle 90% of the cases that bother me. The second may be possible but the third is, I believe, unlikely.

Example 1: No space between keywords and numbers

10 IF X=5THEN X=6ELSE20

Example 2: Optional space within GOTO

20 GO TO 30

Example 3: No space between keywords

30 FORT=1TO1000:?MID$(BUFFER$,T,1):NEXTT
dykstrom commented 1 year ago

I believe PR #18 solves examples 1 & 2. Please have a look! Example 3 is, as you write, hard to solve.