3

I’m a big fan of early/mid 1980s personal computers like the Amstrad CPC, Commodore 64 and the Sinclair Spectrum. One thing these computers all had was a version of BASIC.

As a language hacker myself I’m curious: were these interpreters implemented as tree-walker interpreters (simply traversing the parse tree) or bytecode interpreters? I can’t find a lot of information on how they were implemented. It’s fascinating to me how they were built given the limitations of the hardware at the time.

Garry Pettet
  • 8,096
  • 22
  • 65
  • 103

1 Answers1

2

They were mostly token based. This means, that the integrated code editor transformed the human readable commands in the source into a bytecode. Upon execution those bytecodes were read and a dispatcher then executed the appropriate command (stored as machine code in the kernal) with the given parameters. The ZX Spectrum even had a keyboard to enter Basic Tokens:

http://www.worldofspectrum.org/ZX81BasicProgramming/

For some others see here:

https://www.primidi.com/atari_basic/description/the_tokenizer

http://fileformats.archiveteam.org/wiki/Commodore_BASIC_tokenized_file

http://cpctech.cpc-live.com/docs/bastech.html

Hope this anwers your question.

  • Sorry for answering such an old question, but the answer was pretty clear and straightforward and a question without an answer is just not really something complete. – Wör Du Schnaffzig May 03 '20 at 08:16