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
0
94
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
55
Writing Readable Migrations with Nextras Migrations
jantvrdik
1
110
Nextras Mail Panel
jantvrdik
0
160
Writing reliable migrations with Nextras Migrations
jantvrdik
1
690
Other Decks in Programming
See All in Programming
オープンソースソフトウェアへの解像度🔬
utam0k
15
2.8k
高度なUI/UXこそHotwireで作ろう Kaigi on Rails 2025
naofumi
4
4.1k
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
Flutterで分数(Fraction)を表示する方法
koukimiura
0
130
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
110
理論と実務のギャップを超える
eycjur
0
140
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
160
PHPに関数型の魂を宿す〜PHP 8.5 で実現する堅牢なコードとは〜 #phpcon_hiroshima / phpcon-hiroshima-2025
shogogg
1
220
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
840
Swift Concurrency - 状態監視の罠
objectiveaudio
2
520
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
230
CSC509 Lecture 05
javiergs
PRO
0
300
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
35
6.1k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
The Cult of Friendly URLs
andyhume
79
6.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Automating Front-end Workflow
addyosmani
1371
200k
Making Projects Easy
brettharned
120
6.4k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Designing Experiences People Love
moore
142
24k
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