In a previous blog post, we looked at a simple one-pass compiler written in C. Now, let’s look at how we can design an abstract syntax tree and work with it. An abstract syntax tree (or an AST) is a tree-shaped representation of source code that is convenient for a compiler to operate. A compiler might represent an expression like 4 + 2 * 10 + 3 * (5 + 1) using a tree structure like this: Figure 1
Notes by djb on using Fil-C (2025) I'm impressed with the level of compatibility of the new memory-safe C/C++ compiler Fil-C (filcc, fil++). Many libraries and applications that I've tried work under Fil-C without changes, and the exceptions haven't been hard to get working. I've started accumulating miscellaneous notes on this page regarding usage of Fil-C. My selfish objective here is to protect
アイキャッチ画像 「日本語で記述できるプログラミング言語「お抹茶」を作りながら学ぶインタプリタの仕組み」 はじめに プログラミング言語って自分で作れるの?と思っていた僕ですが、実はインタプリタ型の簡単な言語なら意外と作れることがわかりました。 今回は「お抹茶」という日本語で書けるプログラミング言語を作ってみたので、その実装方法を紹介します。 インタプリタ言語を作るのに必要な3つの要素 プログラミング言語を作るというと難しそうですが、実は基本的な仕組みは意外とシンプルです。インタプリタ型言語を作るには、以下の3つの要素が必要になります。 1. トークナイザー(字句解析器) ソースコードを「トークン」と呼ばれる最小単位に分解する部分です。例えば 定義 x = 10 というコードを ["定義", "x", "=", "10"] のような配列に変換します。人間が読む文章を単語単位に区切るようなイメ
Table of contents for my series on building a WASM compiler in Roc: Part 1 - Project Introduction (Roc and Wasm) Part 2 - Arguments and IO in Roc Part 3 - Tokenizer boilerplate Part 4 - Errors and positions in tokenizer Part 5 - Testing and tokenizing Part 6 - Introduction to Parsing Part 7 - Refactoring with confidence (more parsing) Part 8 - Introduction to Transforming Part 9 - Transforming Mem
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く