Proposal: Nanopass compiler support
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 領域
- compilers
調査の方向性
提案と、そこからリンクされている Nanopass の学位論文および Racket のドキュメントから始めます。この issue では Langkit のファイル、テスト、エントリポイントが一切挙げられていません。完了するには、中間言語、パス、変換、検証、パイプライン、生成される Ada スタブについて合意された設計が必要であり、その後で実装のスコープを定めることができます。
索引モデルが issue の本文から書いたものです。
説明
This is a proposal for adding support for building Nanopass compilers to Langkit (most likely in a fork rather than something that will ever be upstreamed). I'm looking to get some feedback on this from other Langkit users to help refine this idea before I start implementing this. For some background on Nanopass compilers, refer to the following:
In short, from the second document:
The nanopass framework provides a tool for writing compilers composed of several simple passes that operate over well-defined intermediate languages. The goal of this organization is both to simplify the understanding of each pass, because it is responsible for a single task, and to simplify the addition of new passes anywhere in the compiler.
Currently it is entirely possible to write a Nanopass compiler using Langkit by manually writing a series of transformations, however this involves a lot of boilerplate, especially if one wants to formally define and check intermediate languages. I propose the addition of a set of new Langkit constructs to easily and formally define intermediate languages, pipelines, and transformers. I imagine this would look something like the following:
language parsed_foolang from grammar foolang_grammar;
language flat_foolang extends parsed_foolang {
remove BlockStatement;
}
pass flatten_blocks : parsed_foolang -> flat_foolang
with Libfoolang.Nanopass.Passes.Flatten_Blocks;
where Libfoolang.Nanopass.Passes.Flatten_Blocks is an Ada package with a Transform functions which takes some kind of rewriting handle. Langkit would generate the stub for this package.
In addition to remove, which makes a node invalid to have in a language, we would also have add to make a node valid and replace to change the shape of a node. I'm not sure exactly what this would look like yet.
Langkit would also be able to generate a pipeline function which calls a series of passes and checks that the outputs are valid between then.
That's about all I have on this idea for now, I plan to start prototyping it after I finish some other projects. Any ideas on how to design this are welcome.
- 主要言語
- Ada
- スター
- 94
- フォーク
- 34
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AdaCore/langkit のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
AdaCore/langkit の issue をすべて見る
似ている issue
-
`String.Parser.chompUntilEndOr` leaves the column one short when it runs to the end past a newline オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
enhancement PyCDE
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
llvm:support
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
llvm/llvm-project#226296 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
abseil/abseil-cpp#2176 ·