skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
331 stars 27 forks source link

Compiling BASIC to Go #79

Closed udhos closed 5 years ago

udhos commented 5 years ago

Hi,

Inspired by your gobasic tool, I am sketching a BASIC-to-Go compiler just for fun.

I managed to compile an adapted version of your example 99-game.bas. This is the game.bas version that my compiler currently can handle: https://github.com/udhos/basgo/blob/master/examples/game.bas

The compiler works like this:

basgo-build < examples/game.bas > game.go
go run game.go

You might want to have a look at the compiler: https://github.com/udhos/basgo Let me know what you think.

One question: should I report minor gobasic issues that I am finding? For example, gobasic requires LET in order to create a new variable, and I think it should be optional.

Best regards, Everton

skx commented 5 years ago

That's pretty cool, thanks for sharing.

I should add a link to this, and other related repositories to the README.md file.

One question: should I report minor gobasic issues that I am finding?

Yes, I'd be happy to fix bugs and issues.

For example, gobasic requires LET in order to create a new variable, and I think it should be optional.

But things like this I think I'll be less keen on changing.

There are a lot of varieties of BASIC, and whenever I've been in doubt I've chosen to implement things the way the BASIC I'm most familiar with did - In ZX Spectrum BASIC the LET was mandatory, so it is here too.

I'll leave things like that open as "fantasy" / "wishlist" issues, but I suspect I'd not be persuaded easily to make big changes.

udhos commented 5 years ago

There are a lot of varieties of BASIC, and whenever I've been in doubt I've chosen to implement things the way the BASIC I'm most familiar with did - In ZX Spectrum BASIC the LET was mandatory, so it is here too.

One nice thing to realize is, if gobasic supports LET as optional, it won't hurt compatibility with ZX Spectrum plus it will add compatibility with other BASIC dialects.