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
220
電卓アプリで再帰降下法を使った話
nakawai
May 27, 2018
Tweet
Share
More Decks by nakawai
See All by nakawai
AI駆動プロダクト開発で最速価値検証
nakawai
0
250
エンジニアがエンジニアリングマネージャーになって最初にやったこと
nakawai
2
1.1k
AndroidでTensorflow
nakawai
0
35
AndroidでSRCNN(超解像ニューラルネットワーク) 2017
nakawai
0
36
Androidで超解像ニューラルネットワークできる?
nakawai
0
54
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Language of Interfaces
destraynor
156
24k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
490
Typedesign – Prime Four
hannesfritz
41
2.6k
Making the Leap to Tech Lead
cromwellryan
133
9.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
134
33k
How STYLIGHT went responsive
nonsquared
99
5.4k
Become a Pro
speakerdeck
PRO
27
5.2k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Being A Developer After 40
akosma
90
590k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
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
電卓アプリで 再帰降下法を使った話 以上