How the compiler works
Envzn's compiler, evc, reads your .ev files and writes C++20, which clang++ turns into a
native program. Between those two ends, the work is split into stages, and each stage has exactly
one job. That split is what lets the compiler promise that a program it accepts is memory-safe,
and what will let the C++ step be replaced without changing what any program means.
The stages
- Parse. The source becomes tokens, then a tree of declarations and statements. The parser knows the grammar and nothing else: no language rule is checked here.
- Analyze. Every rule of the language lives here, and every error and warning the compiler
can report (see Diagnostics) comes from this stage or the next. Types are
resolved, conversions checked, and every move, borrow and
REFERENCEis followed. A program that breaks a rule stops here, with a code, a location and a remedy. - Build the EvIR. A program that passes analysis is translated into EvIR, Envzn's typed intermediate representation. By the time EvIR exists the program is already known to be legal; building it decides nothing. The IR specification describes every node.
- Verify. A whole-program walk over the EvIR proves the memory-safety floor: no reference outlives what it points into, and no value is used after it has been moved away. It adds to the analyzer's checks; it never replaces them.
- Emit. The EvIR becomes C++. The emitter only writes code: it chooses how to express each construct in C++, and it can never reject a program, because every decision about legality was made before it runs.
- Build.
clang++compiles the C++, andepm, the package manager, orchestrates modules, dependencies and the link.
Why C++, and what comes next
Compiling through C++ gets Envzn onto every platform clang reaches today, with a mature
optimizer behind it, while the language itself was the work that mattered. Because the emitter
makes no decisions of its own, C++ is a replaceable last step: everything a program means is
settled in the EvIR. A native LLVM backend is designed to replace the C++ step, starting from the
same EvIR, so a program will compile to the same behaviour either way.
Written in Envzn
The compiler itself is written in Python today. Everything a program runs on is written in Envzn: the kernel (strings, collections, numbers, files, threads) and the standard library built on it, with a thin layer of C and C++ only for what the operating system alone can do. That is the design principle at work, relocate the cost inward: the hard machinery lives in the compiler and the library, so the code you write stays readable.