Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

o0O

o0O is a tiny esoteric language where the only instruction tokens are o, 0, and O.

Interpreter usage:

go run . <program.o0O> [args...]

Source format

  • 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.

Trit mapping

The language treats tokens as base-3 digits (trits):

  • o => 0
  • 0 => 1
  • O => 2

Instructions

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, push a-b.
  • 0OO: pop one value and print it in decimal.
  • 0oo: read one line from stdin into the line register (trailing \n/\r\n removed).
  • 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 number target (1-based instruction index).
  • 000<target>: pop one value, jump to target if it is 0.
  • Ooo: run another o0O program from the path in the line register.
  • o0O: halt immediately.
  • oO0: drop one stack value.
  • oOO: swap top two stack values.

Meta-interpreter opcodes

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, push 1 if fetched else 0.
  • 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: pop target, pop cond; jump target program if cond == 0.

Formatter

Normalize and wrap a source file:

go run . -fmt helloworld.o0O

Formatter output rules:

  • instructions joined by exactly one space
  • no blank lines
  • hard-wrapped at 40 columns

Note: -fmt rewrites the input file in place.

Example

Run:

go run . helloworld.o0O

Output:

Hello0O world!

Interactive example:

go run . helloname.o0O

Meta-interpreter example:

go build -o o0O .
./o0O o0O.o0O helloworld.o0o

Looping example:

$ go run . countdown.o0O
Enter countdown start: 10
10
9
8
7
6
5
4
3
2
1
o0OOOoooOO0000OOO00!

About

o0O is an esoteric language written in o0O that only uses o, 0, and O

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages