Dr Jefyll wrote:
drogon wrote:
the trickiest thing to parse is the unary minus
Glad I'm not the only one who had trouble with that!
TinyBASIC hacks in the unary minus quite nicely.
You'll only notice it is a little trick when things such as A*-1 and A/-1 won't parse.
You have to type A/(-1), but in reality you don't see that needed in programs.
If you want a quick result in getting a BASIC: port TinyBASIC and skip the intermediate interpreter.
It should really fit in 2K. It took me about a week to port to the Gigatron this summer.
From there, BASIC is never finished. You need POKE/PEEK/USR() etc. Then RND().
You can add FOR-TO-NEXT, perhaps STEP as well, arrays, SAVE/LOAD, perhaps strings.
Colon (:) sounds too-trivial and not-really-needed, but it eliminates many GOTOs
and reduces the craving for ELSE. You can also get pretty far in "faking" strings if you have arrays.
Having TinyBASIC as a start it will always be slow however, and if you plan for speed: tokenise.
TinyBASIC spends most of its time parsing integers and searching for line numbers.
Making a tokenised version requires
much more planning ahead, especially if you want LIST...
If you want floating point, all bets are off.. Bill Gates also didn't do that part for his BASIC...
Links I found useful:
https://en.wikipedia.org/wiki/Tiny_BASIC Wikipedia article
http://www.ittybittycomputers.com/IttyB ... esign.html DESIGN NOTES FOR TINY BASIC (Dennis Allison et al.)
http://www.ittybittycomputers.com/IttyBitty/TinyBasic/ Tom Pittman's implementation
http://p112.sourceforge.net/tbp112.html P112 Tiny Basic User's Guide (V1.0, 18 FEB 1999)
http://www.bitsavers.org/pdf/interfaceA ... 92-108.pdf Dr. Wang's Palo Alto Tiny Basic (Roger Rauskolb)
https://www.applefritter.com/node/2859 Apple 1 BASIC