MC++ is an esoteric, command-oriented programming language built using C++ designed to mirror Minecraft server commands as closely as possible.
It supports script execution, an interactive REPL, scoped command blocks, named-argument functions, dynamic / loose typing, and command-based control flow.
- Download the latest build from the releases page
- To start the REPL, simply run the program or call it with
mcpp - To run a mcpp file, use
mcpp <file.mcpp> - To show help, run
mcpp --helpormcpp -h - To show version, run
mcpp --versionormcpp -v
- Building from source code requires Windows, Visual Studio: Desktop Development with C++, and MSVC / MSBuild
- To build in Visual Studio: Open
mcpp.slnx, then Build Solution - To build from terminal: Open Developer Command Prompt for Visual Studio and run:
MSBuild.exe mcpp.vcxproj /p:Configuration=Release /p:Platform=x64
The REPL is an interactive session for performing live commands and seeing output in realtime. The REPL supports multi-line input and persistent session state.
>>>means fresh input...means current block is still open/stopexits REPL session:helpshows REPL help:quitexits the REPL:exitexits the REPL
/say <expr>evaluates an expression and prints the result/give <name> <expr>assigns a value to a variable/msg <name>reads one line of input and stores it as string<name>/stophalts program/function <name> {param1, param2, ...}starts a function, uses/execute store resultto return within function scope, and must be within a command block to be multiple lines long. Command block}ends the function definition./function <name> {a: expr, b: expr, ...}calls a function with named arguments/execute store result <var> run <command>runs a command and stores that command's result in<var>/execute store result <expr>returns a value from inside a function/execute if <condition> run <command>runs the command only if the condition is true/execute unless <condition> run <command>runs the command only if the condition is false/execute until <condition> run <command>keeps running the command until the condition becomes true/summon command_block { ... }creates a block, usually used with function definitions/gamerule keep_inventory truemakes block or function variable changes persist outside that scope/gamerule keep_inventory falsekeeps block or function variable changes local to that scope
MC++ supports the following:
- Integers:
67 - Strings:
"example" - Booleans:
trueorfalse - Variable references:
x - Parantheses:
(x + 2) * 3 - Unary minus:
-x - Arithmetic:
+,-,*,/ - Comparison:
==,!=,<,<=,>,>=
+performs integer addition when both operands are integers, and otherwise performs string concatenation-,*,/,<,<=,>,>=all require numeric values- Numeric strings can be coerced into numbers
- Division is integer division (no decimal)
- Conditions can use booleans, integers, or strings. Empty string is false, non-empty string is true, but
"false"and numeric0are treated as false.
- Top level: variables persist for current script or REPL session
- Command blocks: creates child scope
- Functions: creates child scope
- With
keep_inventoryactive, block/function writes merge back into the parent scope, otherwise local within block/function.