From Esolang
Jump to navigation Jump to search

--yay is a stack-based esoteric programming language created with the goal of creating an esoteric programming language (I know, very impressive, especially for an esoteric programming language). It was made to be an easier-to-use, stack-based version of brainfuck.


There are two forms of data storage in --yay. The stack and the register:

The stack

The stack is a standard stack, a last-in, first-out data structure that can only store numbers.

The register

The register is a spot that can store a single number. The most important commands operate on the register, so it is a key component of the language.


--yay has 15 instructions in total. These are:

  • +: increments the top of the stack
  • -: decrements the top of the stack
  • p (lowercase letter p): pushes the value stored in the register onto the stack.
  • P (uppercase letter P): pops a value off the stack and stores it in the register.
  • J (uppercase letter J): pops x off the stack and jumps to location x (zero-indexed) of the code
  • # (octothorpe): starts a literal
  • ; (semicolon): ends a literal
  • 0-f: Contribute to the literal a.k.a #41; (inspired by HTML escape sequences) will store the value 65 into the register
  • ?: checks the value stored in register. If it's zero, the program will skip execution of the next command
  • : (colon): duplicates the value at the top of the stack
  • . (dot): same as brainfuck, but operating on the top of the stack
  • , (comma): same as brainfuck, but operating on the top of the stack
  • o (lowercase letter o): pops the top of the stack and outputs it as a number
  • i: gets input as a number and stores it into the register
  • q: halts the program


Hello, world!

This gets the ASCII values for the characters Hello world! into the register, pushes them onto the stack and prints them out. The l in Hello is pushed onto the stack, duplicated, and printed out twice.



This program skips the jump instruction if the input is not zero (I cannot remember how it works, I am just copying the description from my notes)

#12;pi ?J #0; poq #1;po #12;pJ


Feel free to add more implementations if you wish!

Python (original implementation)

import sys

def makeLiteral():
    global index
    global register
    global char

    index += 1
    char = code[index]
    number = char

    while (index := index + 1) < len(code):
        char = code[index]
        if char == ';':
        number += char
    register = int(number, 16)

with open(sys.argv[1], 'r') as f:
    code = f.read()

stack = []
register = None
index = -1

while (index := index + 1) < len(code):
    char = code[index]
    if char == '+':
        stack[-1] += 1
    elif char == '-':
        stack[-1] -= 1
    elif char == 'p':
    elif char == 'P':
        register = stack.pop()
    elif char == '#':
    elif char == '?':
        if register == 0:
            index += 1
    elif char == ':':
    elif char == '.':
        print(chr(stack.pop()), end='')
    elif char == ',':
        i = sys.stdin.read(1)
        register = ord(i)
    elif char == 'o':
        print(stack.pop(), end='')
    elif char == 'i':
        register = int(input())
    elif char == 'J':
        x = stack.pop()
        index = x - 1
    elif char == 'q':