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.3k
Let's Take a Peek at PHP Parser 5.x!
inouehi
0
170
Learning Kotlin with detekt
inouehi
1
570
Learning numeric-like string based on RFC
inouehi
0
95
What We Can Learn From OSS
inouehi
0
960
Learning PHP and Static Analysis with PHP Parser
inouehi
2
700
Improve Our Development Habits by Measuring Productivity and Maintainability
inouehi
1
1.5k
Simple Strategy to Read PHP More Easily
inouehi
0
830
What We Learned and What We Didn't from Our Efforts to Visualize Productivity
inouehi
0
590
Other Decks in Programming
See All in Programming
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
6
2.3k
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
780
フロントエンドのパフォーマンスチューニング
koukimiura
4
1.5k
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
410
チームのテスト力を総合的に鍛えて品質、スピード、レジリエンスを共立させる/Testing approach that improves quality, speed, and resilience
goyoki
5
980
顧客の画像データをテラバイト単位で配信する 画像サーバを WebP にした際に起こった課題と その対応策 ~継続的な取り組みを添えて~
takutakahashi
1
150
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
580
ペアプロ × 生成AI 現場での実践と課題について / generative-ai-in-pair-programming
codmoninc
2
20k
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
610
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
5
1.4k
ソフトウェア品質を数字で捉える技術。事業成長を支えるシステム品質の マネジメント
takuya542
2
14k
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
96
33k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
184
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Why Our Code Smells
bkeepers
PRO
336
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Designing for Performance
lara
610
69k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Designing for humans not robots
tammielis
253
25k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Facilitating Awesome Meetings
lara
54
6.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
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
ご清聴ありがとうございました