Data Packs Server Utility

In-Game C-Minus Compiler Pack (Programming Language)

  • 399 views 1 today
  • save_alt 18 downloads
Compatibility
Minecraft 1.21
Changes include
    • 3
    • 2
    • 2
    LeatherSword
    Lvl 29Expert Crafter
    6
    这里是皮革剑,一个充满特性的世界。
    这个数据包是一个小型教学语言:C-Minus语言的编译器,可以将C-Minus语言代码编译成mcfunction代码并执行。
    运行函数"c-:display/"打开代码编辑界面,在界面内编辑的代码可以被保存(并同时编译),之后可以点击运行。

    该语言为C语言的子集,支持如下语法:
    int类型定义,int和void函数定义,作用域,四则运算,函数调用,if-else分支和while循环。

    This is LeatherSword, a world filled with features.
    This pack is a compiler of a tiny programming language: "C-Minus".
    Run function “c-:display/” to open the code editing interface where you can save (and compile) your code. Then click "Run" to run the code.

    C-Minus is a subset of C language, with only the following syntax:
    int variables, int and void functions, scoping, arithmetic operations, function calls, if-else conditional branching, and while loop.

    示例代码如下: (运行该代码将得到int函数的返回值为18.)
    Example Code of C-Minus:
    int gcd (int u, int v) { /* calculate the gcd of u and v */
    if (v == 0) return u;
    else return gcd(v, u - u / v * v); /* v,u-u/v*v is equals to u mod v*/
    }
    int main() {
    int x; int y; int temp;
    x = 72;
    y = 18;
    if (x<y) {
    temp = x;
    x = y;
    y = temp;
    }
    return gcd(x,y);
    }

    More like this

      Have something to say?

    User4951066G-MAXIS14
    10/06/2025 2:31 pm
    Level 1 : New System
    Can u do a python compiler?
    1
    LeatherSword
    10/07/2025 12:49 am
    He/Him • Level 29 : Expert Crafter
    Actually I have posted one 5 months ago on PlanetMinecraft (Work In Progress). However, as the syntax of Python is too complex and incompatible with mcfunction language, it's not easy to make a complete Python compiler/interpreter. That pack is still working in progress, and 2 more months may be needed.
    2

    Welcome