skx / gobasic

A BASIC interpreter written in golang.

Home Page:https://blog.steve.fi/tags/basic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling BASIC to Go

udhos opened this issue · comments

commented

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

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.

commented

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.