README 1.8 KiB raw
1
2
RADIANCE BOOTSTRAPPING COMPILER
3
4
Bootstrap compiler for the Radiance programming language, written in C99.
5
6
This is the Stage 0 compiler used to bootstrap Radiance from scratch. It
7
compiles Radiance source code to RISC-V machine code. Once built, it can be
8
used to compile the self-hosted Radiance compiler, which then recompiles
9
itself until a fixed point is reached.
10
11
BUILDING
12
13
  Requirements:
14
15
    * clang (or another C99 compiler)
16
    * lld (the LLVM linker)
17
18
  To build the compiler:
19
20
    make
21
22
  This produces `bin/radiance.s0`, the Stage 0 compiler binary.
23
  You can specify a different C compiler with:
24
25
    make CC=gcc
26
27
USAGE
28
29
    bin/radiance.s0 [options] <input.rad>
30
31
  Options:
32
33
    -o <path>       Output file path (required)
34
    -mod <path>     Register an additional module
35
36
COMPILER PIPELINE
37
38
  The compiler is structured as a series of passes:
39
40
    Scanner     (scanner.c)    Tokenizes source text
41
    Parser      (parser.c)     Builds an AST from tokens
42
    Desugar     (desugar.c)    Syntactic transformations on the AST
43
    Resolver    (resolver.c)   Name resolution and type checking
44
    Gen         (gen.c)        Code generation targeting RISC-V 64-bit
45
    RISC-V      (riscv.c)      Instruction encoding
46
47
  Supporting modules:
48
49
    ast.c         AST node definitions and utilities
50
    module.c      Module loading and management
51
    symtab.c      Symbol table
52
    strings.c     Interned string table
53
    ralloc.c      Region-based memory allocator
54
    io.c          File I/O helpers
55
    options.c     Command line option parsing
56
    gen/emit.c    Binary emission
57
    gen/data.c    Read-only and read-write data sections
58
59
FORMATTING
60
61
  To format source files before committing, run `make fmt`.
62
63
LICENSE
64
65
  Licensed under the MIT License,
66
  Copyright (c) 2025-2026 Radiant Computer (https://radiant.computer)