o0O is a tiny esoteric language where the only instruction tokens are o, 0, and
O.
Interpreter usage:
go run . <program.o0O> [args...]- Instructions are separated by a single space character.
- Newlines are ignored entirely and are only for visual wrapping.
- Only
o,0,O, space, and newline are valid source characters. - Canonical style is hard-wrapped at 40 columns.
The language treats tokens as base-3 digits (trits):
o=>00=>1O=>2
Each instruction starts with a 3-token opcode.
ooo<literal>: print a packed string literal.- The literal is encoded as 6 trits per byte (big-endian base-3).
- Every 6-token chunk must decode to
0..255.
oo0<number>: push base-3 integer onto stack.ooO: pop two values, push(a+b) mod 256.o0o: pop one value and print it as a byte.o00: duplicate top stack value.00O: pop two values, pusha-b.0OO: pop one value and print it in decimal.0oo: read one line from stdin into the line register (trailing\n/\r\nremoved).0o0: print the current line register.0O0: parse the line register as decimal and push it onto stack.O0o: shift the next CLI argument into the line register.00o<target>: unconditional jump to instruction numbertarget(1-based instruction index).000<target>: pop one value, jump totargetif it is0.Ooo: run anothero0Oprogram from the path in the line register.o0O: halt immediately.oO0: drop one stack value.oOO: swap top two stack values.
These are used by o0O.o0O to implement a real interpreter in o0O:
OO0: load target program from path in line register.OOO: fetch next target instruction, push1if fetched else0.OOo: decode fetched target instruction, push opcode id and cache payload.O00: decode cached payload as base-3 integer and push.O0O: decode cached payload as packed literal and print it.0oO: move one value from main stack to target stack.0Oo: move one value from target stack to main stack.Oo0: pop target PC and jump target program unconditionally.OoO: poptarget, popcond; jump target program ifcond == 0.
Normalize and wrap a source file:
go run . -fmt helloworld.o0OFormatter output rules:
- instructions joined by exactly one space
- no blank lines
- hard-wrapped at 40 columns
Note: -fmt rewrites the input file in place.
Run:
go run . helloworld.o0OOutput:
Hello0O world!
Interactive example:
go run . helloname.o0OMeta-interpreter example:
go build -o o0O .
./o0O o0O.o0O helloworld.o0oLooping example:
$ go run . countdown.o0O
Enter countdown start: 10
10
9
8
7
6
5
4
3
2
1
o0OOOoooOO0000OOO00!