Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Mythical trees and where to find them
Search
Gabriele Petronella
November 11, 2017
Programming
0
240
Mythical trees and where to find them
An introduction to ASTs in JavaScript
Gabriele Petronella
November 11, 2017
Tweet
Share
More Decks by Gabriele Petronella
See All by Gabriele Petronella
Design System Adventures in React - ReactJS Day 2024
gabro
0
110
Design System Adventures in React
gabro
1
110
Casting Metals
gabro
0
370
Functional Programming in front-end applications
gabro
1
230
Functional Programming in Front-end Applications
gabro
3
190
How to get away with Functional Programming in front-end applications
gabro
3
1.5k
Bridging the tooling gap with Scala.js
gabro
0
290
Monad Transformers Down to Earth
gabro
2
2.7k
Move fast and fix things
gabro
0
350
Other Decks in Programming
See All in Programming
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
110
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
320
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
300
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
120
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
370
WebRTC と Rust と8K 60fps
tnoho
2
1.9k
Integrating WordPress and Symfony
alexandresalome
0
150
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
270
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
160
AIコーディングエージェント(skywork)
kondai24
0
160
Developing static sites with Ruby
okuramasafumi
0
260
Featured
See All Featured
Done Done
chrislema
186
16k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
A Tale of Four Properties
chriscoyier
162
23k
Mobile First: as difficult as doing things right
swwweet
225
10k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Side Projects
sachag
455
43k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Designing for Performance
lara
610
69k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
Mythical Trees and where to find them Gabriele Petronella Software
Engineer @ buildo
me, hi! @gabro27 - Codemotion 11/11/2017
stuff I do (by day) @gabro27 - Codemotion 11/11/2017
stuff I do (by night) @gabro27 - Codemotion 11/11/2017
Why this talk @gabro27 - Codemotion 11/11/2017
Agenda 1.AST 2.AST workflows 3.A real-world example @gabro27 - Codemotion
11/11/2017
Let's start from the answer const answer = 42; @gabro27
- Codemotion 11/11/2017
Tokens const answer = 42 ; // | | |
| | | | | | | // \_'const'_/ \_name_/ \_'='_/ \_num_/ \_';'_/ @gabro27 - Codemotion 11/11/2017
Grammar const answer = 42 ; // | | |
| || // | \_Identifier__/ \_NumericLiteral_/| // | | | // | \_________VariableDeclarator________/ // | | // \____________VariableDeclaration____________/ @gabro27 - Codemotion 11/11/2017
So... AST? @gabro27 - Codemotion 11/11/2017
Abstract Syntax Tree @gabro27 - Codemotion 11/11/2017
Why Abstract? const answer = 42; const answer = 42
const answer = 42 const answer = 42 @gabro27 - Codemotion 11/11/2017
AST in JavaScript @gabro27 - Codemotion 11/11/2017
AST? ASTs! parser AST ES2017 ES next acorn ESTree ✅
only stage-4 babylon Babylon AST ✅ ✅ espree ESTree ✅ same as acorn esprima ESTree ✅ ❌ flow ESTree + custom ✅ ✅ TypeScript TypeScript AST ✅ ✅ @gabro27 - Codemotion 11/11/2017
astexplorer.net @gabro27 - Codemotion 11/11/2017
AST Workflows @gabro27 - Codemotion 11/11/2017
basic @gabro27 - Codemotion 11/11/2017
babel @gabro27 - Codemotion 11/11/2017
demo: literal transformation @gabro27 - Codemotion 11/11/2017
codemod @gabro27 - Codemotion 11/11/2017
hey, doesn't babel do the same thing? @gabro27 - Codemotion
11/11/2017
codemod tools » recast » jscodeshift @gabro27 - Codemotion 11/11/2017
eslint @gabro27 - Codemotion 11/11/2017
ESLint uses espree, so... What about ES next? @gabro27 -
Codemotion 11/11/2017
babel-eslint @gabro27 - Codemotion 11/11/2017
demo: no-console- log @gabro27 - Codemotion 11/11/2017
What about eslint --fix @gabro27 - Codemotion 11/11/2017
prettier @gabro27 - Codemotion 11/11/2017
Prettier... for TS? @gabro27 - Codemotion 11/11/2017
Meanwhile in the real world @gabro27 - Codemotion 11/11/2017
// MyContainer.js import t from 'tcomb'; import container from 'buildo-react-container';
import MyComponent from './MyComponent'; export default container(MyComponent, { connect: { isFlag: t.Boolean, name: t.String, label: t.maybe(t.String) } }); @gabro27 - Codemotion 11/11/2017
// state.js export default { isFlag: t.Boolean, name: t.String, label:
t.maybe(t.String) } @gabro27 - Codemotion 11/11/2017
// MyContainer.js import t from 'tcomb'; import container from 'buildo-react-container';
import MyComponent from './MyComponent'; export default container(MyComponent, { connect: ['isFlag', 'name', 'label'] }); @gabro27 - Codemotion 11/11/2017
DEMO @gabro27 - Codemotion 11/11/2017
We've seen @gabro27 - Codemotion 11/11/2017
AST: what and why @gabro27 - Codemotion 11/11/2017
Competing AST standards in JS @gabro27 - Codemotion 11/11/2017
Typical AST-based workflows @gabro27 - Codemotion 11/11/2017
Some resources » astexplorer.net » Babel Handbook @gabro27 - Codemotion
11/11/2017
Thank you @gabro27 - Codemotion 11/11/2017
Questions? ping me on Twitter: @gabro27 or @gabro on Slack
(http://milanojs.herokuapp.com/) PS: wanna work on this stuff? We're hiring! @gabro27 - Codemotion 11/11/2017