2026-07-04 21:53:04 +03:00
= Компилятор Pascal Blaise
2026-04-20 16:22:10 +03:00
:icons: font
:source-highlighter: rouge
2026-07-04 21:53:04 +03:00
image:https://github.com/graemeg/blaise/actions/workflows/bootstrap.yml/badge.svg["Статус сборки", link="https://github.com/graemeg/blaise/actions/workflows/bootstrap.yml"]
2026-06-16 20:19:10 +03:00
2026-07-04 21:53:04 +03:00
**Pascal, который вы любите, переосмысленный для современной эпохи.**
2026-05-06 14:53:36 +03:00
2026-07-04 21:53:04 +03:00
Blaise — это компилятор Object Pascal нового поколения, созданный с нуля для устранения десятилетий устаревшего наследия. Он ставит во главу угла производительность разработчика, безопасность памяти и высокую производительность выполнения.
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
== ✨ Видение
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Экосистема Object Pascal имеет два варианта: Embarcadero Delphi (проприетарный, ориентированный на Windows) и Free Pascal (открытый исходный код, но несущий 30 лет накопленной сложности — пять режимов языка, пять строковых типов и тысячи файлов включений).
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Этот компилятор использует другой подход:
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
* *Один режим языка.* Без переключателей `{$mode}`; без поддержки устаревших диалектов.
* *Один строковый тип.* Строка UTF-8 с подсчётом ссылок и индексацией с 0. `RawBytes` для бинарных данных.
* *Одна модель памяти.* Автоматический подсчёт ссылок единообразно применяется к строкам, классам и интерфейсам. Нет разделения на ручное/автоматическое между `TObject` и `TInterfacedObject`; `[Weak]` разрывает циклы. `Free` сохранён как синоним для немедленного освобождения.
* *Чистые интерфейсы.* Без COM-идентификаторов GUID; диспетчеризация интерфейсов через таблицу виртуальных методов на этапе компиляции.
* *Реифицированные обобщения.* Мономорфизация на этапе компиляции — без стирания типов.
* *Современная система сборки.* PasBuild с `project.xml`; без makefile'ов.
* *Полноценный отладчик.* OPDF — формат отладки по умолчанию; DWARF не требуется.
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
См. link:docs/design.adoc[docs/design.adoc] для полной архитектуры и плана реализации.
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Результат — современный кроссплатформенный компилятор Object Pascal, генерирующий нативный код через два бэкенда: прямой генератор кода для x86-64 (по умолчанию с v0.12.0) и https://c9x.me/compile/[QBE] (опционально через `--backend qbe`). Один режим языка, один строковый тип, интерфейсы без GUID, реифицированные обобщения и полноценная поддержка формата отладки https://github.com/graemeg/opdebugger[OPDF] — включая полноценную отладку на уровне исходного кода для инкрементально компилируемых многомодульных программ.
2026-05-06 14:53:36 +03:00
2026-07-04 21:53:04 +03:00
== 🚀 Статус проекта
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
* **Самохостинг:** Да. Blaise загружается и перекомпилирует себя с точностью байт-в-байт. FPC больше не требуется — весь инструментарий работает на одном Blaise.
* **Тестирование:** Более 3800 тестов и их число растёт (разработка через тестирование с первого дня). Н а б о р тестов компилируется в Blaise.
* **Бэкенды:** Два бэкенда генерации кода — прямой нативный бэкенд для x86-64 (по умолчанию с v0.12.0) и QBE (опционально через `--backend qbe`). О б а проходят полный цикл фикспойнта и набор тестов.
* **Стандартная библиотека:** Растущая подключаемая стандартная библиотека — обобщённые коллекции, JSON (DOM + парсер + писатель), SHA-1 и Base64, GUID по RFC 4122, TCP-сокеты, WebSockets, минимальный HTTP/1.1 сервер и фреймворк для модульного тестирования `blaise.testing`.
2026-05-06 15:09:11 +03:00
[cols="1,3,1", options="header"]
|===
2026-07-04 21:53:04 +03:00
| Этап | Цель | Статус
2026-05-06 15:09:11 +03:00
| 1
2026-07-04 21:53:04 +03:00
| Конвейер загрузки — Hello World на Linux x86_64 через PasBuild
| Выполнен ✅
2026-05-06 15:09:11 +03:00
| 2
2026-07-04 21:53:04 +03:00
| Система типов — классы, записи, ARC, исключения
| Выполнен ✅
2026-05-06 15:09:11 +03:00
| 3
2026-07-04 21:53:04 +03:00
| Обобщения + интерфейсы без GUID
| Выполнен ✅
2026-05-06 15:09:11 +03:00
| 4
2026-07-04 21:53:04 +03:00
| Генерация отладочной информации OPDF
| Выполнен ✅
2026-05-06 15:09:11 +03:00
| 5
2026-07-04 21:53:04 +03:00
| Самохостинг
| Выполнен ✅
2026-05-06 15:09:11 +03:00
| 6
2026-07-04 21:53:04 +03:00
| Улучшения языка + расширение RTL и StdLib + исправление ошибок
| В процессе 🔄
2026-06-02 19:31:02 +03:00
| 7
2026-07-04 21:53:04 +03:00
| Паритет функций нативного бэкенда (бэкенд по умолчанию, внутренний ассемблер + компоновщик)
| Выполнен ✅
2026-06-02 19:31:02 +03:00
| 8
2026-07-04 21:53:04 +03:00
| Цели Windows + macOS ARM64
| Запланировано
2026-05-06 15:09:11 +03:00
2026-06-02 19:31:02 +03:00
| 9
2026-07-04 21:53:04 +03:00
| LSP + расширение для VS Code
| Запланировано
2026-06-24 01:36:38 +03:00
| 10
2026-07-04 21:53:04 +03:00
| Анализатор миграции для кодовых баз FPC/Delphi
| Запланировано
2026-05-06 15:09:11 +03:00
|===
2026-07-04 21:53:04 +03:00
== Что исключено из классического Pascal
2026-05-06 15:09:11 +03:00
[cols="1,3", options="header"]
|===
2026-07-04 21:53:04 +03:00
| Особенность | Причина удаления
2026-05-06 15:09:11 +03:00
| `ShortString`, `AnsiString`, `WideString`, `UnicodeString`
2026-07-04 21:53:04 +03:00
| Заменены единым строковым типом `string` в UTF-8 с подсчётом ссылок
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
| Оператор `with`
| Источник трудно диагностируемых ошибок разрешения символов; нарушает статический анализ
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
| Устаревшие типы `object`
| Используйте `record` (стек/значение) или `class` (куча/ссылка) вместо них
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
| Интерфейсные GUID в стиле COM
| Диспетчеризация интерфейсов через таблицу виртуальных методов на этапе компиляции; GUID — излишняя сложность
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
| Множественные режимы языка
| Один диалект, поддерживаемый хорошо, лучше, чем пять диалектов, поддерживаемых плохо
2026-05-06 15:09:11 +03:00
| `assign`, `reset`, `rewrite`, `blockread`
2026-07-04 21:53:04 +03:00
| Заменены RTL с потоковым вводом-выводом
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
| Разделение `TObject` и `TInterfacedObject`
| Единая модель классов с автоматическим подсчётом ссылок; `[Weak]` разрывает циклы
2026-05-06 15:09:11 +03:00
|===
2026-07-04 21:53:04 +03:00
== 📢 Сообщество
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
Базовая архитектура всё ещё дорабатывается, поэтому проект пока не принимает вклад в код. Обратная связь по дизайну языка, синтаксическим решениям и будущему направлению Blaise очень приветствуется — используйте вкладку https://github.com/graemeg/blaise/discussions[Discussions] на GitHub.
2026-05-06 15:09:11 +03:00
2026-07-04 21:53:04 +03:00
== Структура репозитория
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Этот проект использует многомодульную структуру PasBuild. Каждый подкаталог с `project.xml` является независимым модулем; корневой `project.xml` является агрегатором.
2026-04-20 16:22:10 +03:00
....
2026-07-04 21:53:04 +03:00
project.xml Корневой агрегатор (packaging=pom)
2026-04-20 16:22:10 +03:00
│
2026-07-04 21:53:04 +03:00
├── compiler/ Бинарный файл компилятора (packaging=application)
2026-04-20 16:22:10 +03:00
│ ├── project.xml
│ └── src/
2026-06-10 14:12:14 +03:00
│ ├── main/pascal/ uLexer, uParser, uAST, blaise.codegen.qbe, blaise.codegen.native.*, ...
2026-07-04 21:53:04 +03:00
│ └── test/pascal/ Н а б о р тестов (blaise.testing, компилируется Blaise)
2026-04-20 16:22:10 +03:00
│
2026-07-04 21:53:04 +03:00
├── runtime/ Время выполнения, всегда компонуется (packaging=library)
2026-04-20 16:22:10 +03:00
│ ├── project.xml
refactor: split rtl/ into runtime/ + stdlib/, rename bcl.testing to blaise.testing
Separate always-linked runtime code (system.pas, ARC, strings, platform
abstraction) from opt-in standard library units (sysutils, classes, math,
dateutils, generics, etc.). This mirrors the Go runtime/ vs stdlib, Rust
core vs std, and Swift SwiftRuntime vs SwiftCore patterns.
- runtime/ contains code linked into every binary + C shims
- stdlib/ contains units imported explicitly via uses clause
- Single platform abstraction layer (rtl.platform.*) in runtime/,
shared by both runtime/ and stdlib/ units
- bcl.testing renamed to blaise.testing across all 95+ test files
- Updated PasBuild project.xml, fixpoint.sh, README, unit search paths
- All 1931 tests pass, fixpoint OK (stage-3/stage-4)
2026-05-16 02:51:18 +03:00
│ ├── Makefile
2026-04-20 16:22:10 +03:00
│ └── src/
2026-07-04 21:53:04 +03:00
│ ├── main/asm/ Ассемблер для платформы (setjmp, атомарные операции, UTF-8)
refactor: split rtl/ into runtime/ + stdlib/, rename bcl.testing to blaise.testing
Separate always-linked runtime code (system.pas, ARC, strings, platform
abstraction) from opt-in standard library units (sysutils, classes, math,
dateutils, generics, etc.). This mirrors the Go runtime/ vs stdlib, Rust
core vs std, and Swift SwiftRuntime vs SwiftCore patterns.
- runtime/ contains code linked into every binary + C shims
- stdlib/ contains units imported explicitly via uses clause
- Single platform abstraction layer (rtl.platform.*) in runtime/,
shared by both runtime/ and stdlib/ units
- bcl.testing renamed to blaise.testing across all 95+ test files
- Updated PasBuild project.xml, fixpoint.sh, README, unit search paths
- All 1931 tests pass, fixpoint OK (stage-3/stage-4)
2026-05-16 02:51:18 +03:00
│ ├── main/pascal/ system.pas, blaise_str.pas, blaise_arc.pas, ...
2026-07-04 21:53:04 +03:00
│ └── test/pascal/ Тесты времени выполнения (punit, компилируются Blaise)
refactor: split rtl/ into runtime/ + stdlib/, rename bcl.testing to blaise.testing
Separate always-linked runtime code (system.pas, ARC, strings, platform
abstraction) from opt-in standard library units (sysutils, classes, math,
dateutils, generics, etc.). This mirrors the Go runtime/ vs stdlib, Rust
core vs std, and Swift SwiftRuntime vs SwiftCore patterns.
- runtime/ contains code linked into every binary + C shims
- stdlib/ contains units imported explicitly via uses clause
- Single platform abstraction layer (rtl.platform.*) in runtime/,
shared by both runtime/ and stdlib/ units
- bcl.testing renamed to blaise.testing across all 95+ test files
- Updated PasBuild project.xml, fixpoint.sh, README, unit search paths
- All 1931 tests pass, fixpoint OK (stage-3/stage-4)
2026-05-16 02:51:18 +03:00
│
2026-07-04 21:53:04 +03:00
├── stdlib/ Стандартная библиотека — подключается через uses
refactor: split rtl/ into runtime/ + stdlib/, rename bcl.testing to blaise.testing
Separate always-linked runtime code (system.pas, ARC, strings, platform
abstraction) from opt-in standard library units (sysutils, classes, math,
dateutils, generics, etc.). This mirrors the Go runtime/ vs stdlib, Rust
core vs std, and Swift SwiftRuntime vs SwiftCore patterns.
- runtime/ contains code linked into every binary + C shims
- stdlib/ contains units imported explicitly via uses clause
- Single platform abstraction layer (rtl.platform.*) in runtime/,
shared by both runtime/ and stdlib/ units
- bcl.testing renamed to blaise.testing across all 95+ test files
- Updated PasBuild project.xml, fixpoint.sh, README, unit search paths
- All 1931 tests pass, fixpoint OK (stage-3/stage-4)
2026-05-16 02:51:18 +03:00
│ ├── project.xml
│ └── src/
│ └── main/pascal/ sysutils.pas, classes.pas, math.pas, ...
2026-04-20 16:22:10 +03:00
│
├── tools/
2026-07-04 21:53:04 +03:00
│ └── migration-analyser/ Инструмент для отчётов по миграции из FPC/Delphi (packaging=application)
│ ├── project.xml зависит от модуля компилятора
2026-04-20 16:22:10 +03:00
│ └── src/
│ ├── main/pascal/
│ └── test/pascal/
│
2026-07-04 21:53:04 +03:00
├── vendor/qbe/ Исходный код бэкенда QBE (закреплённая версия, собирается из исходников)
└── docs/ Документы по дизайну и спецификации
2026-04-20 16:22:10 +03:00
....
2026-07-04 21:53:04 +03:00
PasBuild компилирует каждый модуль в свой подкаталог `target/`. Результаты сборки никогда не сохраняются в репозитории.
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
== Сборка
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
=== Предварительные требования
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
* Ранее выпущенный бинарный файл Blaise (см. `releases/`)
2026-04-20 16:22:10 +03:00
* https://github.com/graemeg/pasbuild[PasBuild]
2026-07-04 21:53:04 +03:00
* Компилятор C (`gcc` или `clang`) для сборки вендорского бэкенда QBE и компоновки
* GNU `make` для сборки времени выполнения
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
ПРИМЕЧАНИЕ: FPC *не* требуется. Blaise полностью самохостовый — каждый бинарник релиза компилирует следующую версию. Цепочка загрузки начинается с бинарника в `releases/`.
2026-05-13 02:47:34 +03:00
2026-07-04 21:53:04 +03:00
=== Загрузка из релиза
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Сборка времени выполнения компилирует свои модули Pascal (`blaise_str.pas`, `blaise_arc.pas`, `blaise_sys.pas`) с использованием бинарника Blaise по пути `compiler/target/blaise`. В чистом виде этого бинарника ещё нет, поэтому бинарник релиза должен быть передан явно через переменную make `BLAISE`.
2026-05-13 03:23:07 +03:00
2026-04-20 16:22:10 +03:00
[source,shell]
----
2026-07-04 21:53:04 +03:00
# Определить новейший бинарник релиза (подставьте путь вместо $RELEASE).
RELEASE=$(ls -d releases/v*/ | sort -V | tail -1)blaise # например releases/v0.12.0/blaise
feat(tests): re-enable 6 test units; fix static array and Pos semantics
Re-enabled cp.test.lexer, cp.test.parser, cp.test.codegen,
cp.test.symtable, cp.test.semantic, cp.test.records in TestRunner.pas —
all six were commented out when the test runner was migrated from FPC to
Blaise, reducing the suite from ~1433 to ~1376 tests.
Changes needed to make all six units compile and pass (1541 tests total):
- Remove leftover `Classes, SysUtils` imports from all six units (FPC
fpcunit era; Blaise has neither unit).
- Replace default-property bracket subscripts (TObjectList[i],
TStringList[i]) with explicit .Items[i] / .Strings[i] calls, since
Blaise does not yet implement the `default` indexed property keyword.
- codegen: add tyRecord branch in EmitStaticSubscriptAssign — record
elements in static arrays must use EmitRecordCopy, not a raw storew.
- codegen: add tyRecord early-return in EmitStringSubscriptExpr static
array branch — return element pointer directly (records are by-value
via pointer).
- codegen: fix EmitInstancePtr to delegate to EmitExpr when the field
access is property-backed (PropRead != nil), avoiding a nil FieldInfo
assertion.
- test: fix IRContains to use Pos(...) >= 0 (Blaise Pos is 0-based,
returns -1 on no-match, not 0 like FPC).
2026-05-13 17:54:50 +03:00
2026-07-04 21:53:04 +03:00
# 1. Собрать время выполнения с использованием бинарника релиза (BLAISE= предотвращает проблему курицы и яйца)
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
cd runtime && make BLAISE=../$RELEASE && make install && cd ..
2026-05-13 02:47:34 +03:00
2026-07-04 21:53:04 +03:00
# 2. Скомпилировать компилятор с использованием бинарника релиза (нативный бэкенд —
# по умолчанию с v0.12.0 — не требует внешнего ассемблера или QBE)
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
$RELEASE \
2026-05-13 02:47:34 +03:00
--source compiler/src/main/pascal/Blaise.pas \
--unit-path compiler/src/main/pascal \
refactor: split rtl/ into runtime/ + stdlib/, rename bcl.testing to blaise.testing
Separate always-linked runtime code (system.pas, ARC, strings, platform
abstraction) from opt-in standard library units (sysutils, classes, math,
dateutils, generics, etc.). This mirrors the Go runtime/ vs stdlib, Rust
core vs std, and Swift SwiftRuntime vs SwiftCore patterns.
- runtime/ contains code linked into every binary + C shims
- stdlib/ contains units imported explicitly via uses clause
- Single platform abstraction layer (rtl.platform.*) in runtime/,
shared by both runtime/ and stdlib/ units
- bcl.testing renamed to blaise.testing across all 95+ test files
- Updated PasBuild project.xml, fixpoint.sh, README, unit search paths
- All 1931 tests pass, fixpoint OK (stage-3/stage-4)
2026-05-16 02:51:18 +03:00
--unit-path runtime/src/main/pascal \
--unit-path stdlib/src/main/pascal \
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
--output compiler/target/blaise
2026-04-20 16:22:10 +03:00
----
2026-07-04 21:53:04 +03:00
После появления `compiler/target/blaise` последующие пересборки RTL (`make && make install`) работают без переопределения.
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
2026-07-04 21:53:04 +03:00
Нативный бэкенд (по умолчанию) генерирует и компонует бинарник напрямую — без внешних инструментов. Для загрузки через опциональный бэкенд QBE вместо этого соберите вендорский QBE один раз (`cd vendor/qbe && make`), добавьте `--backend qbe --emit-ir > /tmp/blaise.ssa` к шагу 2, затем `vendor/qbe/qbe -o /tmp/blaise.s /tmp/blaise.ssa` и `gcc -o compiler/target/blaise /tmp/blaise.s compiler/target/blaise_rtl.a`.
2026-05-13 03:23:07 +03:00
2026-07-04 21:53:04 +03:00
=== Загрузка из разработческой версии
2026-06-03 10:05:16 +03:00
2026-07-04 21:53:04 +03:00
Эта процедура работает, пока последний бинарник релиза достаточно новый, чтобы скомпилировать текущий исходный код. Между релизами это перестаёт работать: как только коммит добавляет новую возможность в парсер, а последующий коммит использует её в среде выполнения/компиляторе, бинарник релиза больше не может собрать `master` напрямую.
2026-06-03 10:05:16 +03:00
2026-07-04 21:53:04 +03:00
`scripts/rolling-bootstrap.sh` пересобирает цепочку коммит за коммитом, начиная с последнего бинарника релиза и до проверенной ревизии, создавая рабочий `-pre` бинарник загрузки. См. link:scripts/BOOTSTRAP.adoc[scripts/BOOTSTRAP.adoc] для предварительных требований (размещение бинарника релиза в `releases/`) и использования.
2026-06-03 10:05:16 +03:00
2026-07-04 21:53:04 +03:00
=== Сборка через PasBuild
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
PasBuild может управлять полным циклом компиляции и тестирования с использованием бинарника Blaise:
2026-04-20 16:22:10 +03:00
[source,shell]
----
2026-05-13 02:47:34 +03:00
pasbuild compile -m blaise-compiler --compiler compiler/target/blaise
pasbuild test -m blaise-compiler --compiler compiler/target/blaise
2026-04-20 16:22:10 +03:00
----
2026-07-04 21:53:04 +03:00
=== Запуск тестов
2026-04-20 16:22:10 +03:00
[source,shell]
----
2026-05-13 02:47:34 +03:00
pasbuild test -m blaise-compiler --compiler compiler/target/blaise
2026-04-20 16:22:10 +03:00
----
2026-07-04 21:53:04 +03:00
=== Проверка фикспойнта самохостинга
2026-05-13 02:47:34 +03:00
2026-07-04 21:53:04 +03:00
После любого изменения компилятора проверьте, что компилятор воспроизводит себя:
2026-04-20 16:22:10 +03:00
[source,shell]
----
2026-05-13 02:47:34 +03:00
./scripts/fixpoint.sh
2026-04-20 16:22:10 +03:00
----
2026-07-04 21:53:04 +03:00
Это генерирует промежуточное представление (IR) для этапов 2 и 3 и подтверждает их идентичность.
2026-05-13 02:47:34 +03:00
2026-07-04 21:53:04 +03:00
=== Запуск компилятора
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
После сборки бинарник компилятора находится по пути `compiler/target/blaise`.
2026-04-20 16:22:10 +03:00
[source,shell]
----
2026-07-04 21:53:04 +03:00
# Скомпилировать однострочную программу (нативный бэкенд — по умолчанию, без внешних инструментов)
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
compiler/target/blaise --source Hello.pas --output Hello
2026-07-04 21:53:04 +03:00
# Скомпилировать через опциональный бэкенд QBE (генерирует QBE IR, собирается и компонуется отдельно)
docs: update for v0.12.0 — native default, expanded stdlib, syntax additions
README.adoc:
- Native x86-64 is the default backend since v0.12.0; QBE is opt-in
(--backend qbe). Reframed the intro, project status, bootstrap, and
single-file compile examples accordingly (native one-step build leads; QBE
shown as the opt-in multi-step path).
- Test count 3474 -> 3800+ (3744 compiler + 57 stdlib).
- Added a Standard library status line (generics collections, JSON, SHA-1,
Base64, GUIDs, sockets, WebSockets, HTTP server, blaise.testing).
- Bootstrap example resolves the newest releases/v* binary instead of the
stale v0.7.0 path, and uses the native --output build.
- OPDF now debugs incrementally-compiled multi-unit programs.
grammar.ebnf (CLAUDE.md sync rule):
- TypeName accepts a unit-qualified, possibly-dotted QualIdent
(UnitName.TypeName, System.SysUtils.TFormatSettings).
- FieldAssignment l-value extended with a Selector chain
(.Field / [Index] / .Method(...)) so Self.F[i].Sub := value parses.
language-rationale.adoc:
- New entries "Qualified type names" and "Chained l-value assignment"
recording the decision, reasoning, and alternatives for the two
conservative FPC/Delphi-compatible parser extensions made this cycle.
2026-06-24 01:32:08 +03:00
compiler/target/blaise --source Hello.pas --backend qbe --emit-ir > Hello.ssa
2026-05-13 02:47:34 +03:00
vendor/qbe/qbe -o Hello.s Hello.ssa
gcc -o Hello Hello.s compiler/target/blaise_rtl.a
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
# Скомпилировать с путями поиска модулей
2026-05-13 02:47:34 +03:00
compiler/target/blaise --source MyApp.pas \
--unit-path src/units \
--emit-ir > MyApp.ssa
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
# Сгенерировать только QBE IR (полезно для отладки самого компилятора)
Phase 1 bootstrap: Blaise compiler skeleton
Renames the project from 'Clean Pascal' to Blaise (after Blaise Pascal).
Adds the Phase 1 compiler pipeline with TDD test suite:
- uPasTokeniser: general Pascal tokeniser (ported from fpGUI IDE)
- uLexer: compiler-specific adapter — filters whitespace/comments,
maps to TTokenKind, unescapes string literals
- uAST: typed AST node hierarchy (TProgram, TBlock, TBinaryExpr, etc.)
- uParser: recursive-descent parser for the Phase 1 BNF grammar
- uCodeGenQBE: QBE IR emitter — WriteLn/Write built-ins, integer
variables, arithmetic, string literals
- Blaise.pas: compiler driver — parses flags, shells to qbe+cc
- FPCUnit test suites for lexer, parser, and code generator
2026-04-20 17:35:50 +03:00
compiler/target/blaise --source Hello.pas --emit-ir
2026-04-20 16:22:10 +03:00
----
2026-07-04 21:53:04 +03:00
== Лицензия
2026-04-20 16:22:10 +03:00
2026-07-04 21:53:04 +03:00
Apache License v2.0 с исключением для библиотеки времени выполнения. См. link:LICENSE[LICENSE].
2026-05-06 14:53:36 +03:00
2026-07-04 21:54:44 +03:00
---