A few months ago, I set myself the challenge of writing a C compiler in 500 lines of Python1, after writing my SDF donut post. How hard could it be? The answer was, pretty hard, even when dropping quite a few features. But it was also pretty interesting, and the result is surprisingly functional and not too hard to understand! There's too much code for me to comprehensively cover in a single blog
The prototypical compilers textbook is: 600 pages on parsing theory. Three pages of type-checking a first-order type system like C. Zero pages on storing and checking the correctness of declarations (the “symbol table”). Zero pages on the compilation model, and efficiently implementing separate compilation. 450 pages on optimization and code generation. The standard academic literature is most use
低レイヤを知りたい人のためのCコンパイラ作成入門 まさに低レイヤのことが分かっておらず、以前から気になっていたこの本。取り掛かってみたところ思いのほかスイスイ進められて、勢いに乗ってセルフホスト(自分が書いたコンパイラで自分自身をコンパイルするところ)までいけたので記念に書いておく。正確には C コンパイラのサブセットです。 GitHub - motemen/mocc 全体的な進め方は、 上記の本の通りに進めていく。 それ以降は自作の 8queen が普通に書けるように機能を強化。 それ以降はセルフホストを目標に進める。 プリプロセッサやリンカは作らず、C からアセンブリまで。 という感じ。自分は手を動かさないと進んでる気がしないので、まずは書いてみつつわからない所があれば調べる、というスタンスでいく。 あと、せっかくなので RISC-V の勉強もしたかったのでこれ向けに書く。なので実行は
academic, developer, with an eye towards a brighter techno-social life [prev] [next] 2021-08-14 Let's write a compiler, part 1: Introduction, selecting a language, and doing some planning All source code for this blog post can be found here. I think we all knew this might be coming once we finished up with our assembler. While we can in theory solve any computable problem by writing the appropriat
(To follow my compiler related posts, either subscribe to my main RSS feed, or the compiler specific one ) Back in March 2008 I started publishing a series on how to write a compiler in Ruby, bottom up, that is, starting with the code generator and working my way up instead of the more traditional approach of writing the parser first. Here are the parts I've published on my blog so far. (The bits
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く