antigravity-basic
test Antigravity for make basic
- Active · last change 2-13-2026
- ★ 2 on GitHub
README
Tiny BASIC Interpreter (Pascal)
A lightweight, feature-rich BASIC interpreter written in Free Pascal. Supporting classic syntax, floating-point math, and character-based animations.
User Guide
How to Build
Requires Free Pascal Compiler (fpc).
fpc basic.pasHow to Run
Run the executable directly for an interactive REPL:
.\basic.exeOr pipe a script file:
type anim.bas | basic.exeSupported Commands
PRINT: Output text or values. Use;for 8-char tab stops and,for a single space.LET: Variable assignment (e.g.,LET X = 10or justX = 10).IF ... THEN: Conditional execution.FOR ... TO ... STEP ... NEXT: Loop constructs (supports nested loops and expressions).GOTO: Jump to a line number.LOAD "file.bas"/SAVE "file.bas": File persistence.SLEEP <ms>: Pause execution.CLS: Clear the screen.LIST,RUN,NEW,BYE: Environment control.
Project Structure
basic.pas: The core interpreter source code.anim.bas,multi_char_vars.bas,user_loop.bas: High-level program examples and demos.tests/: Extensive suite of technical tests and feature verification scripts.
Technical Details (Internal Architecture)
🤖 LLM Implementation Notes
This interpreter is designed for modularity and correctness in parsing complex expressions and control flow.
Core Components
- Scanner/Tokenizer: Keyword-aware scanner that handles "spaceless" syntax (e.g.,
LETA=10) by preferring keywords unless they are prefixes of longer identifiers. Case-insensitive. - Variable Storage: Uses
TStringListfor dynamic Name-Value mapping. Variables are stored as strings but treated asDoublefor calculations. - Expression Parser: Recursive descent parser supporting operator precedence (
* />+ ->= > < <> <= >=). - Control Flow:
- Line-based memory: Program is stored as a linked list of lines.
- Statement-level jumps: Supports jumping back to specific statements within a multi-command line (separated by
:). - Loop Stack: Handles nested
FORloops with a context stack storing the target line and the specific statement content to resume from.
Key Features
- Floating-Point: Internal numeric type is
Double. - Trigonometry: Built-in
SIN()function. - Multi-Statement:
:separator allows multiple commands per line. - Clean REPL: No prompt symbols (
>) and minimal status messages for sleek output compatibility.
Constraints & Compatibility
- Compiled with
fpcversion 3.2.2+. - Cross-platform
CLSsupport (ANSI escape codes on POSIX,cmd /c clson Windows). - Fixed-size loop stack (10 levels deep).
- No line number range limits (uses
Integerfor line numbers).

