#python #ast #编译器 #语言 #语法树 #命令行 #不完整

app rythonc

一个命令行 Python 到 Rust 编译器,目前还很不完整

12 个版本

0.3.0 2024年5月16日
0.2.1 2024年1月16日
0.1.11 2024年1月9日
0.1.10 2023年12月30日
0.1.3 2023年10月28日

#145编程语言

每月 40 次下载

Apache-2.0

15KB
154

rythonc

一个 Rython(类似于 Python 的语言)的编译器。它可以生成 Rust 代码,或者一个抽象语法树(AST)。

安装

如果您已经安装了 rustcargo,您可以使用 cargo 安装 rythonc

cargo install rythonc

用法

可以在命令行中通过运行 rythonc -h 来显示用法。

默认情况下,输出相当简略。如果您需要更易读的输出,请使用 -p 标志。

默认情况下,输出会打印到 stdout。要将其保存到文件,请使用 -o 标志。

Usage: rythonc [OPTIONS] [INPUTS]...

Arguments:
  [INPUTS]...

Options:
  -o, --output <OUTPUT>        The output file.
  -p, --pretty                 Nicely format the output.
  -a, --ast-only               Don't actually compile, just output the ast.
  -l, --log-level <LOG_LEVEL>  Sets the log level. Values are: off,error,warn,info,debug,trace [default: WARN]
      --log-file <LOG_FILE>    Write log events to this file.
  -h, --help                   Print help
  -V, --version                Print version

另请参阅

  • python-mod 包。一种在 Rython/Python 中编写模块的方式,这些模块将被编译为 Rust。
  • python-ast 包。在 Rust 中处理 Python AST 的基础库。

注意

在底层,rythonc 基于python-ast 包中定义的语言。随着底层包功能的增强,它将变得更有能力。目前,它主要是一个概念验证,缺少许多关键功能。

依赖关系

~11–18MB
~244K SLoC