How pschachte/wybe works
Project Type and Purpose
• The project is a compiler for the Wybe programming language. Its primary purpose is to transform Wybe source code (which combines declarative and imperative elements) into executable code using a pipeline of parsing, analysis, optimization, and code-generation passes.
• The README, along with files such as INSTALL.md and the user guide (WYBE.md), clarifies that the project is an early-stage compiler written in Haskell and leveraging LLVM.
Major Components
a. Frontend (Parsing & Lexical Analysis):
– This covers the scanner, parser, and AST construction modules (see files like src/Scanner.hs, src/Parser.hs, src/AST.hs).
b. Semantic Analysis & Intermediate Representations:
– Modules such as AliasAnalysis.hs, Analysis.hs, Normalise.hs, Unbranch.hs, Types.hs, etc., manage the semantic verification and intermediate representations.
c. Optimization / Transformation:
– Modules like Optimise.hs, Transform.hs, Expansion.hs, Flatten.hs, etc., perform optimization and code transformations.
– Link: From “Semantic Analysis” to “Optimizer/Transformer” labelled “apply optimization/transformation passes” (showing that the verified IR is processed to improve performance and prepare for code generation).
d. Code Generation / Backend:
– Key files such as Emit.hs, LLVM.hs, Macho.hs, and others are responsible for generating target code using external tools (LLVM infrastructure).
– Link: From “Optimizer/Transformer” to “Code Generation” labelled “generate executable or intermediate code” (explaining that the optimized IR is passed to backend modules to generate machine code or LLVM IR).
e. External Dependencies and Build/Tooling Components:
– Include build artifacts (Makefile, stack.yaml, wybe.cabal) and continuous integration configuration (.github/workflows for Ubuntu and macOS).
– Also add a link from “LLVM Compiler Infrastructure” to “Code Generation” labelled “external codegen dependency” (demonstrating that the compiler relies on LLVM for final code generation).
f. Library Support:
– The “wybelibs” directory (with files such as array.wybe, bool.wybe, etc.) contains libraries that may be linked or imported during compilation.
g. Testing and Documentation:
– The “test-cases” directory holds an extensive suite of test files (.wybe, .exp, and scripts) representing the regression and example cases used to verify the compiler.
– Link: From “Compiler” to “Test Cases” labelled “regression testing / verification” (this connection indicates that test inputs are used to validate compiler behavior).
– The “documentation” directory and README provide guidelines for users and contributors.