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
How to Write Parser in PHP
Search
Jan Tvrdík
April 12, 2018
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How to Write Parser in PHP
Jan Tvrdík
April 12, 2018
More Decks by Jan Tvrdík
See All by Jan Tvrdík
Runtime Types in TypeScript
jantvrdik
0
62
Writing Readable Migrations with Nextras Migrations
jantvrdik
1
120
Nextras Mail Panel
jantvrdik
0
170
Writing reliable migrations with Nextras Migrations
jantvrdik
1
710
Other Decks in Programming
See All in Programming
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
120
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
関数型プログラミングのメリットって何だろう?
wanko_it
0
140
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
1.8k
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
140
dRuby over BLE
makicamel
2
410
初めてのKubernetes 本番運用でハマった話
oku053
0
120
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
290
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
3.9k
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
1
110
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
410
The Invisible Side of Design
smashingmag
301
52k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Being A Developer After 40
akosma
91
590k
30 Presentation Tips
portentint
PRO
1
340
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
A designer walks into a library…
pauljervisheath
211
24k
Ruling the World: When Life Gets Gamed
codingconduct
0
270
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
380
Transcript
Jan Tvrdík
None
None
process of splitting text into words The square is blue
. The square is blue.
process of organizing sequence of words into structure The square
is blue .
The square is blue . D N V A NP
VP S
process of given meaning to the word structure
normally done by simple state machine fastest state machine in
PHP = PCRE
None
None
can be optimized to a single preg_* call by using
a smart trick David Grudl has taught me
None
ready to use lexer = nette/tokenizer
always start by writing a grammar EBNF simple not standardized
ABNF slightly less friendly than EBNF standardized by IETF PEG the coolest not standardized
multiple approaches possible easiest to start with is recursive descent
parser because it matches the grammar
JsonValue = JsonBool / JsonNull / JsonNumber / JsonString /
JsonArray / JsonObject JsonBool = TokenTrue / TokenFalse JsonNull = TokenNull
JsonNumber = TokenNumber JsonString = TokenString JsonArray = TokenSquareBracketOpen JsonArrayItems?
TokenSquareBracketClose JsonArrayItems = JsonValue (TokenComma JsonValue)* ...
None
Twitter + GitHub @JanTvrdik