Skip to content
프로젝트

ehsanmok/create-your-own-lang-with-rust

GitHub에서 보기

소개

Rust로 나만의 프로그래밍 언어 만들기

프로그래밍 언어 및 런타임

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-2
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

CreateLang.rs Logo

Create Your Own Programming Language with Rust

Learn compiler fundamentals by building four languages from scratch

Overview • Languages • Quick Start • Requirements • Book

CI GitHub Pages Read the Book License


Edition 1.0 Complete
Four languages covering interpretation, compilation, type systems, and object-oriented programming.
LLVM code generation, JIT compilation, type inference, and memory management.


Overview

This book arose from frustration with the lack of modern, clear, and concise teaching materials for beginners who want to learn how to create their own programming language.

"If you don't know how compilers work, then you don't know how computers work" 1

"If you can't explain something in simple terms, you don't understand it" 2

Languages

The book teaches programming language implementation through four progressively complex languages:

Language Type System Execution Features Rust Version
Calculator None Interpreter/VM/JIT Arithmetic expressions stable / nightly
Firstlang Dynamic Interpreter Variables, functions, recursion stable 1.70+
Secondlang Static LLVM JIT Type inference, compilation nightly + LLVM
Thirdlang Static LLVM JIT Classes, methods, OOP nightly + LLVM
create-your-own-lang-with-rust/
├── calculator/     # Simple arithmetic (interpreter, VM, JIT backends)
├── firstlang/      # Interpreted language with recursion
├── secondlang/     # Compiled language with type inference
├── thirdlang/      # Object-oriented with classes and methods
└── book/           # mdbook source for createlang.rs

Each language has its own README with detailed instructions.

Quick Start

Firstlang (stable Rust)

cd firstlang
cargo run -- examples/fibonacci.fl    # Run a program
cargo run                              # Start REPL

Secondlang (nightly + LLVM)

cd secondlang
rustup run nightly cargo run -- examples/fibonacci.sl
rustup run nightly cargo run -- --ir examples/fibonacci.sl   # View LLVM IR

Thirdlang (nightly + LLVM)

cd thirdlang
rustup run nightly cargo run --bin thirdlang -- examples/point.tl
rustup run nightly cargo run --bin thirdlang -- examples/counter.tl

Calculator

cd calculator
cargo run --bin main examples/simple.calc                                            # Interpreter
cargo run --bin main --no-default-features --features vm examples/simple.calc        # VM
rustup run nightly cargo run --bin main --no-default-features --features jit examples/simple.calc  # JIT

Requirements

Stable Rust (Calculator interpreter/VM, Firstlang)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Nightly Rust + LLVM (Calculator JIT, Secondlang, Thirdlang)

# Install nightly
rustup toolchain install nightly

# Install LLVM
# macOS:
brew install llvm

# Debian/Ubuntu:
# See https://apt.llvm.org/

Check your LLVM version and update Cargo.toml accordingly:

LLVM Version inkwell feature
20.x llvm20-1
19.x llvm19-1
18.x llvm18-1

Running Tests

# All projects
cargo test -p calculator -p firstlang
rustup run nightly cargo test -p secondlang -p thirdlang

Building the Book

cd book
mdbook serve    # Local preview at http://localhost:3000
mdbook build    # Build static site

Support
If you found this project useful, please consider donating to:

Child Foundation • Black Lives Matter • Food Bank of Canada

관련 프로젝트 살펴보기

불러오는 중…