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
nakawai
May 27, 2018
0
200
電卓アプリで再帰降下法を使った話
nakawai
May 27, 2018
Tweet
Share
More Decks by nakawai
See All by nakawai
エンジニアがエンジニアリングマネージャーになって最初にやったこと
nakawai
2
1.1k
AndroidでTensorflow
nakawai
0
30
テンプレート作ると爆速Android 開発できる?
nakawai
0
24
AndroidでSRCNN 2017
nakawai
0
32
Android開発の罠と、その避け方
nakawai
0
30
AndroidでSRCNNできる?
nakawai
0
49
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
960
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Site-Speed That Sticks
csswizardry
4
380
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
51k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
Transcript
電卓アプリで 再帰下降構文解析を 使った話 かものはし 2018/5/27 @kawai
どんな電卓?
デモ
1. 式の計算 2. 式の編集 3. 式の参照 要件
行計算できる 電卓
「式」の計算
“3+4” ↓ 3 + 4 ↓ 7
“√4+(3-15)” ↓ √4+(3-15) ↓ 2+-12
“100+8%” ↓ 100+(100×0.08) ↓ 100+8
“100×÷8” ↓ 無効な式
構文解析が必要
式の文字列から結果を導くには 1. トークンに分解 2. 処理用にパース 3. パース結果を処理
↑をトークンに分解 √4+(3-15)
√4+(3-15) 4 √ + - 3 15 ) (
処理用にパース
アルゴリズム
・操車場アルゴリズム(Shunting Yard Algorithm ) 中置 → 後置(逆ポーランド記法) ・再帰降下法 中置 → 構文木 → 評価
- 3 5 - 3 5 - 3 5 操
車 場 再帰降下法
- 3 15 4 √ + - 3 15 )
( √ 4 +
実装など
Evaluater Parser Tokenizer ParserTest EvaluaterTest Unit Test TokenizerTest Core Logic
電卓アプリで 再帰降下法を使った話 以上