erg/crates/erg_compiler
2025-04-07 12:00:23 +09:00
..
context Revert "fix: unification bug" 2025-02-25 17:15:13 +09:00
error fix: clippy warns 2025-01-14 00:59:15 +09:00
lib feat: add type decl files 2025-04-07 12:00:23 +09:00
module fix: clippy warnings 2025-04-07 11:50:37 +09:00
tests fix: unification bug 2024-05-24 20:24:18 +09:00
ty fix: clippy warnings 2025-04-07 11:50:37 +09:00
.gitignore Rename dir: compiler -> crates 2023-01-15 12:03:19 +09:00
artifact.rs perf(els): improve diagnostics speed 2024-09-18 14:17:16 +09:00
build.rs chore: eliminate unwraps 2024-03-25 15:14:48 +09:00
build_hir.rs build: update pyo3 to v0.21 2024-07-02 03:15:28 +09:00
build_package.rs feat: add ErgConfig::respect_pyi 2025-02-18 21:58:53 +09:00
Cargo.toml fix: clippy warns 2025-01-14 00:59:15 +09:00
codegen.rs fix: trait impl bugs 2024-12-27 00:24:02 +09:00
compile.rs build: update pyo3 to v0.21 2024-07-02 03:15:28 +09:00
declare.rs perf: reduce AST/HIR element size 2024-10-13 17:51:37 +09:00
desugar_hir.rs chore: add hir::Methods 2023-11-05 01:18:32 +09:00
effectcheck.rs fix: clippy warnings 2025-02-21 18:00:45 +09:00
hir.rs fix: don't warn for unused control flow result values 2025-02-08 16:46:29 +09:00
lib.rs build: update pyo3 to v0.21 2024-07-02 03:15:28 +09:00
link_ast.rs chore: continue checking even if AST-linking failed 2024-09-18 14:30:10 +09:00
link_hir.rs fix: #510 2024-05-03 13:29:31 +09:00
lint.rs fix: don't warn for unused control flow result values 2025-02-08 16:46:29 +09:00
lower.rs fix: clippy warnings 2025-02-21 18:00:45 +09:00
main.rs chore: let HIRBuilder/ASTLowerer be generic 2023-11-03 03:03:11 +09:00
optimize.rs feat: glob import (WIP) 2024-08-17 10:25:17 +09:00
ownercheck.rs fix: incorrect Dict!.update! typing 2024-12-29 18:28:50 +09:00
README.md feat: impl setter for AST elements 2023-11-16 16:15:29 +09:00
transpile.rs fix: transpiler bug 2024-10-01 12:15:19 +09:00
varinfo.rs perf: reduce AST/HIR element size 2024-10-13 17:51:37 +09:00

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>