https://github.com/dps/toybasic
A toy basic compiler playground
https://github.com/dps/toybasic
Last synced: 10 months ago
JSON representation
A toy basic compiler playground
- Host: GitHub
- URL: https://github.com/dps/toybasic
- Owner: dps
- License: bsd-2-clause
- Created: 2021-01-30T21:34:43.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-01T04:42:30.000Z (over 5 years ago)
- Last Synced: 2025-07-21T10:19:39.647Z (11 months ago)
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# toybasic
This is a toy compiler for a simple dialect of BASIC in golang. It's written in Go and it generates (ugly!) Go code.
I made this just for fun. The code is pretty short and hopefully easy to read. I hope you enjoy it too.
Example program `example/hello.bas`
```VB
10 PRINT "Hello, world."
20 LET x = (3 * 2) + 3
30 LET x = x + 1
40 IF x == 10 THEN PRINT "Ten!"
45 PRINT x
50 IF x >= 15 THEN GOTO 70
60 GOTO 30
70 END
```
Example output
```
$ ./toybasic