A Turing-complete stack-based language with exactly two lexical tokens
Project description
PatrickScript
A programming language with exactly two lexical tokens: the literal word
patrick and a single space ( ).
PatrickScript's entire specification — computational model, grammar, semantics, tooling — is designed and authored by an LLM. The only human-fixed inputs are the name and the two tokens. Everything else is the agent's to decide.
The language is owned by the patrick-script-worker track in the reflection
substrate. The specification, reference implementation, and conformance corpus
live in this repository.
Status: v1.3.0 — spec, reference interpreter, assembler, and 50-test conformance corpus (+ 12 disassembler round-trip tests) complete. Turing complete via JUMP/JUMPZ/JUMPNZ + unbounded memory. v1.1.0 adds CALL/RET subroutines (arities 11–12). v1.2.0 adds PUSHN single-instruction negative literal (arity 13). v1.3.0 adds PICK stack-copy instruction (arity 14).
Install (once published to PyPI)
pip install patrickscript
# or
uv add patrickscript
After install, patrickscript and patrickscript-asm are on PATH.
Running programs
./patrickscript <program.ps>
./patrickscript --disassemble <program.ps>
Or directly:
python3 src/patrickscript/ps.py <program.ps>
Running the conformance corpus
bash corpus/run-tests.sh
All 49 corpus tests and 12 disassembler round-trip tests should pass.
Writing programs with the assembler
Writing raw PatrickScript is impractical (PUSH 42 requires one patrick
token and 43 spaces). Use the assembler for human-readable input:
./psa program.psa > program.ps
./patrickscript program.ps
Or directly:
python3 src/patrickscript/psa.py program.psa > program.ps
./patrickscript program.ps
Assembly format: one mnemonic per line, labels end with :, comments
start with ;. String literals via .string "text" directive (emits
PUSH+OUTCHAR per character, supports \n \t \\ \"). See examples/
for complete programs.
Examples
examples/ contains:
hello-world.psa— "Hello, World!" via.stringdirective (v1.1.0)counter.psa— infinite counter (0, 1, 2, ...)echo.psa— copy stdin to stdout byte by bytefibonacci.psa— first 10 Fibonacci numbersfactorial-recursive.psa— recursive 5! using CALL/RET; shows nested recursion (v1.1.0)fizzbuzz.psa— FizzBuzz 1..15 using CALL/RET subroutines +.string(v1.1.0)call-string.psa— CALL/RET subroutine called twice;.stringinside subroutine (v1.1.0)square.psa— compute n² using PICK 0 for non-destructive stack copy (v1.3.0)pick-demo.psa— PICK 2 copies a deep stack element; prints four characters (v1.3.0)rot13.psa— ROT13 cipher: rotate A-Z and a-z by 13, pass others through; its own inverse (v1.3.0)
To run an example:
python3 src/patrickscript/psa.py examples/fibonacci.psa > /tmp/fib.ps
./patrickscript /tmp/fib.ps
Documentation conventions
Raw-legible tables: every markdown table in every *.md documentation
file in this repo is formatted so the raw source is legible — column pipes
aligned vertically, separator rows padded to match. Pure presentation; content
is never changed to satisfy alignment. Apply this to any table you add or edit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patrickscript-1.3.0.tar.gz.
File metadata
- Download URL: patrickscript-1.3.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.10","id":"oracular","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ba7413da759f2d7fa0fbd68b63d5821ba6d2605c2e1a0263422ea021c07831d
|
|
| MD5 |
18c24e8da384411b2151f9842d82ee3e
|
|
| BLAKE2b-256 |
8a7219acea42aee38f7e6d260f59fa77a997acaf55934b6ccf4f0c341e4087fd
|
File details
Details for the file patrickscript-1.3.0-py3-none-any.whl.
File metadata
- Download URL: patrickscript-1.3.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.10","id":"oracular","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b107360e734028973fb6028636c96250a9136d7de0a66c1d01fac5134afcb36
|
|
| MD5 |
45732b9fc8c80d31d8b27c0d2d9757ae
|
|
| BLAKE2b-256 |
ada1defcc58690a346de4db834cff16ab22d54b58d800e01d9bad132226c406d
|