Hi!
I have just pushed a number of commits that change the syntax of Engine BASIC in a somewhat intrusive fashion. I generally try to avoid any such change, but in this case it was the only way to overcome the limitations on variable naming imposed by the previous "whitespace-optional" syntax.
Some background: More modern BASIC dialects require keywords to be separated from identifiers in some way. Engine BASIC did not impose any such requirements in order to be compatible with Microsoft BASIC, which does not require any spacing between tokens and variables. This, however, creates ambiguity. It is not possible to distinguish between the command DIM ension(10)
and the array variable reference dimension(10)
. That is not a big problem for MS BASIC, because the maximum length for variable names is two, so collisions are few and far between. For us, however, it is highly inconvenient, having both longer variable names and considerably more tokens occupying the namespace.
The changes I have pushed amend the syntax insofar as whitespace between alphanumeric tokens and alphanumeric variable identifiers and numeric constants is now required. That means that you can still write a=a+1
, but you have to write print a
and print 1+2
, where previously printa
and print1+2
would have sufficed. On the other hand, you can now use variable names that start with tokens, such as dimension
, token
, position
etc.
Even though these are intrusive changes, compatibility with existing Engine BASIC programs should be high. The reason is that Engine BASIC has always saved programs formatted with whitespace, so modulo any pre-existing bugs, they should still load and function as before. Programs written in a text editor may have to be touched up, though.
There is a new configuration option (CONFIG 9,1
) that restores the old behavior, which may be useful for importing MS BASIC programs, or as an option for users preferring the whitespace-optional syntax. Note, however, that while this option is enabled, programs written for the new syntax may not load correctly.
These changes will show up in the upcoming nightly build. Check it out, and feel free to report any bugs: https://github.com/uli/basicengine-firmware/issues
CU
Uli