We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Pancake

From Esolang
Jump to navigation Jump to search

Pancake is an esoteric programming language designed by User:Namotanu.

Overview

Pancake is an integer-based stack language where the most important design goal is for the source code to look like a delicious stack of pancakes.

Each line or block of code represents a layer of a pancake, and the entire program visually resembles a fluffy stack ready to be eaten. While the aesthetics are sweet and savory, under the hood, it operates on a standard integer stack.

Syntax

Layout and Structure

Pancake code execution is unique because the structure and flow depend entirely on the "plates" placed at the bottom of the source code.

  • The Plates: The final line of the source code must contain one or more plates. A plate is represented by the regular expression: (-+)(\+-+)*
  • Parallel Stacks: A single plate can have multiple sections separated by a + character. Each section of - characters represents a parallel stack or lane where pancakes (data/commands) are served.
  • Execution Columns: Only the columns (vertical alignment) that contain a - character from the plate on the final line will be processed. Any columns that do not align with a - are completely ignored by the interpreter.
  • Execution Order: By default, execution begins at the first plate (the leftmost plate at the bottom). The interpreter reads the pancake commands from the bottom layer (just above the plate) and moves upwards row by row.

Commands

Each layer of the pancake stack is checked row by row (for each plate/lane) against the following regular expressions to determine the command.

  • MV (Market Value): Refers to the current dynamic "Market Value" of the pancake (stored in a separate global register).
  • Data notation: Stack operations are described using standard Forth notation: ( before -- after ).
Regular Expression Stack Operation Description
/^[\| ]*\+<([0-9]+\$\|MV)\][\| ]*$/ Pancake Flip: Flips the top N (or MV) items of the stack. (e.g., flipping top 3 of [0,1,2,3,4] results in [0,1,4,3,2]).
/^[\| ]*8+[\| ]*$/ Stack Inversion: Inverts the entire stack.
/^[\| ]*(\(\))+[\| ]*$/ ( x y -- y x ) Swap: Swaps the top two items.
/^[\| ]*:+[\| ]*$/ ( x -- x x ) Duplicate: Duplicates the top item.
/^[\| ]*0+[\| ]*$/ ( x -- ) Pop/Discard: Discards the top item.
/^[\| ]*#+<(-?[0-9]+\$\|MV)\][\| ]*$/ ( -- N ) Push Value: Pushes the value specified on the "price tag" (or MV) onto the stack.
/^[\| ]*I+[\| ]<.*\]*$/ ( -- chars... ) Push String: Pushes the ASCII/Unicode codes of the characters inside <...> sequentially.
/^[\| ]*({})+[\| ]*$/ ( x -- ) Set Market Value: Sets the Market Value (MV) to x.
/^[\| ]*O+<([0-9]+\$\|MV)\][\| ]*$/ Multi-Pop: Pops and discards N (or MV) items from the stack.
/^[\| ]*\++[\| ]*$/ ( x y -- x+y ) Addition
/^[\| ]*X+[\| ]*$/ ( x y -- x-y ) Subtraction
/^[\| ]*\*+[\| ]*$/ ( x y -- x*y ) Multiplication
/^[\| ]*\/+[\| ]*$/ ( x y -- floor(x/y) ) Division: Returns the flooring of x / y.
/^[\| ]*%+[\| ]*$/ ( x y -- mod(x,y) ) Modulo
/^[\| ]*!+[\| ]*$/ ( x -- 1 or 0 ) Logical NOT: Pushes 1 if x = 0, otherwise 0.
/^[\| ]*===+[\| ]*$/ ( x y -- 1 or 0 ) Equality: Pushes 1 if x = y, otherwise 0.
/^[\| ]*@+[\| ]*$/ ( -- char ) Character Input: Reads one character from input and pushes its ASCII/Unicode value.
/^[\| ]*;+[\| ]*$/ ( x -- ) Numeric Output: Outputs x as an integer.
/^[\| ]*\|+[\| ]*$/ ( x -- ) Character Output: Outputs x converted to its ASCII/Unicode character.
/^[\| ]*[i ]+[\| ]*$/ Move Left: Moves the execution pointer to the pancake stack directly to the left on the same plate (at the same height).
/^[\| ]*[A ]+[\| ]*$/ Move Right: Moves the execution pointer to the pancake stack directly to the right on the same plate (at the same height).
/^[\| ]*(<>)+[\| ]*$/ ( x -- ) Conditional Skip: Skips the next instruction if x = 0.
/^[\| ]*\$+[\| ]*$/ ( x -- ) Conditional Move Left: Moves to the left pancake stack at the same height if x = 0.
/^[\| ]*&+[\| ]*$/ ( x -- ) Conditional Move Right: Moves to the right pancake stack at the same height if x = 0.
/^[\| ]*(=+\*)+=+[\| ]*$/ ( x -- ) Loop to Plate: If x ≠ 0, loops the execution pointer back down to the plate.
/^[\| ]*==[\| ]*$/ ( x -- ) Jump to Plate: Jumps to the x-th plate from the bottom-left. (Terminates execution if the target plate does not exist).
/^[\| ]* +[\| ]*$/ NOP: Does nothing.
/-+/ Plate: A plate boundary (can also be placed mid-stack).

Examples

Hello, World!

This program displays "Hello, World!". It visually resembles a stacked pancake served on plates.

   =*==*=
   ::::::
   ||||||
--------------------------
 | 888888               |
 | IIIIII<Hello, World!]|
--------------------------

Explanation

  1. Execution starts from the bottom plate.
  2. IIIIII<Hello, World!] pushes the ASCII codes of "Hello, World!" onto the stack from first to last character.
  3. 888888 inverts the stack so that the first character ("H") is at the top of the stack.
  4. The execution passes through the middle plate --------------------------.
  5. |||||| pops and outputs each character until the stack is empty (or loops/duplicates via the rows above).
  6. :::::: duplicates values, and =*==*= handles the loop structure to successfully print the whole string.