Study Projects
Toy grammars teach syntax; real repositories show how lexers, ASTs, intermediate representations, diagnostics, and solvers fit together in production. Pair these projects with Demo Examples, Languages in Design & Research, and References & Downloads.
How to Read a Language Repository
A compiler or DSL codebase can span hundreds of thousands of lines. Narrow your focus to one stage of the pipeline:
- Start at the grammar or AST definition. Find the
.g4grammar, parser generator rules, or AST node types before reading optimization passes. - Follow one construct end to end. Trace a single expression (for example, a function call or
ifnode) from tokenization through lowering and code generation. - Read the error-reporting tests. Diagnostic fixtures show every edge case the language designers cared enough to pin down.
Parsers, Macros, and Compiler Toolchains
Repositories demonstrating grammar-driven parsing, hygienic macros, and SSA intermediate representations.
| Project | What to study | Prepare with |
|---|---|---|
| antlr/grammars-v4 | Real-world ANTLR 4 grammars for SQL, JSON, Python, and dozens of DSLs. | Grammar & Rules, ANTLR |
| antlr/antlr4 | ALL(*) parsing runtime, parse-tree listeners, and visitor generation. | Parsing & Trees |
| racket/racket | #lang reader and macro-expander architecture for language-oriented programming. | Racket |
| ocaml/ocaml | Cleanly separated compiler passes: parsing, type inference, lambda IR, and bytecode/native backends. | Compiler Design, OCaml |
| llvm/llvm-project | Read llvm/lib/IR and llvm/lib/Transforms/Scalar for SSA passes and constant folding. | Intermediate Representations, LLVM IR |
AI, GPU, and Scientific DSLs
Domain-specific compilers and numerical runtimes built for tensor kernels and Bayesian inference.
| Project | What to study | Prepare with |
|---|---|---|
| triton-lang/triton | Python-embedded GPU DSL lowering block-level operations to MLIR and PTX/AMDGPU. | Triton |
| JuliaLang/julia | Type inference, multiple dispatch, and LLVM JIT lowering in base/ and src/. | Julia |
| stan-dev/stan | Probabilistic DSL compiling statistical models to C++ with automatic differentiation. | Stan |
Logic, Constraint, and Symbolic Engines
Declarative solvers and Lisp-family runtimes where rules and data drive execution.
| Project | What to study | Prepare with |
|---|---|---|
| SWI-Prolog/swipl-devel | Warren Abstract Machine (WAM) bytecode engine and standard Prolog libraries. | Virtual Machines, Prolog |
| potassco/clingo | Grounder (gringo) and CDNL solver (clasp) architecture for Answer Set Programming. | Clingo (ASP) |
| MiniZinc/libminizinc | Flattening high-level constraint models into solver-ready FlatZinc. | MiniZinc |
| clojure/clojure | Persistent data structures, reader macros, and JVM bytecode compilation. | Clojure |
Practice Lab
Use these targeted exercises to connect the theory lessons to real language implementations:
- Compare two grammars. Open a small grammar in
antlr/grammars-v4(such as JSON or CSV) and map each rule to the EBNF concepts in Grammar & Rules. - Trace an optimization pass. Inspect one scalar pass in
llvm/lib/Transforms/Scalarand compare it with Code Optimization. - Model one constraint problem. Compare the graph-coloring ASP snippet in 11_clingo_graph_color.lp with a MiniZinc model from MiniZinc.