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
Abstract Syntax Tree in Javascript
Search
Taketoshi Aono(青野健利 a.k.a brn)
January 24, 2018
Programming
0
180
Abstract Syntax Tree in Javascript
JavascriptのASTについて
Taketoshi Aono(青野健利 a.k.a brn)
January 24, 2018
Tweet
Share
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
3k
Parsing Javascript
brn
14
9.3k
JSON & Object Tips
brn
1
490
CA 1Day Youth Bootcamp for Frontend LT
brn
0
950
Modern TypeScript
brn
2
810
javascript - behind the scene
brn
3
740
tc39 proposals
brn
0
880
プロダクト開発とTypeScript
brn
8
2.9k
React-Springでリッチなアニメーション
brn
1
700
Other Decks in Programming
See All in Programming
Claude Code + Container Use と Cursor で作る ローカル並列開発環境のススメ / ccc local dev
kaelaela
10
6k
XP, Testing and ninja testing
m_seki
3
250
10 Costly Database Performance Mistakes (And How To Fix Them)
andyatkinson
0
440
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
260
テスト駆動Kaggle
isax1015
1
430
RailsGirls IZUMO スポンサーLT
16bitidol
0
190
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
270
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
170
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
780
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
210
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
860
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
440
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Why Our Code Smells
bkeepers
PRO
336
57k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Building Applications with DynamoDB
mza
95
6.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
310
Fireside Chat
paigeccino
37
3.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
We Have a Design System, Now What?
morganepeng
53
7.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Transcript
Abstract Syntax Tree in Javascript
Name @brn (ꫬꅿ⨳ⵃ) Occupation ؿٗٝزؒٝسؒٝآص،٥ط؎ذ؍ـؒٝآص، Company Cyberagent ،سذؙأةآؔ AI Messenger
OSS Contributor of V8 Blog http://abcdef.gets.b6n.ch/ Twitter https://twitter.com/brn227 GitHub https://github.com/brn
What is AST? ASTהכJavascriptךفؚٗٓيػ٦أ׃穠卓欰䧭ׁ 圓俑邌植׃加圓鸡ךֿה
if (x) { x = 100 }
IF CONDITION THEN BLOCK EXPRESSION STATEMENT ASSIGN VAR PROXY (X)
LITERAL (100) if (x) { x = 100
Why need it? فؚٗٓيך㶵ךתת⢪ֲךכꨇ׃ְկ javascript㹋遤ׅחכ圫ղזؿؑ٦ؤָ֮կ غ؎ز؝٦س欰䧭ծCFG欰䧭ծIR欰䧭ծ剑黝⻉ծetc…
How do I create it? فؚٗٓىؚٝ鎉铂חכ㛇劤涸חכ俑岀ָ㶷㖈ׅկ JavascriptכEcmaInternationalָ➬圫תהגⰕ׃גְկ
None
Grammars ך⚥ח俑岀ָ㹀纏ׁגְل٦آָ֮ךדֿ撑ֿׅ הדػ٦؟٦剅ֻֿהָדֹկ
None
But… ֿך俑岀㹀纏כ㛇劤涸חךתת⢪ֲךכꨇ׃ְկ
Javascript become too complex Javascriptך俑岀כַז醱꧟חזגֹגֶծ秪磏חךתת ػ٦أֿׅהַָזꨇ׃ְկ
var a = /aaa|bbb/! b / 2 = 0;! !
// Is it easy?! b = / 2 = 0 /! ת׆כ剣せז姻鋉邌植ַ
var a = (x, y) => x + y;! var
a = (x, y);! ! var a = x => x;! var a = x;! ،ٗ٦ꟼ侧
None
var {a: b, b: c} = {b: 1, c: 2};!
({a: b, b: c});! ! [a, b, c] = [0, 1, 2];! [a, b, c];! ⴓⶴ➿Ⰵ
Parser has many state 穠㽷Parserכ㣐ꆀך朐䡾⥂䭯׃זָ갹䓸גػ٦أׅ׃ַז ְկ
AST Usage 蕱⸤׃ג⡲♳־ASTכוֲ⢪גְךַ
In V8 ASTַScope欰䧭׃ׅ ׁח剑穄涸חBytecode欰䧭׃ג㹋遤ׅ YieldװAsync٥Awaitך圓俑JavascriptךStateMachineח㢌䳔ׅ
In Babel AST㢌䳔׃ג剑倜ךJavascriptַ植㖈ךJavascriptפ㢌䳔ׅ
In istanbul AST㢌䳔׃גぐ؝٦سח鸐麓׃⽩➰ֽ؝٦س㙵鴥
Try and play AST Esprima⢪ֲֿהד知⽃חAST欰䧭ֿׅהָדֹ ת https://github.com/estools חػ٦أ׃ASTQuery׃ׅخ٦ָٕ尶㿊֮ךד鑐׃ גה葺ְ
Summary AST鍗ה鸐䌢ךفؚٗٓيדכꨇ׃ַֿהָ葿ղדֹ״ ֲחז 嚂׃ְךד僽ꬊ♧㔐ְֻכ鑐׃גהְְה䙼ֲ