254 releases

0.6.53-nightly.5 Feb 25, 2025
0.6.52-nightly.1 Jan 29, 2025
0.6.51-nightly.0 Dec 29, 2024
0.6.49-nightly.0 Nov 26, 2024
0.5.13 Nov 26, 2022

#432 in Programming languages

Download history 148/week @ 2024-11-29 568/week @ 2024-12-06 562/week @ 2024-12-13 516/week @ 2024-12-20 475/week @ 2024-12-27 400/week @ 2025-01-03 296/week @ 2025-01-10 517/week @ 2025-01-17 336/week @ 2025-01-24 193/week @ 2025-01-31 537/week @ 2025-02-07 525/week @ 2025-02-14 1325/week @ 2025-02-21 245/week @ 2025-02-28 100/week @ 2025-03-07 103/week @ 2025-03-14

1,873 downloads per month
Used in 6 crates

MIT/Apache

4MB
99K SLoC

The Erg compiler (codename: Centimetre)

The overall structure is described in detail in architecture.md(English).For other language translations of architecture.md, please check them out by yourself.

Use erg_compiler as a Python library

erg_compiler can be built as a Python library by using pyo3/maturin.

Example

import erg_compiler

module = erg_compiler.exec_module(".i = 1")
# foo.er:
# .bar = 1
foo = erg_compiler.__import__("foo")
assert module.i == 1
assert foo.bar == 1
import erg_compiler
erg_parser = erg_compiler.erg_parser
erg_ast = erg_compiler.erg_parser.ast

module = erg_parser.parse(".i = 1")
d = module.pop()
d.sig = erg_ast.VarSignature.new(erg_ast.Identifier.public("j"), None)
module.push(d)
ast = erg_ast.AST.new("test", module)
code = erg_compiler.compile_ast(ast)
exec(code)
assert j == 1

Debug install (using venv)

python -m venv .venv
source .venv/bin/activate
maturin develop --features pylib_compiler

Release install

maturin build -i python --release --features pylib_compiler
pip install <output wheel>

Dependencies

~2–32MB
~399K SLoC