← All projects
Applications & services · Python
P

pebble

A small language in the browser: lexer → Pratt parser → resolver → tree-walking interpreter.

1 Run a program

Write Pebble code and press Run. Output and errors (with line/column) appear below, alongside the AST.

Press Run to execute.

2 AST

Parsed by a Pratt parser — binding powers, not a function per precedence level.

(nothing parsed yet)

3 Tokens

Every token carries line and column — that is where error positions come from.

kindlexemepos
No tokens.

4 The language in one screen

let/fn/return, if/else, while/for, numbers are floats, strings, lists [1,2], maps {}, closures that capture scopes, and/or short-circuit and return an operand. Sixteen builtins: print len push pop has split join str num abs min max range floor keys type.

A closure captures a scope, not a snapshot

let a = "global"; { fn show() { print(a); } show(); // global let a = "block"; show(); // global — the hard part }

Per-iteration bindings

let fns = []; for (let i = 0; i < 3; i = i + 1) { push(fns, fn() { return i; }); } print([fns[0](), fns[1](), fns[2]()]); // [0, 1, 2]

Undefined variables are errors, not nil. Every error names line and column: line 3, column 19: undefined variable 'xs'.

217 tests · Python 3.10–3.12 · standard library only · Built by Umer Hashmi