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.

喵谕 Meaoiu

From Esolang
Jump to navigation Jump to search

Meaoiu (喵谕) is a cat-themed esoteric programming language. Designed with Chinese keywords, its syntax heavily(maybe) revolves around feline behaviors.

Despite its esoteric and highly stylized nature, Meaoiu provides a suite of modern language features, including a built-in formatting tool, static diagnostics, and a Language Server Protocol (LSP) implementation.

Language Concepts

The Tail (~)

Every valid statement must be terminated with a ~.

蹭甲~       (Valid)
蹭乙        (Syntax Error: Missing tail)

Data Types

Meaoiu supports several basic data types, referred to as "Toys" (玩具):

  • Number (摸数): Non-negative decimal rational numbers.
  • String (闲话): Character strings wrapped in single or double quotes.
  • Boolean (好坏): 好喵 (Good Meow / True) and 坏喵 (Bad Meow / False).
  • Null (空碗): 空碗 (Empty Bowl), representing nothing.
  • Collection (纸箱): Arrays/Dictionaries, represented as Cardboard Boxes [= =].
  • Function (计谋): Functions or Schemes.

Variables and Memory Semantics

Variables are declared using the keyword (Rub). Meaoiu explicitly differentiates between reference, copy, and move assignments using different keywords:

Keyword Action Description
就是 (Is) Reference Both variables point to the same memory space.
就像 (Is like) Copy Creates a shallow copy of the data for the new variable.
才是 (Is only/truly) Move Moves the data to the new variable, disable the original one.

Syntax and Commands

Arithmetic and Chained Operations

Meaoiu supports basic arithmetic (+, -, *, /). It also features a unique "Sequence Operator" (分节运算) using commas to chain arithmetic evaluations from left to right without needing parentheses:

10+2*3 -, 7 *, 2~ 
(Evaluates to ((10 + 2 * 3) - 7) * 2)

Logic Gates

Logical operations use a self-closing pair syntax. Opening and closing keywords must strictly match:

Open Close Equivalent to
(And) 都好 (All good) AND
(And) 都坏 (All bad) NOR
(Or) 不坏 (Not bad) OR
(Or) 不好 (Not good) NAND

Example: a 和 b 都好~ means a && b.

Control Flow

Code blocks ("Thoughts") are wrapped in [# #]. The last expression in the block is its return value.

  • If/Else: Evaluated using 好不好? (Good or not?) and 不然 (Otherwise). Note that the condition comes after the block.
[# 扒[='Too big'=]喵~ #] 好不好? x > 5
不然 [# 扒[='Too small'=]喵~ #]~
  • Loops: Initiated with 玩耍 (Play). You can break out using 累了 (Tired) or continue/return early using 偷袭 (Ambush).

Functions

Functions are declared using 想要 (Want), followed by arguments in a box [= =], the function name, and the body in [# #]. To return a value, use 叼回来 (Bring back). (want some items to do something)

To call a function, use (Paw at) followed by arguments in [= =] and the function name.

(Declaration)
想要 [=n=] 双倍 [#
    叼回来 n * 2~
#]~

(Call)
扒[=5=]双倍~

Built-in Functions

Meaoiu comes with several built-in functions that can be called directly:

  • 扒[= 'Text' =]喵~: Print to stdout.
  • 扒[= 'Prompt' =]祈求~: Read input from stdin.
  • 扒[= 秒数 =]打盹~: Sleep for X seconds.
  • 扒[= 1, 10 =]添乱~: Generate a random integer between 1 and 10.
  • 扒[= '开心' =]猫咪艺术~: Print an ASCII cat face.

Examples

Hello, World!

扒[='Hello, World!'=]喵~

Factorial (Recursion)

想要 [=n=] 阶乘 [#
    [# 叼回来 1~ #] 好不好? n <= 1
    不然 [# 叼回来 n * 扒[=n - 1=]阶乘~ #]~
#]~

扒[="The factorial of 5 is: ", 扒[=5=]阶乘=]喵~

Number Guessing Game

想要 [==] 猜数字 [#
    蹭 答案~ 答案 就是 扒[=1, 100=]添乱~
    扒[="I'm thinking of a number between 1 and 100 meow~"=]喵~

    玩耍 [#
        蹭 输入 就是 扒[='Guess: '=]祈求~
        蹭猜测就是扒[=输入=]变摸数~ (Spaces between words are not necessary)

        [# 扒[="Please enter a number meow:"=]喵~ #] 好不好? 猜测 == 空碗
        不然 [#
            [# 扒[="Too small meow~"=]喵~ #] 好不好? 猜测 < 答案
            不然 [# 扒[="Too big meow~"=]喵~ #] 好不好? 猜测 > 答案
            不然 [#
                扒[="Correct! You are a genius cat meow~"=]喵~
                累了~
            #]~
        #]~
    #]~
#]~

扒[==]猜数字~

External resources