#syntax-tree #ast #python #compiler #language #command-line #human-readable

app rythonc

A command-line Python to Rust compiler, at this point, very incomplete

12 releases

0.3.0 May 16, 2024
0.2.1 Jan 16, 2024
0.1.11 Jan 9, 2024
0.1.10 Dec 30, 2023
0.1.3 Oct 28, 2023

#240 in Programming languages

Download history 40/week @ 2024-07-30 1/week @ 2024-09-17 16/week @ 2024-09-24 1/week @ 2024-10-01

824 downloads per month

Apache-2.0

15KB
154 lines

rythonc

A compiler for Rython, a Python-like language. It can either generate Rust code, or an Abstract Syntax Tree (AST).

Installation

If you already have rust and cargo installed, you can just install rythonc with cargo.

cargo install rythonc

Useage

The useage can be displayed at the command line by running rythonc -h.

By default, the output is fairly minimal. If you would like more human-readable output, use the -p flag.

By default, the output is printed to stdout. To save it in a file, use the -o flag.

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

See Also

  • The python-mod crate. A way to write modules in Rython/Python that will be compiled to Rust.
  • The python-ast crate. The base library for working with Python ASTs in Rust.

Notes

Under the hood, rythonc is based on the language defined by the python-ast crate. It will become more capable as the capabilities of the underlying crate improve. At this point, it is mostly a proof of concept, missing many key features.

Dependencies

~11–17MB
~241K SLoC