186 releases

new 0.6.35 Apr 24, 2024
0.6.33 Mar 21, 2024
0.6.28 Dec 30, 2023
0.6.26 Nov 25, 2023
0.5.13 Nov 26, 2022

#260 in Programming languages

Download history 266/week @ 2024-01-03 259/week @ 2024-01-10 277/week @ 2024-01-17 259/week @ 2024-01-24 263/week @ 2024-01-31 302/week @ 2024-02-07 619/week @ 2024-02-14 501/week @ 2024-02-21 424/week @ 2024-02-28 494/week @ 2024-03-06 524/week @ 2024-03-13 440/week @ 2024-03-20 270/week @ 2024-03-27 474/week @ 2024-04-03 451/week @ 2024-04-10 311/week @ 2024-04-17

1,553 downloads per month
Used in 5 crates

MIT/Apache

3.5MB
88K 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–13MB
~133K SLoC