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
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
200
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
Oxlint JS plugins
kazupon
1
950
CSC307 Lecture 04
javiergs
PRO
0
660
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
620
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
2026年 エンジニアリング自己学習法
yumechi
0
130
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
970
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
GitHub's CSS Performance
jonrohan
1032
470k
A Soul's Torment
seathinner
5
2.3k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
220
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
200
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
66
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
The agentic SEO stack - context over prompts
schlessera
0
640
Product Roadmaps are Hard
iamctodd
PRO
55
12k
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
• 自作インタプリタがプログラムを実行できるよ うになるので楽しい
まとめ • たのしい