198 releases

new 0.6.40 Jul 24, 2024
0.6.39-nightly.1 Jun 19, 2024
0.6.33 Mar 21, 2024
0.6.28 Dec 30, 2023
0.5.13 Nov 26, 2022

#267 in Programming languages

Download history 525/week @ 2024-03-31 351/week @ 2024-04-07 490/week @ 2024-04-14 274/week @ 2024-04-21 385/week @ 2024-04-28 365/week @ 2024-05-05 60/week @ 2024-05-12 202/week @ 2024-05-19 83/week @ 2024-05-26 80/week @ 2024-06-02 45/week @ 2024-06-09 448/week @ 2024-06-16 46/week @ 2024-06-23 377/week @ 2024-06-30 256/week @ 2024-07-07 52/week @ 2024-07-14

750 downloads per month
Used in 5 crates

MIT/Apache

3.5MB
90K 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–12MB
~135K SLoC