
Show HN: An Actually-Tiny Basic for Arduino - gtrevorjay
https://github.com/trevorjay/atinybasic
======
contingencies
Interesting it wasn't called ATtinyBasic!

[https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_ch...](https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_chart)

------
Jaruzel
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!

Oh, nice project btw! Bookmarked.

~~~
gtrevorjay
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.

~~~
stevekemp
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:

[https://github.com/skx/gobasic](https://github.com/skx/gobasic)

~~~
Jaruzel
Cool! I'm reading your blog post right now:

[https://blog.steve.fi/so_i_wrote_a_basic_basic.html](https://blog.steve.fi/so_i_wrote_a_basic_basic.html)

