Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boxbeam/nanobasic
An extremely minimal interpreter for BASIC with only a handful of legal instructions
https://github.com/boxbeam/nanobasic
Last synced: 2 days ago
JSON representation
An extremely minimal interpreter for BASIC with only a handful of legal instructions
- Host: GitHub
- URL: https://github.com/boxbeam/nanobasic
- Owner: boxbeam
- Created: 2022-03-08T02:54:34.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-10T19:21:41.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T23:09:31.582Z (about 2 months ago)
- Language: Java
- Homepage:
- Size: 151 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NanoBASIC
An extremely minimal interpreter for BASIC with only a handful of legal instructions. Below is an example script which prints all numbers up to 1 million.```basic
10 LET A = 0
20 LET A = A + 1
30 PRINT A
40 IF A >= 1000000 THEN GOTO 60
50 GOTO 20
60 PRINT "DONE"
```To run a script, first clone this repository and build the jar using `./gradlew shadowJar`, then you may find the jar in the `build/libs` folder. You can run your script using `java -jar NanoBASIC-all.jar path/to/script.bas`.
## Instructions
`LET = ` - Assign a variable to a numeric value
`PRINT ` - Print a numeric value
`PRINT "string"` - Print a string
`IF THEN ` - Conditionally run an instruction
`GOTO ` - Jumps to a line number
`GOSUB ` - Jumps to a line number and pushes the previous line number onto the stack
`RETURN` - Returns to the last line pushed onto the stack
`INPUT ` - Reads a number from stdin and puts it into a variable
`END` - Ends the program