Loading
Jump to navigation
Jump to search
- This is still a work in progress. It may be changed in the future.
Designed by | User:DumbEsolangsOrgUser |
---|---|
Appeared in | 2025 |
Computational class | Unknown |
Reference implementation | Unimplemented |
Loading — joke esoteric programming language, where you modifying the loading.
Language Overview
Loading — an esolang for different loading styles (/|\-
, ...
, (|)|
).
You can change the loading style, and in [] you can set the loading duration (in seconds).
Commands:
Command | Description |
---|---|
<
|
Start of waitforme code |
>
|
End of waitforme code |
1
|
set style to /-\| |
2
|
set style to /|\- |
3
|
set style to ... |
4
|
set style to (|)| |
[
|
Start of setting loading duration |
]
|
Stop of setting loading duration |
Interpreters
Python (CLI)
#!/usr/bin/env python3 # coding: utf-8 import sys import time import argparse import re from typing import List, Tuple, Optional, Iterable class Style: def __init__(self, frames: List[str], pingpong: bool = False): self.frames = frames self.pingpong = pingpong def frame_list(self) -> List[str]: """Return the full frame list. If pingpong is enabled, extend with reversed frames (without duplicates).""" if not self.pingpong: return self.frames return self.frames + self.frames[-2:0:-1] STYLES = { '1': Style(["/", "-", "\\", "|"]), # classic spinner '2': Style(["/", "|", "\\", "-"]), # bash-like spinner '3': Style([".", "..", "..."], pingpong=True), # dots ping-pong '4': Style(["(", "|", ")", "|"]), # (|)| cycle } Token = Tuple[str, Optional[str]] # ('style'|'dur'|'wait'|'other', value) def tokenize(prog: str) -> List[Token]: """Split program into tokens (styles, durations, waitforme blocks).""" tokens = [] i = 0 while i < len(prog): c = prog[i] if c in STYLES: tokens.append(('style', c)) i += 1 elif c == '[': j = prog.find(']', i+1) if j < 0: raise ValueError("Unclosed '['") val = prog[i+1:j].strip() if not re.fullmatch(r'\d+(\.\d+)?', val): raise ValueError(f"Invalid duration: '{val}'") tokens.append(('dur', val)) i = j + 1 elif c == '<': j = prog.find('>', i+1) if j < 0: raise ValueError("Unclosed '<'") code = prog[i+1:j] tokens.append(('wait', code)) i = j + 1 else: tokens.append(('other', c)) i += 1 return tokens def segments(tokens: List[Token]) -> List[Tuple[str, float, Optional[str]]]: """Build segments: (style, duration, optional waitforme code before it).""" segs = [] cur_style = None pending_wait = None for t, v in tokens: if t == 'style': cur_style = v elif t == 'wait': pending_wait = v elif t == 'dur': if not cur_style: raise ValueError("Duration without style.") segs.append((cur_style, float(v), pending_wait)) pending_wait = None return segs def animate(style: Style, duration: float, fps: float, label: str): """Display spinner animation for a given duration.""" frame_time = 1.0 / fps frames = style.frame_list() start = time.time() idx = 0 try: while time.time() - start < duration: frm = frames[idx % len(frames)] print("\r" + label + frm, end='', flush=True) time.sleep(frame_time) idx += 1 finally: # Clear the line after animation ends print("\r" + " " * (len(label) + max(len(f) for f in frames)) + "\r", end='', flush=True) def run_waitforme(code: str): """Minimal waitforme interpreter: For each digit, sleep for that many seconds. Non-digits are ignored. """ for c in code: if c.isdigit(): time.sleep(int(c)) def run(program: str, fps: float, label: str): """Run a program: parse, execute waitforme blocks, then animate spinners.""" toks = tokenize(program) segs = segments(toks) if not segs: raise ValueError("No segments found.") for style_key, dur, wait_code in segs: if wait_code: run_waitforme(wait_code) animate(STYLES[style_key], dur, fps, label) def main(): parser = argparse.ArgumentParser(description="Loading esolang interpreter with waitforme support") parser.add_argument("program", nargs="?", help="Program string, e.g. '1[2]<123>2[1.5]'") parser.add_argument("-f", "--file", help="Read program from file") parser.add_argument("--fps", type=float, default=10, help="Frames per second (default 10)") parser.add_argument("--label", default="", help="Prefix text before spinner") args = parser.parse_args() if args.file: with open(args.file, 'r', encoding='utf-8') as f: prog = f.read() elif args.program: prog = args.program else: print("Provide program or -f FILE. Example: 1[2]<123>2[1.5]") sys.exit(1) try: run(prog, fps=args.fps, label=args.label) except Exception as e: print(f"\nError: {e}", file=sys.stderr) sys.exit(1) if __name__ == "__main__": main()
- was written by AI
simple tutorial for use cli :
python loading.py "...code..."