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
Parsing for Humans
Search
Yorick Peterse
May 20, 2014
Programming
2
90
Parsing for Humans
Presentation for the Amsterdam Ruby user group.
Yorick Peterse
May 20, 2014
Tweet
Share
More Decks by Yorick Peterse
See All by Yorick Peterse
Garbage Collection Crash Course
yorickpeterse
1
360
Making GitLab Faster
yorickpeterse
2
450
Rubinius & The Eternal Yak
yorickpeterse
1
250
Oga
yorickpeterse
3
190
Other Decks in Programming
See All in Programming
Scaling your build logic
antalmonori
1
130
functionalなアプローチで動的要素を排除する
ryopeko
1
750
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
2.1k
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
150
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
180
CloudNativePGがCNCF Sandboxプロジェクトになったぞ! 〜CloudNativePGの仕組みの紹介〜
nnaka2992
0
140
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
450
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
1
170
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
2
7.8k
Azure AI Foundryのご紹介
qt_luigi
1
240
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
130
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
140
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
510
110k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
A Philosophy of Restraint
colly
203
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
52k
Facilitating Awesome Meetings
lara
51
6.2k
Typedesign – Prime Four
hannesfritz
40
2.5k
Music & Morning Musume
bryan
46
6.3k
Producing Creativity
orderedlist
PRO
343
39k
Transcript
Parsing For Humans
@yorickpeterse (Github, Twitter, Gmail, etc)
Olery http://olery.com/
Parsing “Analysing a string of symbols according to the rules
of a grammar.”
10 + 10
number = [0-9]+ operator = “+”
Vocabulary Token, AST, Lexer & Parser
Token A label for a specific part of the input.
10 [:INTEGER, “10”]
Abstract Syntax Tree A tree structure representing the input.
Markdown Lists * Item * Nested item
(unordered-list (list “Item” (unordered-list (list “Nested item”))))
Lexer Takes raw input and returns a sequence of tokens.
Parser Takes tokens as input and returns an AST.
Available Tools
ANTLR, Bison, Coco/R, Flex, Happy, Lemon, jQuery, Parslet, Racc, Ragel,
Rexical, Treetop, Yacc
Ragel & Racc
Ragel “A finite state machine compiler.”
“<!--” any* “-->” => { … };
$ ragel -R lexer.rl -o lexer.rb
Racc “A LALR(1) parser generator.”
expression : NUMBER OPERATOR NUMBER { … } ;
$ racc -o parser.rb parser.y
Oga Parsing XML/HTML in Ruby https://github.com/yorickpeterse/oga
Questions?