8 releases (5 breaking)

0.10.0 Dec 27, 2022
0.9.0 Jun 6, 2022
0.8.1 Jan 29, 2022
0.8.0 Nov 11, 2021
0.5.1 Jan 25, 2021

#1007 in Development tools

Download history 5/week @ 2023-12-24 1/week @ 2024-02-04 5/week @ 2024-02-11 11/week @ 2024-02-18 53/week @ 2024-02-25 13/week @ 2024-03-03 22/week @ 2024-03-10 17/week @ 2024-03-17

106 downloads per month
Used in 6 crates

Apache-2.0

1MB
22K SLoC

The EndBASIC programming language - standard library

Build and test Health checks Deploy to staging Deploy to release Crates.io Docs.rs

EndBASIC is an interpreter for a BASIC-like language and is inspired by Amstrad's Locomotive BASIC 1.1 and Microsoft's QuickBASIC 4.5. Like the former, EndBASIC intends to provide an interactive environment that seamlessly merges coding with immediate visual feedback. Like the latter, EndBASIC offers higher-level programming constructs and strong typing.

EndBASIC offers a simplified and restricted environment to learn the foundations of programming and focuses on features that can quickly reward the programmer. These features include things like a built-in text editor, commands to render graphics, and commands to interact with the hardware of a Raspberry Pi. Implementing this kind of features has priority over others such as performance or a much richer language.

EndBASIC is written in Rust and runs both on the web and locally on a variety of operating systems and platforms, including macOS, Windows, and Linux.

EndBASIC is free software under the Apache 2.0 License.

What's in this crate?

endbasic-std provides the language standard library, which is composed of various commands and functions. Each of these can be exposed to the interpreter individually.

Standard library features

EndBASIC's standard library is inspired by other BASIC interpreters but does not intend to be fully compatible with them. The library currently contains:

  • Arrays: LBOUND, UBOUND.
  • Console manipulation: CLS, COLOR, INKEY, INPUT, LOCATE, PRINT, SCRCOLS, SCRROWS.
  • Data manipulation: READ, RESTORE.
  • Date and time manipulation: SLEEP.
  • Graphics: GFX_CIRCLE, GFX_CIRCLEF, GFX_HEIGHT, GFX_LINE, GFX_PIXEL, GFX_RECT, GFX_RECTF, GFX_SYNC, GFX_WIDTH.
  • Hardware interaction: GPIO_CLEAR, GPIO_READ, GPIO_SETUP, GPIO_WRITE.
  • File system interaction: CD, DIR, MOUNT, PWD, UNMOUNT.
  • Interpreter interaction: CLEAR, ERRMSG, HELP.
  • Numerics: ATN, CINT, COS, DEG, INT, MAX, MIN, PI, RAD, RANDOMIZE, RND, SIN, SQR, TAN.
  • Program manipulation: EDIT, KILL, LIST, LOAD,NEW, RUN, SAVE.
  • Strings and characters: ASC, CHR, LEFT, LEN, LTRIM, MID, RIGHT, RTRIM, STR.

Design principles

Some highlights about the EndBASIC implementation are:

  • Minimalist library. The standard library provides the logic for all built-in commands, but each command can be individually installed into the parser, and all interactions with the environment (e.g. the console, or the file system) are exposed via hooks that the caller needs to implement.

  • Async support. The library is async-compatible, making it trivial to embed it into Javascript via WASM.

Examples

The examples directory contains sample code to show how to embed the EndBASIC interpreter and standard library into your own programs.

  • examples/script-runner.rs: Shows how to instantiate full-blown EndBASIC interpreter and uses it to implement a script runner.

Dependencies

~4MB
~76K SLoC