Getting Started
Your First Raz Program
Create a small source file, compile it to C++, and inspect the generated output.
This page assumes that the Raz Gen2 compiler and its configured GNU C++ toolchain are available in the project checkout.
Create a source file
Create a file named hello.raz with the following
contents:
Example 1 — hello.raz
function main() -> i64 {
let answer: i64 = 40 + 2;
return answer;
}
The function declares an explicitly typed local binding, evaluates an arithmetic expression, and returns an integer value. The example demonstrates source syntax; it does not prescribe how a platform executable must be launched.
Emit C++
The compiler can write generated C++ to a specified path with
--emit-cpp or -o. From the project root,
the command shape is:
./compiler/razc/bin/razc hello.raz --emit-cpp hello.cpp
Check the toolchain page for the available command-line options and
the repository's build configuration. The generated
hello.cpp is the compiler output to inspect.
Inspect the output
Raz's backend targets C++17. The generated output may contain type mappings and implementation details that are not part of the Raz language contract. In particular, a C++ representation should not be interpreted as a guarantee that Raz exposes all corresponding C++ behavior.
Next steps
- Read the language reference for supported syntax.
- Review function declarations and calls, including when parentheses are required.
- See compiler architecture to follow source processing stages.