2个不稳定版本

0.6.1 2023年12月20日
0.5.2 2023年11月6日

#1114 in 编程语言


用于 enalang

GPL-3.0-only

105KB
3K SLoC

ena

极度臭名昭著的算法

Ena是一种非常糟糕的语言,其实现最初是用C编写的,但后来被重写为Rust,因为主要开发者厌倦了调试段错误。

安装

目前,Ena不提供预构建的二进制文件,您需要自己构建。

Ena是用Rust编写的,因此您应该已安装 cargorustc

构建和安装命令

# If you want a stable version
$ cargo install enalang

# If you have cloned the repo
$ cargo install --path ./enalang

测试是否已安装Ena

$ ena --version

如果看到错误,请检查您的PATH变量是否已配置。

语法

Ena是一种基于栈的语言。这意味着它在栈上运行。这听起来合理,不是吗?

展示比解释更容易。

Ena没有函数,它有块。唯一的区别是块不接收参数。相反,它从栈中获取它需要的参数。

# Comments are written in Python style.

# Let's print hello world.

# Main is the entrypoint of any ena program.
main {
    print_hello # Calls print_hello block.
}

# Let's define another block to call from main.
print_hello {
    "hello world!" # A literal puts the value on top of stack.
    println # println takes the literal on top of stack and prints it with a new line.
}

移除所有注释后,结果是一段非常短且整洁的代码。

examples文件夹中查看更多示例。

依赖项

~1.2–1.9MB
~40K SLoC