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
610
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
What We Can Learn From OSS
inouehi
0
460
Learning PHP and Static Analysis with PHP Parser
inouehi
1
320
Improve Our Development Habits by Measuring Productivity and Maintainability
inouehi
1
640
Simple Strategy to Read PHP More Easily
inouehi
0
660
What We Learned and What We Didn't from Our Efforts to Visualize Productivity
inouehi
0
310
Paying Off Technical Dept with Rector -The First Step-
inouehi
0
660
Learning PHP with PHP Parser
inouehi
1
1.8k
Introduction to Static Analysis through Psalm
inouehi
0
950
Psalmで始めるOSS contribution
inouehi
0
290
Other Decks in Programming
See All in Programming
チーム立ち上げにAWSを活用したらClaudeさんに褒められた話
mkdev10
3
230
TypeScriptから始める VR生活
tamagokakeg
2
140
TypeScriptの型とパフォーマンス (TSKaigi 2024)
ypresto
14
5.2k
The test code generator using static analysis and LLM
mikik0
1
300
RailsConf 2024: Riffing on Rails: sketch your way to better designed code
kaspth
1
220
otelcol receiver 自作RTA / Pepabo Tech Conference #22 春のSREまつり
arthur1
0
1.1k
GoでParserを書く
karupanerura
3
450
Open standards for building event-driven applications in the cloud
meteatamel
0
230
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
2
74k
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
370
ソースコードを美しくたもつために ~コードレビューの認知限界を突破し、年間400リリースを達成する~
kotauchisunsun
1
790
Deep Dive into React Stream/Serialize
mugi_uno
4
880
Featured
See All Featured
WebSockets: Embracing the real-time Web
robhawkes
59
7k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
34
6.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Designing the Hi-DPI Web
ddemaree
276
33k
GraphQLとの向き合い方2022年版
quramy
33
13k
RailsConf 2023
tenderlove
9
590
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Designing for humans not robots
tammielis
247
25k
Making Projects Easy
brettharned
109
5.5k
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
ご清聴ありがとうございました