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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
570
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
CSC307 Lecture 02
javiergs
PRO
1
780
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
200
Raku Raku Notion 20260128
hareyakayuruyaka
0
180
Data-Centric Kaggle
isax1015
2
770
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
Implementation Patterns
denyspoltorak
0
290
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
53
Optimizing for Happiness
mojombo
379
71k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
420
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
780
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
120
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
360
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
• 自作インタプリタがプログラムを実行できるよ うになるので楽しい
まとめ • たのしい