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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jan Tvrdík
April 12, 2018
Programming
0
95
How to Write Parser in PHP
Jan Tvrdík
April 12, 2018
Tweet
Share
More Decks by Jan Tvrdík
See All by Jan Tvrdík
Runtime Types in TypeScript
jantvrdik
0
56
Writing Readable Migrations with Nextras Migrations
jantvrdik
1
120
Nextras Mail Panel
jantvrdik
0
170
Writing reliable migrations with Nextras Migrations
jantvrdik
1
700
Other Decks in Programming
See All in Programming
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
480
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
130
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
1.1k
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
200
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.5k
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
1k
Docコメントで始める簡単ガードレール
keisukeikeda
1
130
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
480
OTP を自動で入力する裏技
megabitsenmzq
0
120
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
160
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
160
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
220
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
130
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
YesSQL, Process and Tooling at Scale
rocio
174
15k
A designer walks into a library…
pauljervisheath
210
24k
エンジニアに許された特別な時間の終わり
watany
106
240k
Paper Plane (Part 1)
katiecoart
PRO
0
5.7k
Un-Boring Meetings
codingconduct
0
230
Code Reviewing Like a Champion
maltzj
528
40k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
310
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
74
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