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
Understanding Ast By Looking
Search
inouehi
March 09, 2024
Programming
0
2.2k
Understanding Ast By Looking
『木を見て!森を見て!目で見てわかるAST(抽象構文木)』
PHPerKaigi 2024
2024-03-09 15:40〜 Track A
https://phperkaigi.jp/2024/
inouehi
March 09, 2024
Tweet
Share
More Decks by inouehi
See All by inouehi
Using AI Tools Around Software Development
inouehi
0
1.4k
Let's Take a Peek at PHP Parser 5.x!
inouehi
0
210
Learning Kotlin with detekt
inouehi
1
630
Learning numeric-like string based on RFC
inouehi
0
100
What We Can Learn From OSS
inouehi
0
1k
Learning PHP and Static Analysis with PHP Parser
inouehi
2
730
Improve Our Development Habits by Measuring Productivity and Maintainability
inouehi
1
1.5k
Simple Strategy to Read PHP More Easily
inouehi
0
840
What We Learned and What We Didn't from Our Efforts to Visualize Productivity
inouehi
0
610
Other Decks in Programming
See All in Programming
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
110
個人軟體時代
ethanhuang13
0
330
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
320
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
Namespace and Its Future
tagomoris
6
710
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
710
Compose Multiplatform × AI で作る、次世代アプリ開発支援ツールの設計と実装
thagikura
0
170
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
11
4.4k
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
2.8k
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
4.3k
Ruby Parser progress report 2025
yui_knk
1
460
Featured
See All Featured
Practical Orchestrator
shlominoach
190
11k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
850
How to Ace a Technical Interview
jacobian
279
23k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Bash Introduction
62gerente
615
210k
The World Runs on Bad Software
bkeepers
PRO
70
11k
A Tale of Four Properties
chriscoyier
160
23k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
A designer walks into a library…
pauljervisheath
207
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
YesSQL, Process and Tooling at Scale
rocio
173
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
Transcript
木を見て!森を見て! 目で見てわかるAST(抽象構文木) 2024/03/09 PHPerKaigi 2024 LT
2 • Hiroki Inoue • Software Engineer • Engineering Manager
@ WHITEPLUS, Inc. About Me
3 トーク概要 このトークでは、ASTを見ます。 見ることで理解に迫ります。年に1度、5分だけ、1年分の感謝を込めてASTだけを見つめPHP Parserに 想いを馳せる。そんな時間にしたいと思います。 https://fortee.jp/phperkaigi-2024/proposal/55a9f921-3540-4373-bed8-8b3073c06d64
4 誰向けのトーク? Who is this talk for?
5 あなた You
6 伝えたいこと What I want to tell
7 尊敬 Respect
8 感謝 Gratitude
9 愛 Ai
10 愛 Adoration or something
11 ありがとうPHP Parser MY utmost appreciation and heartfelt thanks for
PHP Parser
12 ありがとうnikic-san and nikic-san
13 俺たちは PHP Parser から 恩恵を受けまくっている
14 PHPStan https://phpstan.org/blog/find-bugs-in-your-code-without-writing-tests#on-the-shoulders-of-giants
15 Rector https://getrector.com/documentation/how-rector-works
16 Psalm https://psalm.dev/docs/contributing/philosophy/
17 AST is 何? What is AST?
18 AST
19 A S T
20 AiSiTeru
21 AST is 愛
22 見ろ Look
23 見つめろ Don't think, look
24 ASTを見つめろ Look at AST
25 百聞は一見にしかず Seeing is understanding
26 トーク概要 このトークでは、ASTを見ます。 見ることで理解に迫ります。年に1度、5分だけ、1年分の感謝を込めてASTだけを見つめPHP Parserに 想いを馳せる。そんな時間にしたいと思います。 https://fortee.jp/phperkaigi-2024/proposal/55a9f921-3540-4373-bed8-8b3073c06d64
27 AST Examples
28 <?php function foo() { echo 'bar'; }
29 <?php function foo() { echo 'bar'; }
30 <?php function foo() { echo 'bar'; } ノード ノード
ノード ノード
31 <?php function foo() { echo 'bar'; }
32 <?php function foo() { echo 'bar'; }
33 Let’s traverse!
34 <?php function foo() { echo 'bar'; }
35 <?php function foo() { echo 'bar'; }
36 <?php function foo() { echo 'bar'; }
37 <?php function foo() { echo 'bar'; }
38 <?php function foo() { echo 'bar'; }
39 <?php function foo() { echo 'bar'; }
40 参考資料 14:40~ Track Aにて 『PHP Parserで学ぶPHPと静的解析』 という話をしました
41 declareを追加する
42 <?php declare(strict_types=1); function foo() { echo 'bar'; } プレ|サフィックスは作図のための
便宜的なもの Rootは作図のための 便宜的なもの 気にしないで…
43 <?php declare(strict_types=1); function foo() { echo 'bar'; } 枝分かれする
44 <?php declare(strict_types=1); function foo() { echo 'bar'; } こっちはさっきと同じ
45 <?php declare(strict_types=1); function foo() { echo 'bar'; }
46 Let’s traverse!
47 <?php declare(strict_types=1); function foo() { echo 'bar'; }
48 <?php declare(strict_types=1); function foo() { echo 'bar'; }
49 <?php declare(strict_types=1); function foo() { echo 'bar'; }
50 <?php declare(strict_types=1); function foo() { echo 'bar'; }
51 <?php declare(strict_types=1); function foo() { echo 'bar'; }
52 <?php declare(strict_types=1); function foo() { echo 'bar'; }
53 <?php declare(strict_types=1); function foo() { echo 'bar'; }
54 <?php declare(strict_types=1); function foo() { echo 'bar'; }
55 <?php declare(strict_types=1); function foo() { echo 'bar'; }
56 <?php declare(strict_types=1); function foo() { echo 'bar'; }
57 <?php declare(strict_types=1); function foo() { echo 'bar'; }
58 <?php declare(strict_types=1); function foo() { echo 'bar'; }
59 namespaceを追加する
60 <?php declare(strict_types=1); namespace Baz; function foo() {} 枝分かれするのは さっきと同じ
61 <?php declare(strict_types=1); namespace Baz; function foo() {} こっちはさっきと同じ
62 <?php declare(strict_types=1); namespace Baz; function foo() {} namespaceがfunctionの 親になる
63 Let’s traverse!
64 <?php declare(strict_types=1); namespace Baz; function foo() {}
65 <?php declare(strict_types=1); namespace Baz; function foo() {}
66 <?php declare(strict_types=1); namespace Baz; function foo() {}
67 <?php declare(strict_types=1); namespace Baz; function foo() {}
68 <?php declare(strict_types=1); namespace Baz; function foo() {}
69 <?php declare(strict_types=1); namespace Baz; function foo() {}
70 <?php declare(strict_types=1); namespace Baz; function foo() {}
71 <?php declare(strict_types=1); namespace Baz; function foo() {}
72 <?php declare(strict_types=1); namespace Baz; function foo() {}
73 <?php declare(strict_types=1); namespace Baz; function foo() {}
74 <?php declare(strict_types=1); namespace Baz; function foo() {}
75 <?php declare(strict_types=1); namespace Baz; function foo() {}
76 文字列演算子
77 <?php function foo() { echo 'The' . 'World!'; }
barがドット区切りのThe World!に
78 <?php function foo() { echo 'The' . 'World!'; }
ここはさっきと同じ
79 <?php function foo() { echo 'The' . 'World!'; }
80 <?php function foo() { echo 'The' . 'World!'; }
81 <?php function foo() { echo 'The' . 'World!'; }
82 繰り返される文字列演算子
83 <?php function foo() { echo '無' . '駄' .
'無駄'; } ドットが2つ
84 <?php function foo() { echo '無' . '駄' .
'無駄'; }
85 <?php function foo() { echo '無' . '駄' .
'無駄'; }
86 Let’s traverse!
87 <?php function foo() { echo '無' . '駄' .
'無駄'; }
88 <?php function foo() { echo '無' . '駄' .
'無駄'; }
89 <?php function foo() { echo '無' . '駄' .
'無駄'; }
90 <?php function foo() { echo '無' . '駄' .
'無駄'; }
91 <?php function foo() { echo '無' . '駄' .
'無駄'; }
92 <?php function foo() { echo '無' . '駄' .
'無駄'; }
93 <?php function foo() { echo '無' . '駄' .
'無駄'; }
94 <?php function foo() { echo '無' . '駄' .
'無駄'; }
95 <?php function foo() { echo '無' . '駄' .
'無駄'; }
96 <?php function foo() { echo '無' . '駄' .
'無駄'; }
97 <?php function foo() { echo '無' . '駄' .
'無駄'; }
98 <?php function foo() { echo '無' . '駄' .
'無駄'; }
99 クラス
100 <?php class Foo { public function foo() { echo
'bar'; } }
101 <?php class Foo { public function foo() { echo
'bar'; } }
102 AST可視化ツール https://github.com/hirokinoue/ast-visualizer
103 PlantUML Online Server PlantUML Online Server - Image tab
104 このLTに込めた想い PHPの開発現場においてPHP ParserやASTは謂わば空気。 欠かせないものですが、私たちがそれのことを気に留めることはほとんどありません。 年に1度、5分だけ、1年分の感謝を込めてASTだけを見つめPHP Parserに想いを馳せる。 そんな時間にしたいと思います。 https://fortee.jp/phperkaigi-2024/proposal/55a9f921-3540-4373-bed8-8b3073c06d64
105 ありがとうnikic-san Again, I wish to express my deep respect
and gratitude to nikic-san
ご清聴ありがとうございました