ワンクリックで
compiler-development
Guide for developing Sagittarius compiler. Use this when you need to develop or optimize the compiler.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Guide for developing Sagittarius compiler. Use this when you need to develop or optimize the compiler.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Guide for writing Sagittarius documents. Use this when asked to write a user reference manual or other Sagittarius documents.
Guide for developing Scheme libraries for Sagittarius. Use this when creating or modifying Scheme libraries in sitelib/, implementing SRFI, or adding new utility libraries.
Guide for executing Sagittarius tests. Use this when asked to execute tests.
| name | compiler-development |
| description | Guide for developing Sagittarius compiler. Use this when you need to develop or optimize the compiler. |
This guide provides an overview of the Sagittarius Scheme compiler architecture, optimization strategies, and best practices for development.
The Sagittarius compiler is written in Scheme, and consists of several phases:
The compiler source code is located in the boot/ directory
boot/compiler.scm - Main compiler entry pointboot/lib/pass*.scm - Optimization passesboot/lib/compiler-util.scm - Utility library for compilerboot/lib/iform.scm - Intermediate form definitionsboot/lib/smatch.scm - Pattern matching utilities, use include syntax to include in the compiler source filesThe compiler is built by the compiler from the host Sagittarius by running the command below:
For POSIX
./dist.sh precomp
For Windows
dist.bat precomp
This will generate the C code for the compiler in src/ directory. To execute the compiler
you need to build the Sagittarius first by running the command below:
For POSIX
make sash -j$(nproc)
For Windows (Ninja)
ninja sash -j %NUMBER_OF_PROCESSORS%
To analyze the optimisation result, you can use the compile-p* procedure to print the intermediate form of the code after each pass. The below example shows how to use it.
(import (sagittarius compiler))
(compile-p1 '((lambda (x) (+ x 1)) 5)) ;; shows result of pass1
(compile-p2 '((lambda (x) (+ x 1)) 5)) ;; shows result of pass2
(compile-p3 '((lambda (x) (+ x 1)) 5)) ;; shows result of pass3
(compile-p4 '((lambda (x) (+ x 1)) 5)) ;; shows result of pass4
(compile-p5 '((lambda (x) (+ x 1)) 5)) ;; shows result of pass5 (generated VM instructions)
You can run the script with the command below:
POSIX:
./build/sagittarius -Llib -Lsitelib -L'ext/*' -Dbuild ${file}
Windows:
.\build\sash.exe -Llib -Lsitelib -Lext/* -Dbuild %file%