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
“A ::= aAa / a” in PEG
Search
Masaki Hara
June 09, 2013
Programming
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
“A ::= aAa / a” in PEG
さっき考えてたことのメモ
Masaki Hara
June 09, 2013
More Decks by Masaki Hara
See All by Masaki Hara
文字コードの話
qnighy
47
21k
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
9
2.6k
Dockerfileの考え方
qnighy
50
20k
Arm移行タイムアタック
qnighy
1
770
Quine, Polyglot, 良いコード
qnighy
5
930
Prolog入門
qnighy
5
3.1k
Rubyのobject_id
qnighy
8
1.9k
Getting along with YAML comments with Psych
qnighy
2
3.2k
状態設計から「なんとなく」を無くそう
qnighy
90
30k
Other Decks in Programming
See All in Programming
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
130
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
330
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1k
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Designing for Timeless Needs
cassininazir
1
530
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Optimising Largest Contentful Paint
csswizardry
37
4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Faster Mobile Websites
deanohume
310
32k
HDC tutorial
michielstock
2
960
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
Transcript
“A ::= aAa / a” in PEG Masaki Hara さっき考えてたことのメモ
PEG • 手前から順番に試す • 文字列の一部分と一致したらそこで停止
PEG • 手前から順番に試す • 文字列の一部分と一致したらそこで停止 • 病的な例が知られている
PEGの病的な例 • “a := aAa / a” というルールを考える
PEGの病的な例 • “a := aAa / a” というルールを考える – 直感的にはaが奇数個並んだ文字列にマッチ
PEGの病的な例 • “a := aAa / a” というルールを考える – 直感的にはaが奇数個並んだ文字列にマッチ
– 実際はaが(2^n-1)個並んだ文字列にマッチ
PEGの病的な例の解析 • ここでは、文字列の後ろ側から順番に解析し てみる – 実際は手前から再帰的に試す
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a × aAaを試そうと するが失敗
a a a a a a a A ::= aAa
| a ◦ aを試す →成功
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a ×
a a a a a a a A ::= aAa
| a ◦ aにマッチ
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a ◦ aAaにマッチ
a a a a a a a A ::= aAa
| a aAaにマッチしてしまった のでaにはマッチしない
a a a a a a a A ::= aAa
| a A=aaaと決まっているので aaaaaにマッチしようとする →失敗
a a a a a a a A ::= aAa
| a ×
a a a a a a a A ::= aAa
| a ◦
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a ◦
a a a a a a a A ::= aAa
| a aaaにマッチ →全体にマッチしない (∴5文字は×)
a a a a a a a A ::= aAa
| a
a a a a a a a A ::= aAa
| a 7文字は◦
a a a a a a a A ::= aAa
| a 0 1 2 3 4 5 6 7
位置 マッチ先 1 0 2 1 3 0 4 3
5 2 6 1 7 0
位置 マッチ先 1 0 2 1 3 0 4 3
5 2 6 1 7 0 aAaにマッチする時 →数字が1減る
位置 マッチ先 1 0 2 1 3 0 4 3
5 2 6 1 7 0 aにマッチする時 →直後を参照
結論 • (2^n-1)個のaにマッチすることがわかった