Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goでインタプリタつくった
Search
vortispy
March 05, 2017
Programming
0
290
Goでインタプリタつくった
"Writing An Interpreter In Go"
https://interpreterbook.com/
をよんでインタプリタつくった。ただそれだけの話。
vortispy
March 05, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
Advanced Micro Frontends: Multi Version/ Framework Scenarios @WAD 2025, Berlin
manfredsteyer
PRO
0
390
CDK引数設計道場100本ノック
badmintoncryer
2
460
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
960
リバースエンジニアリング新時代へ! GhidraとClaude DesktopをMCPで繋ぐ/findy202507
tkmru
3
890
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
600
ご注文の差分はこちらですか? 〜 AWS CDK のいろいろな差分検出と安全なデプロイ
konokenj
3
560
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
790
テスターからテストエンジニアへ ~新米テストエンジニアが歩んだ9ヶ月振り返り~
non0113
2
220
レトロゲームから学ぶ通信技術の歴史
kimkim0106
0
110
Agentic Coding: The Future of Software Development with Agents
mitsuhiko
0
130
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
240
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
460
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
Writing Fast Ruby
sferik
628
62k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
108
19k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Embracing the Ebb and Flow
colly
86
4.8k
Bash Introduction
62gerente
613
210k
Code Review Best Practice
trishagee
69
19k
Transcript
Goでインタプリタつくった @vortispy
概要 • “Writing An Interpreter In Go”を読んでインタプ リタつくった • Go言語しか使わない
• GotoutineやChannelは使わない • 難しいことは気にせずとりあえず作ってみる
なにやった • 字句解析(Lexing) • 構文解析(Parsing) • 評価(Evaluation)
字句解析 • 文字列をTokenに変換する • “let a = 1;” → <LET><IDENT><ASSIGN><INT><SEMICOLO
N>
構文解析 • ここが山場 • TokenからAST(Abstract syntax tree)をつくる
let a = 1; if (a > 10) { return
a; } <LET><IDENT><ASSING><INT><SEMICOLON> <IF><IDENT><GT><INT><LBRACE> <RETURN><IDENT><SEMICOLON> <RBRACE>
None
• 使うアルゴリズムは“Top Down Operator Precedence”(Pratt parser)
評価 • ASTを解釈して実行する • どのように解釈させるか? • 例: “foo” * 3
• Python: “foofoofoo” • Go: cannot convert "foo" to type int invalid operation: "foo" * 3
• 自作インタプリタがプログラムを実行できるよ うになるので楽しい
まとめ • たのしい