erg/crates/erg_compiler
2024-03-03 20:00:06 +09:00
..
context feat: add Copy trait 2024-03-03 16:22:14 +09:00
error fix: compile-time eval bug 2024-02-23 23:03:34 +09:00
lib feat: add Copy trait 2024-03-03 16:22:14 +09:00
module fix(els): minor bugs 2024-02-26 12:02:28 +09:00
tests fix: eliminate unwraps 2024-02-24 23:02:59 +09:00
ty fix: range type definition bug 2024-02-26 01:35:41 +09:00
.gitignore Rename dir: compiler -> crates 2023-01-15 12:03:19 +09:00
artifact.rs fix(els): don't show irrelevant parse errors 2024-01-27 16:18:00 +09:00
build.rs fix: test failure 2024-02-14 16:23:07 +09:00
build_hir.rs feat: add initializer, destructor syntax 2024-02-10 18:49:04 +09:00
build_package.rs fix: eliminate unwraps 2024-02-24 23:02:59 +09:00
Cargo.toml feat: make erg_compiler available as a Python lib 2023-11-15 11:20:10 +09:00
codegen.rs fix: constructor bug 2024-03-03 20:00:06 +09:00
compile.rs feat: add erg_compiler::Compiler (python module) 2024-02-15 03:09:22 +09:00
declare.rs chore: add TraitImpl::declared_in 2024-02-11 13:55:17 +09:00
desugar_hir.rs chore: add hir::Methods 2023-11-05 01:18:32 +09:00
effectcheck.rs feat: add initializer, destructor syntax 2024-02-10 18:49:04 +09:00
hir.rs fix: constructor bug 2024-03-03 20:00:06 +09:00
lib.rs feat: add erg_compiler::Compiler (python module) 2024-02-15 03:09:22 +09:00
link_ast.rs chore: eliminate clippy warns 2023-08-24 23:38:27 +09:00
link_hir.rs fix: python script backend bug 2024-02-19 02:26:18 +09:00
lint.rs fix: eliminate unwraps 2024-02-24 23:02:59 +09:00
lower.rs fix: range type definition bug 2024-02-26 01:35:41 +09:00
main.rs chore: let HIRBuilder/ASTLowerer be generic 2023-11-03 03:03:11 +09:00
optimize.rs feat: make erg_compiler available as a Python lib 2023-11-15 11:20:10 +09:00
ownercheck.rs fix: eliminate unwraps 2024-02-24 23:02:59 +09:00
README.md feat: impl setter for AST elements 2023-11-16 16:15:29 +09:00
transpile.rs fix: python script backend bug 2024-02-19 02:26:18 +09:00
varinfo.rs fix: eliminate unwraps 2024-02-24 23:02:59 +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>