Skip to content

Repository files navigation

Leopard

Leopard

Leopard is a small, beginner-friendly programming language for writing desktop GUI programs: windows, controls, menus, turtle graphics, editable text windows, sound, and serial-port and network communication (two-way serial, receive-only TCP and UDP, with helpers for NMEA 0183). It's a from-scratch, modernized resurrection of leopard.bas, a 2013 Liberty BASIC application by Brandon Watts — this time a real language, with variables, expressions, control flow, functions, and lists, rather than a fixed-vocabulary state machine.

window "Hello", 300, 100:
    label "Hello, world!" as greeting at 10, 10, 200, 24
pip install -e ".[gui]"
leopard run hello.lep

See what it can do: Leopard Instruments

Leopard Instruments showing position, speed, a compass card, a wind dial, depth, and a table and plot of nearby AIS targets

examples/leopard_instruments.lep is a complete marine instrument display, written entirely in Leopard. It reads NMEA 0183 from a serial port (a GPS or an instrument bus on a USB adapter), a TCP server or a UDP broadcast (a Wi-Fi NMEA multiplexer), and shows:

  • Position, speed and course, and a compass card that turns with the heading
  • Wind, apparent and true: the true wind is worked out from the apparent wind and the boat's speed
  • Depth, with a history and a shallow-water alarm, and water temperature
  • Satellites: a sky plot and signal-strength bars for GPS, GLONASS, Galileo and BeiDou
  • Waypoint navigation: cross-track error, range, bearing, closing speed and time to go
  • AIS targets: a list sorted by range and a plot around your own boat, from AIS messages decoded bit by bit

It also has a checksum-verified sentence log, recording to a file, and a red night mode. It starts in its built-in simulator, so you don't need any hardware. A boat motors round Elliott Bay in Seattle with five AIS vessels nearby. Every sentence it generates is a real, checksummed NMEA or AIS sentence, and it goes through the same decoding code a serial port's data does.

pip install -e ".[gui]"
leopard run examples/leopard_instruments.lep
Satellites Navigation Night mode
Sky plot and satellite signal-strength bars Cross-track error indicator and waypoint data The display in red night mode

It's about 2,200 lines of readable, heavily commented Leopard. It's a good program to open once you've worked through a few lessons, to see the language used for serious work.

Installing

git clone https://github.com/CFFinch62/Leopard.git
cd Leopard

Leopard is a standard pip package (leopard-lang), split into optional extras so you only install what you need:

pip install -e .              # the language core only — no GUI dependency at all
pip install -e ".[gui]"       # + PyQt6, needed for window/menu/turtle/sound/serial/network programs
pip install -e ".[build]"     # + PyInstaller, needed for `leopard build`
pip install -e ".[dev]"       # + pytest, for running this project's own test suite

A bare (no-window) script never needs PyQt6 installed at all — the language core has zero GUI dependency.

Using the CLI

leopard run script.lep              # run a program
leopard check script.lep            # report syntax errors without running it
leopard build script.lep            # compile it into a standalone executable
leopard build script.lep -o dist -n myapp

leopard build bundles your script's source, the Leopard runtime, and a small generated launcher into one --onefile PyInstaller executable — no Python installation required on the machine that runs it.

leopard check lexes and parses without executing anything. That distinction matters: a Leopard program can open dialogs, write files and play sound, so "does this parse?" should not be answered by running it. Errors are printed as <path>:<line>: <message> — with the file path, unlike the bare Line N: message that run reports — so an editor or build tool can attribute them. It exits 0 when the file is clean and 1 when it is not.

$ leopard check greeter.lep
greeter.lep: no syntax errors

$ leopard check broken.lep
broken.lep:12: expected an expression, found 'NEWLINE'

Editor support

editors/vscode is a VS Code extension for .lep files: syntax highlighting for all 147 reserved words split by role, control-name and turtle-method awareness, snippets for windows, controls, events and turtle drawing, and Run / Check / Build commands wired to the Problems panel.

Learning Leopard

  • user-docs/LANGUAGE_GUIDE.md — start here. A tutorial that walks through every part of the language with runnable examples.
  • user-docs/LANGUAGE_SPEC.md — the complete, flat reference: every operator, statement form, and builtin function in one catalog, kept verified against source.
  • dev-docs/GRAMMAR.md — the incremental design/decision log (why things are the way they are), rather than a flat reference.
  • user-docs/IDE_GUIDE.md — a tour of the Leopard IDE itself (below), for when you're ready to move past a plain text editor.
  • examples/ — twenty-one sample programs, from bare-script fundamentals through every window kind, graphics, sound, and serial ports and networking, ending with the Leopard Instruments display above. See that folder's own README for the full, ordered list.

The Leopard IDE

Leopard is fully usable from the command line with any text editor, but a dedicated IDE also lives in this repo, at src/leopard_ide/ — syntax highlighting, a run/build toolbar, a file browser, an in-app documentation viewer (the three files linked above, under Learning Leopard), and the example curriculum above.

pip install -e ".[gui]"
leopard-ide

Project layout

LANGUAGES/Leopard/
  original -source/leopard.bas   <- original 2013 source, read-only reference
  user-docs/
    LANGUAGE_SPEC.md           <- complete, flat language reference
    LANGUAGE_GUIDE.md          <- beginner tutorial
    IDE_GUIDE.md               <- tour of the Leopard IDE
  dev-docs/
    GRAMMAR.md                 <- design/decision log
    IMPLEMENTATION_PLAN.md     <- project tracker / build history
    FEATURE_PARITY_REVIEW.md   <- gap review vs. the original leopard.bas
    LANGUAGE_ROADMAP.md        <- stdlib/control-flow gap review vs. mainstream languages
  examples/                    <- the example curriculum, ending with leopard_instruments.lep
  screenshots/                 <- images used in this README
  pyproject.toml
  src/leopard_lang/
    tokens.py, lexer.py, ast_nodes.py, parser.py    <- lexer/parser
    errors.py, environment.py, interpreter.py        <- runtime core
    builtins_core.py, builtins_files.py              <- non-GUI builtins
    cli.py                                           <- `leopard` command
    build.py                                         <- `leopard build` / PyInstaller packaging
    gui/                                              <- windows, menus, turtle, text window, sound
  src/leopard_ide/                                    <- the Leopard IDE (`leopard-ide` command)
    main.py, app/                                     <- editor, file browser, doc viewer, etc.
  tests/
  build_ide.py                                        <- standalone PyInstaller build of the IDE
  packaging/                                          <- .deb build (see packaging/README.md)

Development

pip install -e ".[dev,gui,build]"
pytest

513 tests, headless (QT_QPA_PLATFORM=offscreen set automatically in tests/conftest.py), a few seconds to run. See dev-docs/IMPLEMENTATION_PLAN.md for the full build history and design decisions behind the language.

Acknowledgments

Leopard's vocabulary and spirit — window/text-window/graphics-window programs, named GUI controls, turtle graphics — come from Brandon Watts's original 2013 Liberty BASIC application, leopard.bas (original -source/leopard.bas, and originally distributed via leopardprogramming.com). This project is a ground-up reimplementation as a real programming language, but the idea and design it draws inspiration from are his.

License

MIT — see LICENSE.

About

Beginner-friendly GUI programming language in Python — windows, controls, turtle graphics, serial/TCP/UDP with NMEA 0183 support. A modern resurrection of Brandon Watts' Liberty BASIC original..

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages