Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Goでインタプリタつくった
Search
vortispy
March 05, 2017
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goでインタプリタつくった
"Writing An Interpreter In Go"
https://interpreterbook.com/
をよんでインタプリタつくった。ただそれだけの話。
vortispy
March 05, 2017
Other Decks in Programming
See All in Programming
contenteditable と日本語入力に向き合う
colorful12
0
200
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
sbt 2.0: takeoff
eed3si9n
0
160
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
490
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
490
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Optimising Largest Contentful Paint
csswizardry
37
4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Statistics for Hackers
jakevdp
799
230k
YesSQL, Process and Tooling at Scale
rocio
174
15k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
How to Ace a Technical Interview
jacobian
280
24k
Being A Developer After 40
akosma
92
590k
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
• 自作インタプリタがプログラムを実行できるよ うになるので楽しい
まとめ • たのしい