231 releases

new 0.6.49-nightly.0 Nov 26, 2024
0.6.47-nightly.4 Oct 20, 2024
0.6.40 Jul 24, 2024
0.6.33 Mar 21, 2024
0.5.13 Nov 26, 2022

#318 in Programming languages

Download history 411/week @ 2024-08-08 631/week @ 2024-08-15 329/week @ 2024-08-22 486/week @ 2024-08-29 342/week @ 2024-09-05 200/week @ 2024-09-12 444/week @ 2024-09-19 660/week @ 2024-09-26 793/week @ 2024-10-03 505/week @ 2024-10-10 791/week @ 2024-10-17 120/week @ 2024-10-24 446/week @ 2024-10-31 333/week @ 2024-11-07 226/week @ 2024-11-14 271/week @ 2024-11-21

1,283 downloads per month
Used in 6 crates

MIT/Apache

4MB
98K 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–30MB
~438K SLoC