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
Gorgos-parser-combinator-written-in-scheme
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Niyarin
November 26, 2020
Programming
410
0
Share
Gorgos-parser-combinator-written-in-scheme
Schemeでパーサコンビネータを作りました
Niyarin
November 26, 2020
More Decks by Niyarin
See All by Niyarin
Scheme用nREPLの開発(エラー出力の改善)
niyarin
0
180
bel lispの紹介
niyarin
0
780
nanopass-compiler-frameworkを使ってみました
niyarin
0
470
outputting-beautiful-s-expression
niyarin
0
410
Serialisp
niyarin
1
720
Mongo DBとS式検索
niyarin
0
360
goodbye-python-repl
niyarin
0
390
SchemeのEphemeronとWeak Pairの説明
niyarin
0
1.1k
red-paren-scheme-rev-macro.pdf
niyarin
0
450
Other Decks in Programming
See All in Programming
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.3k
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
140
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
190
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
240
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
120
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
0
110
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
130
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
290
Explore CoroutineScope
tomoeng11
0
130
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
250
CDK Deployのための ”反響定位”
watany
5
910
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
270
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Code Review Best Practice
trishagee
74
20k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Transcript
Parser combinator (written in Scheme) 「Gorgos」 Niyarin
Schemeでparser combinator を作った ・私はパーサに関しては素人です ・文字列を入れるとSchemeオブジェクトを返す手続きを作成する (Scheme手続きを組み合わせて)
返り値は多値 ・”受理したもの”と、”のこりの文字列”が返る ・文字aのパーサに”abcdef”を入れると、 受理した#\aと残りの”bcdef”が返る
“ab”を受け取るパーサ1 ・”gchar”を2回使って実装する
“ab”を受け取るパーサ2 ・よく使いそうなものは楽できるような部品が提供されている 特定の文字列を受け取るパーサ “gstring”
リストを意識したパーサコンビネータ1 ・gorgosはリストを返すことを意識した作りになっている ・受理→ 変換の”変換”を簡潔に書くため リストリーダの例
リストを意識したパーサコンビネータ2 ・なるべく変換を手抜きしたいので、gpairというpairを返すも のも作った ab…. を受け取る例
Schemeにcharsetがあって楽できた ・Schemeには文字の集合というデータ構造がある (SRFI 14) or (scheme charset) ・charsetに含まれているかどうかの部分だけでよかった ・組み込みも充実している char-set:upper-case
char-set:digit char-set:whitespace など
macro/手続きでありがちなやつ ・glistは最初は手続きだった → piyo-parserがfoo-parserの前に来ていないとだめ (右)再帰する場合もlambdaで囲わないと再帰できない ・parserを受け取るものをすべてマクロに書き換えた ・applyとかに渡すことができなくなったので、glist-fという関数版も用意 した
未完成な部分 ・文字列→ Scheme objectはできている ・今作り込んでいる部分 1.エラー表示 2.1文字先読みだけでいけるように変換orチェックする対応 port (fileストリームなど)から使えるようにしたい 1文字先読み