前言
没错,这就是那个木兰。
2020 年一月第一时间提出知乎问题「木兰」编程语言有什么特色?的正是本人,这是那段暴风骤雨的亲历记。
目标
悬赏完成之前,将努力向 重现「木兰」编程语言的目标 迈进。系列技术文章集结在 知乎专栏 与 开源中国(待同步),部分文章曾发在 国产语言论坛木兰主题。
IDE 辅助
运行木兰源码文件
$ 木兰 测试/手工测试/命令行.ul 运行上面的 猜数字 游戏。
中文报错信息
交互环境中仅提示出错所在位置简要信息:
> func a(n) { return n1+1 }
> func b(n) { print(n) }
> b(a(2))
😰 请先定义'n1'再使用, 见第1行
运行源码时,可见调用各层的详细信息。如果错误发生在其他文件,可见文件名:
$ 木兰 测试/错误处理/引用模块.ul
😰 取列表内容时,索引超出范围
“测试/错误处理/下标越界函数.ul”第2行:print([][0])
调用层级如下
见第3行:a()
参考例程在此
其中 实用 为较接近实用的部分。另外 木兰代码编辑器 也用木兰代码编写。
所有例程演示的语法可用原始的木兰可执行文件 ulang-0.2.2.exe 检验。如发现有异烦请告知,长期悬赏在此。
功能说明
随着逐渐缩小 与原版木兰的差距,将完善 语法说明。用户手册 尚待更新。为调试方便,报错等等反馈信息会逐渐中文化。
试用发布版
必需 Python 3.7 ~ 3.13,源码文件需 UTF-8 编码,pip install ulang 安装木兰。
命令行交互环境
$ 木兰
木兰向您问好
更多信息请说'你好'
> 和 = 0
> for 数 in 1..10 {
>> 和 += 数
>> }
> 和
55
功能说明 在此。
binder 在线环境
New -> Terminal 打开命令行,同样输入“木兰”运行
新手入门
无编程经验不打紧,请入此门。
参与开发
实现简介
木兰源代码转换为 Python 的中间表示(AST)后执行,可实现各种语法设计与周边功能,并可方便地利用 Python 现有生态。
新手开发者请看开发流程与项目结构简介。
使用 Python 3.7 ~ 3.13 的最新小版本。Mac、Linux、Windows 下全部测试通过。
为提高开发维护效率,本项目中尽量使用中文标识符。包括语法规则、Python 代码等等。
木兰语言部分依赖的第三方 Python 包:
- rply-ulang
- 【已内置】codegen
本地运行
$ python -m 木兰
木兰向您问好
更多信息请说'你好'
>
运行测试
- 重现项目自身测试
python -m unittest 测试.unittest.交互 测试.unittest.语法树 测试.unittest.所有用例 测试.unittest.报错 测试.unittest.Python到木兰
- 原始木兰可执行文件测试
以下为检验与原始木兰可执行文件功能一致,在 Windows 下需将 ulang-0.2.2.exe 置于项目根目录。
以下测试语法相关用例。Windows 系统下会使用 木兰原始可执行文件(ulang-0.2.2.exe)测试,其他系统下则会使用 Python 安装的木兰进行测试:
python 测试/运行所有.py
以下测试源码生成相关用例:
python -m unittest 测试.unittest.原始可执行文件
以下测试木兰源码转换为 Python:
python -m unittest 测试.unittest.木兰到Python
许可证
GNU GPLv3
版本历史介绍
Metadata
Release files for ulang 0.1.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ulang-0.1.9.1.tar.gz | 384.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ulang-0.1.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 442.7 kB
Release files / ulang-0.1.9.1.tar.gz
| Download URL | ulang-0.1.9.1.tar.gz |
|---|---|
| Size | 384.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb0742a4bd8305f39bd6286dbb8137e6099a543e2cbc415ca813b0aa32ec0030
|
|
BLAKE2b-256 checksum How to use checksums |
2c7543062e019540fb934ff180f8924d2449c1c5535e82908a8c9e15f999d965
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / ulang-0.1.9.1-py3-none-any.whl
| Download URL | ulang-0.1.9.1-py3-none-any.whl |
|---|---|
| Size | 58.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f6ae6294ae85ca06a002e50c1ff64588ae0b7deb1774e72ba2f186fca1650ec
|
|
BLAKE2b-256 checksum How to use checksums |
a328a22b43e9e3ee56a28f7d9f1ab33250c20219325d1a3d19b120a542e1ddf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Security for ulang 0.1.9.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.