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
楽にコンパイラを書く話
Search
Yuya Kono
May 19, 2019
Programming
1
99
楽にコンパイラを書く話
Yuya Kono
May 19, 2019
Tweet
Share
More Decks by Yuya Kono
See All by Yuya Kono
自作プログラミング言語Malgoの紹介
takoeight0821
0
190
プログラミングの暗黙知
takoeight0821
0
87
git logで振り返る大学4年間
takoeight0821
1
190
自作言語にモジュールを実装した話
takoeight0821
0
410
量子コンピュータで乱数を生成した話
takoeight0821
1
270
自作言語コンパイラを作った話
takoeight0821
0
180
自作言語malgoのコンパイラをリファクタリングした話
takoeight0821
0
350
今日から始める自作コンパイラ ver 0.0.1
takoeight0821
0
1.1k
Language Server Protocolの話
takoeight0821
0
440
Other Decks in Programming
See All in Programming
WebRTC と Rust と8K 60fps
tnoho
0
220
How Software Deployment tools have changed in the past 20 years
geshan
0
14k
開発生産性が組織文化になるまでの軌跡
tonegawa07
0
190
dnx で実行できるコマンド、作ってみました
tomohisa
0
110
GraalVM Native Image トラブルシューティング機能の最新状況(2025年版)
ntt_dsol_java
0
170
Feature Flags Suck! - KubeCon Atlanta 2025
phodgson
0
170
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
5
2.2k
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
500
Herb to ReActionView: A New Foundation for the View Layer @ San Francisco Ruby Conference 2025
marcoroth
0
200
CSC509 Lecture 13
javiergs
PRO
0
260
最新のDirectX12で使えるレイトレ周りの機能追加について
projectasura
0
300
[SF Ruby Conf 2025] Rails X
palkan
0
370
Featured
See All Featured
The Language of Interfaces
destraynor
162
25k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.1k
Designing Experiences People Love
moore
142
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.2k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Building an army of robots
kneath
306
46k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Mobile First: as difficult as doing things right
swwweet
225
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
118
20k
Transcript
ָʹίϯύΠϥΛॻ͘ ʹΌʔΜʢ!UBLPFJHIUʣ
ϓϩάϥϛϯάݴޠ ࡞ͬͯ·͢
ࣗ࡞ݴޠ͋Δ͋Δ Α͋͘Δޡղฤ ͍͘͢͜͝͠ͱΛ͍ͯ͠ΔͱࢥΘΕΔ ಄͕͓͔͍͠ਓͩͱࢥΘΕΔ 3VCZ͖ͩͱࢥΘΕΔ
ࣗ࡞ݴޠ͋Δ͋Δ Α͋͘Δޡղฤ ͍͘͢͜͝͠ͱΛ͍ͯ͠ΔͱࢥΘΕΔ ಄͕͓͔͍͠ਓͩͱࢥΘΕΔ 3VCZ͖ͩͱࢥΘΕΔ ਖ਼͍͠ͷ͚ͩ ͍͘͢͝͠Θ͚Ͱͳ͍
ίϯύΠϥͱ w ݴޠ"͔Βݴޠ#ͷมϓϩάϥϜ w #ΞηϯϒϦݴޠωΠςΟϒίϯύΠϥ w "#ͷͭ͋Δɻ#BCFMͱ͔ w ෳͷมॲཧΛ࿈݁ͨ͠ͷ͕΄ͱΜͲ w
ιʔείʔυΛநߏจʹม w நߏจΛதؒදݱʹม w தؒදݱΛతίʔυʹม
ίϯύΠϥͷ͠͞ w ιʔείʔυͱతίʔυͷΪϟοϓ͕େ͖͍΄Ͳ͍͠ w $ ˠΞηϯϒϦݴޠ͍͠ w ࠷దԽίϯύΠϥ͍͠ w ߴڃݴޠͷίϯύΠϥΘΓͱ؆୯
ྫ w ύλʔϯϚον͕͋Δݴޠ͔Β$ʹม͢ΔίϯύΠϥ w $ʹม͢Εɺ࠷దԽͱ͔$ίϯύΠϥ͕ؤுͬͯ ͘ΕΔ
ύλʔϯϚονͬͯʁ type Result = Ok(int) | Err(string) match input {
Ok(value) => return value, Err(_) => error("something bad happend"), } ͜Μͳͷɻ ༩͑ΒΕͨ JOQVU ͷܗʹԠͯ͡ذ͢Δɻ 3FTVMUͷఆٛ$ʹม͠ͳ͍ͱ͍͚ͳ͍ɻ
࡞ઓ w ܕλά͖ڞ༻ମʹม͢Δ w 0Lˠ &SSˠͰλά͚͢Δ w NBUDINBUDI@UBHʹม͢Δ
ܕͷม struct Result { int tag; union { int val_0;
string val_1; }; } int Ok = 0; int Err = 1; ܕ$ʹมͰ͖ͨɻ
NBUDI@UBHʹม match_tag (input, Ok) { value = input.val_0; return value;
} else match_tag (input, Err) { _ = input.val_1; error("something bad happend"); } NBUDI@UBHୈҰҾͷUBH͕ୈೋҾʹ͚͠Εଓ͘ ϒϩοΫΛ࣮ߦ͢ΔɻJGͷѥछɻ
$ʹม struct Result { int tag; union { int val_0;
char* val_1; } }; int Ok = 0; int Err = 1; if (input.tag == Ok) { int value = input.val_0; return value; } else if (input.tag == Err) { error("something bad happened"); }
·ͱΊ w ίϯύΠϥݴޠ"͔Βݴޠ#ͷมϓϩάϥϜ w Ұؾʹతݴޠʹม͢Δͱ͍͠ɻதؒදݱΛ͏·͘ ͏ͱ͙ͬͱָʹͳΔ