Reading through the tny.ino - is this the normal way to write a BASIC interpreter ? I've always fancied writing one, but was put off by the complexity... but it doesn't actually look that complex!
Not exactly? Structurally yes, in that before we had fancy tools like "ANTLR" the standard way to write an interpreter/parser was to in more or less a straight-forward way translate the grammar into something that would process a stream of tokens. No in that "Tiny Basic" is double interpreted. The idea was that instead of publishing a huge listing of "Tiny Basic" for a particular platform Allison instead would publish one written in an intermediate language where it would be obvious enough (at least to his audience) how to implement each of the "op codes" within the intermediate language. I wanted to keep with that tradition of pseudo-machine instructions and so I made way more use of Goto (for example) than you probably should.
Yeah a lot of the early computers wouldn't have the grunt to parse into an AST. Instead they'd write bytecode, or interpret the code at runtime pretty efficiently. Storing programs as bytes instead of ASCII wasn't uncommon either. (e.g. "PRINT" -> 0x02, etc).
I wrote a simple BASIC interpreter for golang, and did something a little more high-level, but not by much:
5 comments
[ 4.1 ms ] story [ 16.2 ms ] threadOh, nice project btw! Bookmarked.
I wrote a simple BASIC interpreter for golang, and did something a little more high-level, but not by much:
https://github.com/skx/gobasic
https://blog.steve.fi/so_i_wrote_a_basic_basic.html
https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_ch...