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
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
320
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
260
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
360
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
300
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
220
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.5k
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
1.1k
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
2
21k
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
15
5.6k
ニーリーにおけるプロダクトエンジニア
nealle
0
950
NPOでのDevinの活用
codeforeveryone
0
900
マッチングアプリにおけるフリックUIで苦労したこと
yuheiito
0
190
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
A better future with KSS
kneath
238
17k
Navigating Team Friction
lara
187
15k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Visualization
eitanlees
146
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Designing Experiences People Love
moore
142
24k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Building Applications with DynamoDB
mza
95
6.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
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