Skip to main content

Pebble

An educational compiler and bytecode VM for the Pebble programming language.

Pebble is a small imperative language that compiles to bytecode and runs on a custom stack-based virtual machine. The project is designed for learning how compilers work, built incrementally using TDD.

Language Features

  • Integers, floats, strings, booleans
  • Variables (let declarations, const, reassignment)
  • Arithmetic, comparison, bitwise, and logical operators (and, or, not)
  • Short-circuiting and / or and chained comparisons (1 < x < 10)
  • Control flow: if/else, while, for loops, match
  • Collections: lists, dicts, list comprehensions, slicing, tuple unpacking
  • Functions (fn, return), default arguments, closures, and generators (yield)
  • Async / await (async fn, await)
  • Structs, classes with inheritance, and enums
  • Error handling: try / catch / finally and throw
  • Modules and imports (import, from ... import)
  • String interpolation ("hello {name}")
  • print() built-in
  • Comments (#)
  • Curly-brace blocks, newline-delimited statements (no semicolons)

Example

let count = 0
while count < 5 {
    if count > 0 {
        print(count)
    }
    count = count + 1
}

Pipeline

Source -> Lexer -> Parser -> Analyzer -> Module Resolver -> Type Checker -> Compiler -> Optimizer -> VM

See the documentation for a kid-friendly walk-through of each stage.

Quick Start

# Install dependencies
uv sync --all-extras

# Run tests
uv run pytest

# Lint and type check
uv run ruff check .
uv run pyright src tests

Using Pebble from Python

from pebble import run_source

print(run_source('print("Hello from Pebble!")'), end="")

run_source, compile_source, check and format_source are Pebble's public API; see Using Pebble from Python.

Documentation

Full docs (with kid-friendly explanations of every idea): https://robcox2910.github.io/pebble-lang/

Releasing

Other projects in the series (PyStack and PyLLM) use a pinned release of this one, not whatever is on main. To publish a change for them:

  1. Merge the change to main.
  2. Tag it: git tag -a vX.Y.Z -m vX.Y.Z && git push origin vX.Y.Z. A change to the public API bumps the minor version (v0.1.0 → v0.2.0); anything else bumps the patch (v0.1.0 → v0.1.1).
  3. In each project that uses it, edit the tag in [tool.uv.sources], run uv lock --upgrade-package <name>, and open a pull request so CI checks the pair together.

This project is one of a series that builds real systems "from scratch in Python" to teach how they work. See the series home for the full story.

Project What it teaches Repository Docs
PyOS Operating systems py-os Docs
Pebble Compilers and programming languages pebble-lang Docs
PyDB Relational databases pydb Docs
PyKV Key-value stores pykv Docs
PyDocDB Document databases pydoc-db Docs
PyGraphDB Graph databases pygraphdb Docs
PyTSDB Time-series databases pytsdb Docs
PyVecDB Vector databases pyvecdb Docs
PyColDB Column-family databases pycoldb Docs
PyCrypt Cryptography pycrypt Docs
PyNet Computer networking pynet Docs
PyWeb HTTP web servers pyweb Docs
PyGit Version control pygit Docs
PySearch Search engines pysearch Docs
PyMQ Message queues pymq Docs
PyLLM Language models (the brain) pyllm Docs
PyScheduler Job scheduling pyscheduler Docs
PyStack Full-stack integration pystack Docs

License

MIT

Metadata

Release files for fromscratch-pebble 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fromscratch-pebble 0.3.0
File Size Uploaded Provenance
fromscratch_pebble-0.3.0.tar.gz 408.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fromscratch-pebble 0.3.0
File Interpreter ABI Platform
fromscratch_pebble-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 519.1 kB

Release files / fromscratch_pebble-0.3.0.tar.gz

Download URL fromscratch_pebble-0.3.0.tar.gz
Size 408.6 kB
Tags Source
SHA-256 checksum
How to use checksums
544cb23ecfe239933407415fe9059ec78c69a24e6a8da7d430e977867934a362
BLAKE2b-256 checksum
How to use checksums
3c47252c7ac1f6fc612be7b801a946674a15af8a6a5e54c7a30e597d735a66fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / fromscratch_pebble-0.3.0-py3-none-any.whl

Download URL fromscratch_pebble-0.3.0-py3-none-any.whl
Size 110.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7725f2b538dbe0bceee5204ea2dcc9576de98a4c4c32da4e489adf6c04d93c1
BLAKE2b-256 checksum
How to use checksums
b356159c6250b4c28fe7fa22fea254b2635c83a8d64099ec87d042ed59c85c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for fromscratch-pebble 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fromscratch_pebble-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page