Monty Save

A language toolchain for explicitly typed annotated Python. ๐Ÿ

Project README

Monty

A language toolchain for explicitly typed annotated Python.

Index

Abstract

Monty (/หˆmษ’ntษช/) is a language toolchain for a subset of Python 3.0+ it is designed from the ground up to be an LSP-first compiler, emphasizing high responsiveness and extraordinarily fast compile times.

Similar alternatives are already mature and pretty impressive, namely:

The compiler aims to maintain the inherent dynamism of Python while incorporating advanced type inference and type-checking capabilities.

Key Differentiators:

  1. Compile-Time Execution of Global Scope: Monty evaluates code in the global scope at compile-time, thereby making the import process static. This architectural decision is intended to encourage the segregation of business logic from initialization code.

  2. Advanced Typing Semantics: Monty's type system is influenced by prominent type checkers such as pytype, pyright, and pyre. It employs advanced type inference algorithms and supports a variety of type-narrowing techniques.

Monty is not intended to ever be a production grade language, it is a project I enjoy working on in my spare time and most recently I have decided to transition away from total coverage of Python and pick out a, strict, toy, subset of the language.

Building the compiler

You will need a fairly recent version of rustc, I am building locally with 1.72.0

Then specify that you would like to build the montyc binary, dropping the --release flag as needed.

cargo build --release --bin montyc

Crate/Repository Layout

  • /montyc is the compiler binary, it is a thin wrapper around montyc_driver
  • /montyc_driver is where all the magic happens, type checking/inference, calls into codegen, etc...
  • /montyc_codegen is where codegen providers are, currently only Cranelift is supported but I'd like to support both LLVM and GCC in the future.
  • /montyc_hlirt is a High Level Interpreter Runtime (HLIRT) and is a minimal but geniune Python interpreter used mainly for compile time evaluation.
  • /montyc_query is where the query interface is defined for the driver.
  • /montyc_flatcode is where AST -> FlatCode lowering happens.
  • /montyc_parser is the parser implementation.
  • /montyc_core is where all fundamental types used in this project go to live.

"prior art"

Open Source Agenda is not affiliated with "Monty" Project. README Source: mental32/monty
Stars
67
Open Issues
0
Last Commit
7 months ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating