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
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
Let's Take a Peek at PHP Parser 5.x!
inouehi
0
130
Learning Kotlin with detekt
inouehi
1
390
Learning numeric-like string based on RFC
inouehi
0
81
What We Can Learn From OSS
inouehi
0
890
Learning PHP and Static Analysis with PHP Parser
inouehi
2
660
Improve Our Development Habits by Measuring Productivity and Maintainability
inouehi
1
1.5k
Simple Strategy to Read PHP More Easily
inouehi
0
800
What We Learned and What We Didn't from Our Efforts to Visualize Productivity
inouehi
0
540
Paying Off Technical Dept with Rector -The First Step-
inouehi
1
1.1k
Other Decks in Programming
See All in Programming
The Implementations of Advanced LR Parser Algorithm
junk0612
1
280
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
2
570
アプリを起動せずにアプリを開発して品質と生産性を上げる
ishkawa
0
2.8k
DataStoreをテストする
mkeeda
0
290
PHPで書いたAPIをGoに書き換えてみた 〜パフォーマンス改善の可能性を探る実験レポート〜
koguuum
0
150
Road to RubyKaigi: Making Tinny Chiptunes with Ruby
makicamel
4
120
リアルタイムレイトレーシング + ニューラルレンダリング簡単紹介 / Real-Time Ray Tracing & Neural Rendering: A Quick Introduction (2025)
shocker_0x15
1
300
タイムゾーンの奥地は思ったよりも闇深いかもしれない
suguruooki
1
640
Signal-Based Data FetchingWith the New httpResource
manfredsteyer
PRO
0
170
Building a macOS screen saver with Kotlin (Android Makers 2025)
zsmb
1
150
Do Dumb Things
mitsuhiko
0
430
エンジニア未経験が最短で戦力になるためのTips
gokana
0
270
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
Designing for Performance
lara
608
69k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
135
33k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
StorybookのUI Testing Handbookを読んだ
zakiyama
29
5.6k
Code Reviewing Like a Champion
maltzj
522
40k
Thoughts on Productivity
jonyablonski
69
4.6k
A Tale of Four Properties
chriscoyier
158
23k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
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
ご清聴ありがとうございました