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
Proglrの紹介
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tkob
March 31, 2018
530
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Proglrの紹介
tkob
March 31, 2018
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Prompt Engineering for Job Search
mfonobong
0
520
ラッコキーワード サービス紹介資料
rakko
1
5.3M
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Discover your Explorer Soul
emna__ayadi
2
1.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Facilitating Awesome Meetings
lara
57
7.2k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
Transcript
Proglrの紹介 tkob https://github.com/tkob/proglr
SMLと私 • ML-MessagePack https://github.com/tkob/mlmsgpack • UXML https://github.com/tkob/uxml – XML Parser
• SMLZIP https://github.com/tkob/smlzip – Access to ZIP files • 最近の活動 – SMLでsyslogdを作っています
Proglrの紹介 • SML向けのパーサージェネレーター – 私が作りました • BNFC互換のLBNFからパーサーとASTを生成 • Generalized LR
• 生成したパーサーが多くのSML処理系で使える
BNFC互換のLabelled BNF文法定義 token Add "+" ; … token Integer of
int; EAdd. Exp ::= Exp "+" Exp1 ; ESub. Exp ::= Exp "-" Exp1 ; EMul. Exp1 ::= Exp1 "*" Exp2 ; EDiv. Exp1 ::= Exp1 "/" Exp2 ; EInt. Exp2 ::= Integer ; coercions Exp 2 ;
生成されるAST structure Ast = struct datatype exp = EAdd of
Lex.span * exp * exp | ESub of Lex.span * exp * exp | EMul of Lex.span * exp * exp | EDiv of Lex.span * exp * exp | EInt of Lex.span * int …
生成されるパーサー(概略イメージ) fun go … = … and state15 … =
… … (* stateNが続く *) and state0 … = … fun parse sourcemap strm = … (* go を呼ぶ *) • 相互末尾再帰関数で状態を表現する – 読めなくもない気分のコード
parseの型 val parse : sourcemap -> strm -> Ast.exp list
• 何故Ast.expでなくAst.exp listなのか – 多義的な文法かもしれない(文脈自由文法) – ProglrはGeneralized LRを使用
なぜGLRなのか • あまり深い理由は… – 自分のパーサージェネレーターがほしい! – 教科書を読みながらまずはLR(0)まで作成 • 面倒くさくなってきた –
手っ取り早く表現力をあげられないか? – LR(0)ベースのGLRにするのが一番はやい(と思った)
Q: Proglrは私のSMLコンパイラで使えますか? • A: きっと… – 対応処理系: • SML/NJ, MLton,
Poly/ML, Alice ML, MLKit, Moscow ML, SML# – Proglr自体はMLtonかPoly/MLでビルドするのがおすすめ
Proglrの利用方法(MLton) $ proglr -m mlton -o parse.sml -l scan.ulex calc.cf
$ mlton main.mlb $ ./main sample.txt • -mオプションで処理系を指定するとプロジェクト一式 (MakefileやMLBやCM)が全部生成される • 用意するのは文法だけ
おわり • 大体全部の現存SML処理系で使えるパーサージェネレー ターのProglrを紹介しました