Labubu
Jump to navigation
Jump to search
Paradigm(s) | (esoteric, interpreted) |
---|---|
Designed by | Digitpink |
Appeared in | 2025 |
Computational class | (Finite state machine) |
Major implementations | JavaScript |
Influenced by | Lua |
LABUBU
LABUBU is a minimal, playful esoteric programming language inspired by Labubu toys. It supports only two commands:
- popmart – assignment
- labubu – output
LABUBU programs are plain text files. Each line either assigns a literal to a variable or prints one or more values to the screen.
Syntax
Assignment
Use:
popmart <em>identifier</em> = <em>literal</em>
- identifier must start with a letter and may contain letters, digits, or underscores.
- literal is either:
* a number (integer or float), e.g.42
,-3.14
* a string in single or double quotes, e.g."hello"
,'world'
Output
Use:
labubu(<em>expr1</em>, <em>expr2</em>, …)
- Each expr may be an identifier, a number literal, or a string literal.
- Values are printed separated by spaces, followed by a newline.
Lines that do not match either form will produce an “Unknown command” error at runtime.
Semantics
- Variables are dynamically typed and stored in a global environment.
- Assignment binds the given literal to the variable name.
- Output resolves each expression:
* If it matches a defined variable, its value is printed. * Number and string literals are printed directly. * Otherwise the raw token is printed.
Example
Here is a simple LABUBU program:
popmart x = 123 popmart y = "Hello" popmart z = 'world' labubu(x, y, z) labubu("The answer is", x)
Produces:
123 Hello world The answer is 123
Implementation
Below is a minimal HTML + JavaScript interpreter. Save this as .html
and open in your browser to try LABUBU:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>LABUBU Interpreter</title> <style> body { font-family: monospace; padding: 1em; } textarea { width: 100%; height: 200px; } #output { background: #222; color: #eee; padding: 1em; margin-top: 1em; white-space: pre-wrap; } button { margin-top: 0.5em; } </style> </head> <body> <h1>LABUBU Interpreter</h1> <textarea id="code" placeholder="Write LABUBU code here…"></textarea><br> <button onclick="runLabubu()">Run</button> <div id="output"></div> <script> const vars = {}; function runLabubu() { const lines = document.getElementById('code').value.split('\n'); document.getElementById('output').textContent = ''; for (let raw of lines) { let line = raw.trim(); if (!line) continue; if (line.startsWith('popmart ')) { const m = line.match(/^popmart\s+([A-Za-z_]\w*)\s*=\s*(.+)$/); if (m) { let v = m[2].trim(); if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) { v = v.slice(1, -1); } else if (!isNaN(v)) { v = Number(v); } vars[m[1]] = v; continue; } } if (line.startsWith('labubu(') && line.endsWith(')')) { let args = parseArgs(line.slice(7,-1)); let out = args.map(tok => { tok = tok.trim(); if (vars.hasOwnProperty(tok)) return vars[tok]; if ((tok.startsWith('"') && tok.endsWith('"')) || (tok.startsWith("'") && tok.endsWith("'"))) { return tok.slice(1,-1); } if (!isNaN(tok)) return Number(tok); return tok; }); document.getElementById('output').textContent += out.join(' ') + '\n'; continue; } document.getElementById('output').textContent += `Unknown command: ${line}\n`; } } function parseArgs(s) { let res = [], cur = '', inQ = false, q = ''; for (let c of s) { if (inQ) { cur += c; if (c===q) inQ = false; } else { if (c==='\"'||c==="'") { inQ=true; q=c; cur+=c; } else if (c===',') { res.push(cur); cur=''; } else cur+=c; } } if (cur) res.push(cur); return res; } </script> </body> </html>
See also