원클릭으로
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 직업 분류 기준
| 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%
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.