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
Niyarin
November 26, 2020
Programming
420
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Gorgos-parser-combinator-written-in-scheme
Schemeでパーサコンビネータを作りました
Niyarin
November 26, 2020
More Decks by Niyarin
See All by Niyarin
Scheme用nREPLの開発(エラー出力の改善)
niyarin
0
190
bel lispの紹介
niyarin
0
790
nanopass-compiler-frameworkを使ってみました
niyarin
0
490
outputting-beautiful-s-expression
niyarin
0
420
Serialisp
niyarin
1
740
Mongo DBとS式検索
niyarin
0
360
goodbye-python-repl
niyarin
0
400
SchemeのEphemeronとWeak Pairの説明
niyarin
0
1.1k
red-paren-scheme-rev-macro.pdf
niyarin
0
460
Other Decks in Programming
See All in Programming
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
210
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
源内ハンズオン概要編
hideg
0
150
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.1k
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
320
仕様駆動開発の消費期限
watany
19
7.6k
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
180
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.4k
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
React本体のコードリーディング
high_g_engineer
1
140
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
550
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
210
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
56k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
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文字先読み