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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
65
Writing Readable Migrations with Nextras Migrations
jantvrdik
1
120
Nextras Mail Panel
jantvrdik
0
180
Writing reliable migrations with Nextras Migrations
jantvrdik
1
710
Other Decks in Programming
See All in Programming
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
180
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
300
「人を評価する AI」の設計と実装
ryoyanara
0
180
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
メールのエイリアス機能を履き違えない
isshinfunada
0
220
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
330
AIが無かった頃の素敵な出会いの話
codmoninc
1
390
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
190
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
580
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
160
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
450
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.9k
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
400
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
420
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Google's AI Overviews - The New Search
badams
0
1.1k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
620
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
430
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
Darren the Foodie - Storyboard
khoart
PRO
3
3.5k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.5k
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