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
600
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
620
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
JS RPCを理解する
yusukebe
5
270
Docker_OSS_ホスティング入門
satokoki645
0
140
TypeScriptコードの漸進的改善 / Progressive Improvement of TypeScript Code
medley
1
440
TypeScriptで使いやすいOpenAPIの書き方
yukimochi_dwango
1
870
Criando a Woovi em uma semana
daniloab
0
120
2024 コーディング研修
ckazu
2
650
仕様と実装で学ぶOpenTelemetry
drumato
2
1.1k
Enjoy Creative Coding with Ruby (RubyKaigi2024)
chobishiba
0
320
Documentation testsの恩恵 / Documentation testing benefits
ssssota
1
560
戦略的DDDは重いのか? / Is strategic DDD heavy?
pictiny
3
2.1k
The Design of Everyday APIs - PyCon 2024
roguelynn
0
190
WinActorの勉強を継続する方法
tamai_63
0
130
Featured
See All Featured
The Invisible Customer
myddelton
114
12k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Practical Orchestrator
shlominoach
183
9.8k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.7k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
Fireside Chat
paigeccino
22
2.7k
Raft: Consensus for Rubyists
vanstee
133
6.3k
Designing for Performance
lara
601
67k
Code Review Best Practice
trishagee
56
15k
Writing Fast Ruby
sferik
622
60k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Designing with Data
zakiwarfel
96
4.8k
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
ご清聴ありがとうございました